Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4018) - 28 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

Programmer's help needed !

Talk about anything that doesn't fit elsewhere - PLEASE don't put Cumulus queries in here!
Post Reply
User avatar
laulau
Posts: 678
Joined: Tue 13 Oct 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Programmer's help needed !

Post by laulau »

Hi,
I've written a little VB application that monitors my central heating device through a PLC.
It produces log files and runs an extenal program at each 'realtime', 'logtime' and rollover as Cumulus do.

The code i use to run the external batch:

Code: Select all

Call Shell("MyCommand.cmd")
but i've a little problem: :oops:
Each time the external program runs it opens a little "Command line window" (closed automaticaly) but it's very annoying when you're doing something on the same computer.
Question : is there an other instruction i can use or some options to hide the "Command line window" ? :idea: :?:
Thanks
Laurent

Image
uncle_bob
Posts: 505
Joined: Wed 17 Aug 2011 2:58 pm
Weather Station: WeatherDuino Pro2
Operating System: 2008
Location: Canberra

Re: Programmer's help needed !

Post by uncle_bob »

laulau wrote: Question : is there an other instruction i can use or some options to hide the "Command line window"
Yeah there is, but I can't for the life of me, remember what it is as it's been 10 years since I mucked with DOS :)
Interested in building your own Weather Station? Maybe check out the WeatherDuino Pro Project Here
Conder, Canberra Weather
Image
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Programmer's help needed !

Post by nitrx »

BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Programmer's help needed !

Post by BCJKiwi »

Does the info here help?
http://www.developerfusion.com/article/ ... -function/

1. Shell without the call
2. vbHide

Just a guess, my VB skills <=0 !
User avatar
laulau
Posts: 678
Joined: Tue 13 Oct 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: Programmer's help needed !

Post by laulau »

@ BCJKiwi
I'll it this evening.

@ Steve
How do you manage the external programs call in Cumulus (pascal) ?
Laurent

Image
User avatar
steve
Cumulus Author
Posts: 26702
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Programmer's help needed !

Post by steve »

laulau wrote:@ Steve
How do you manage the external programs call in Cumulus (pascal) ?
I use a wrapper to ShellExecute, like this:

Code: Select all

Res := ShellExecute(MainForm.Handle, nil, PChar(prog), PChar(Params), nil, 0);
Steve
User avatar
laulau
Posts: 678
Joined: Tue 13 Oct 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: Programmer's help needed !

Post by laulau »

Hi,
Changed

Code: Select all

Call Shell("MyCommand.cmd")
to

Code: Select all

Shell("MyCommand.cmd",0)
No more annoying windows :D
:clap: et Merci
Now i'm going to write a ftp subroutine to upload my log files, for the moment Cumulus is doing this job perfectly ;)
I certainly need some more help to achieve that :oops:
I'll start by googling on this topic!
Laurent

Image
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Programmer's help needed !

Post by BCJKiwi »

If you can live with Windows' built in simple FTP, then you can add that to your batch file. If not you can add a command line FTP program (e.g. NcFTP available here at no cost).
http://www.ncftp.com/ncftp/
Click download, scroll down to download NcFTP Client and in the section Precompiled binary distributions
Select the "NcFTP Client 3.2.5 for Microsoft Windows" link.
This will download an .msi package and initiate an installation.
It installs the .exe' s into %windir% so all you need to do is call ncftpput. There will be shortcuts and documentation in c:\program Files\NcFTP Software\
Syntax is a bit finicky but this is fast and robust. It will also generate logs if you want.
User avatar
laulau
Posts: 678
Joined: Tue 13 Oct 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: Programmer's help needed !

Post by laulau »

Is ncfp more efficient than windows ftp command line ?

I also found the option to use

Code: Select all

Public Sub UploadFile(ByVal _FileName As String, ByVal _UploadPath As String, ByVal _FTPUser As String, ByVal _FTPPass As String)

        Dim _FileInfo As New System.IO.FileInfo(_FileName)

        If _FileInfo.Exists Then
            ' Create FtpWebRequest object from the Uri provided
            Dim _FtpWebRequest As System.Net.FtpWebRequest = CType(System.Net.FtpWebRequest.Create(New Uri(_UploadPath)), System.Net.FtpWebRequest)
            Try

                ' Provide the WebPermission Credintials
                _FtpWebRequest.Credentials = New System.Net.NetworkCredential(_FTPUser, _FTPPass)

                ' By default KeepAlive is true, where the control connection is not closed
                ' after a command is executed.
                _FtpWebRequest.KeepAlive = False

                ' set timeout for 2 seconds
                _FtpWebRequest.Timeout = 2000

                ' Specify the command to be executed.
                _FtpWebRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile

                ' Specify the data transfer type.
                _FtpWebRequest.UseBinary = True

                ' Notify the server about the size of the uploaded file
                _FtpWebRequest.ContentLength = _FileInfo.Length

                ' The buffer size is set to 2kb
                Dim buffLength As Integer = 2048
                Dim buff(buffLength - 1) As Byte
                Try
                    ' Opens a file stream (System.IO.FileStream) to read the file to be uploaded
                    Dim _FileStream As System.IO.FileStream = _FileInfo.OpenRead()


                    ' Stream to which the file to be upload is written
                    Dim _Stream As System.IO.Stream = _FtpWebRequest.GetRequestStream()

                    ' Read from the file stream 2kb at a time
                    Dim contentLen As Integer = _FileStream.Read(buff, 0, buffLength)

                    ' Till Stream content ends
                    Do While contentLen <> 0
                        ' Write Content from the file stream to the FTP Upload Stream
                        _Stream.Write(buff, 0, contentLen)
                        contentLen = _FileStream.Read(buff, 0, buffLength)
                    Loop

                    ' Close the file stream and the Request Stream
                    _Stream.Close()
                    _Stream.Dispose()
                    _FileStream.Close()
                    _FileStream.Dispose()
                Catch ex As Exception
                    MessageBox.Show(ex.Message, "Upload Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                End Try
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Connect Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try

        End If
        
    End Sub
in my VB application.
Does anyone have an opinion on this :?:
Laurent

Image
BCJKiwi
Posts: 1255
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Programmer's help needed !

Post by BCJKiwi »

Is ncfp more efficient than windows ftp command line ?
NcFTP package just a suggestion - it has been around a long time and is very robust. Has a lot more features but is a little more tricky to set up than the windows built in FTP. However windows FTP works well enough if you just want simple. You could start with that and move to something more sophisticated later if required. I only suggested it as you already have a batch file so why not use some well developed and bullet proof command line FTP instead of 'rolling your own'.
Karv
Posts: 40
Joined: Sun 16 Dec 2012 11:19 pm
Weather Station: WH-1080
Operating System: Windows XP / 7, Ubuntu, Centos
Location: South Gloucestershire

Re: Programmer's help needed !

Post by Karv »

if you have a batch job, you can just call an FTP script to move files about, they are as simple as

Code: Select all

open <ip address>
username
password
cd /<directoy>[optional]
put filename [or mput *.extension or get or mget]
bye
call this from your batch script as
ftp -i -s:<path/to/ftpscript>

:)
Post Reply