Please read the posts in the Announcements section about the current status of Cumulus development now that I have retired

Please read this post before posting

Latest Cumulus release v1.9.4 (build 1099) - Nov 28 2014
Latest Cumulus MX release - v3.0.0 build 3043 Jan 20 2017. See this post for download

Programmer's help needed !

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

Programmer's help needed !

Postby laulau » Tue Feb 11, 2014 5:54 am

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: 472
Joined: Wed Aug 17, 2011 2:58 pm
Weather Station: WeatherDuino Pro2
Operating System: 2008
Location: Canberra

Re: Programmer's help needed !

Postby uncle_bob » Tue Feb 11, 2014 7:21 am

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: 1289
Joined: Sun Dec 13, 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: Programmer's help needed !

Postby nitrx » Tue Feb 11, 2014 8:25 am


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

Re: Programmer's help needed !

Postby BCJKiwi » Tue Feb 11, 2014 10:28 am

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: 518
Joined: Tue Oct 13, 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: Programmer's help needed !

Postby laulau » Tue Feb 11, 2014 11:07 am

@ 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: 26656
Joined: Mon Jun 02, 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: Programmer's help needed !

Postby steve » Tue Feb 11, 2014 1:01 pm

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
-----
Hosting available for Cumulus web sites. See http://sandaysoft.com/forum/viewtopic.php?f=2&t=11876

Please read the posts in the Announcements section about the current status of Cumulus development since I have retired from my day job

User avatar
laulau
Posts: 518
Joined: Tue Oct 13, 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: Programmer's help needed !

Postby laulau » Tue Feb 11, 2014 5:45 pm

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: 859
Joined: Mon Jul 09, 2012 8:40 pm
Weather Station: Davis VP2 Cabled with Solar
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Programmer's help needed !

Postby BCJKiwi » Tue Feb 11, 2014 7:38 pm

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: 518
Joined: Tue Oct 13, 2009 10:52 pm
Weather Station: WeatherDuino Pro2
Operating System: Win 7
Location: Meyenheim, Alsace, FR
Contact:

Re: Programmer's help needed !

Postby laulau » Tue Feb 11, 2014 9:39 pm

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: 859
Joined: Mon Jul 09, 2012 8:40 pm
Weather Station: Davis VP2 Cabled with Solar
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: Programmer's help needed !

Postby BCJKiwi » Wed Feb 12, 2014 3:10 am

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: 38
Joined: Sun Dec 16, 2012 11:19 pm
Weather Station: WH-1080
Operating System: Windows XP / 7, Ubuntu, Centos
Location: South Gloucestershire
Contact:

Re: Programmer's help needed !

Postby Karv » Wed Feb 12, 2014 4:33 pm

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>

:)
Image


Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest