Our full technical support staff does not monitor this forum.
Please submit your question from our support page if you don't find an answer here.
Next Page

1 2

Previous Page

Created on: 05/29/12 02:19 PM

Can you use ShortCut to make a CR1000 w/ NL120 push to FTP?

Replies: 11

aps

United Kingdom


Campbell Scientific Ltd. Employee Campbell Scientific Ltd.

Posts: 669
Joined: 09/15/08

RE: Can you use ShortCut to make a CR1000 w/ NL120 push to FTP?
06/01/12 5:42 AM

The program below will do most everything you want. However, it only outputs the last 24 hours data every 24 hours not 48 hours worth of data. (The latter could be done but would involve merging two files which gets complicated due to the headers) It also tries to send the file up to 3 times until successful.

This should work but I have not tried it live. You may get an error the first time you load it as the USR drive it defined within the program to it takes one run before this is set correctly.

I hope this is beneficial to all to see the principles - there are other examples in the CRBasic help.

As I mentioned before this will become a little simpler in the next release of logger operating system although the option to timestamp files, which is already on the wish list, may be a version later.

--
'CR1000
'Created by Short Cut (2.8)

'Declare Variables and Units
Public BattV
Public PSP1
Public PSP2

'Define public variables - these are temporary memory locations with names that can be accessed by the program
Public Outstat As Boolean, Sendit As Boolean, SentOK As Boolean, tries 'These variables control the ftp process
Public LastFileName As String * 30 'This is a variable, defined as a string, that will store the name of the last file created by the TableFile instruction
Public Newfilename As String *50 'holds the timestamped destination filename

'Define constants - these are values with names that can be accessed by the program, but cannot be changed
Const ServerIP = "192.168.0.1" 'This is the address of the FTP server that you want to send files to
Const User = "Admin" 'This is the user name needed to login to the FTP server
Const Password = "Admin" 'This is the password needed to login to the FTP server
Const DestPath = "/Site1/Data/Onemin" 'This is the destination directory where the FTP'ed file will be saved on the FTP server

Units BattV=Volts
Units PSP1=mV
Units PSP2=mV

'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,1,Min,10)
'Every day at 2 am write a file of the last 24 hours data
TableFile ("USR:Onemin",8,-1,2,24,Hr,Outstat,LastFileName)
Average(1,BattV,FP2,False)
Average(1,PSP1,FP2,False)
Average(1,PSP2,FP2,False)
EndTable

'Main Program
BeginProg
SetStatus("UsrDriveSize","100000") 'Sets the USR drive size to 100k
Scan(1,Sec,1,0)
'Default Datalogger Battery Voltage measurement BattV
Battery(BattV)
'Generic Differential Voltage measurements PSP1
VoltDiff(PSP1,1,mV25,1,True,0,_60Hz,109.769,0)
'Generic Differential Voltage measurements PSP2
VoltDiff(PSP2,1,mV25,2,True,0,_60Hz,107.936,0)
'Call Data Tables and Store Data
CallTable(Table1)
'The following line sets a second variable the code in the slow sequence can monitor
'Checking Outstat is risky as it will get reset at the next run of the main scan
If Outstat Then
Sendit = true
tries=0
Newfilename = DestPath & " " & Public.TimeStamp(4,0) 'A quick way of generating a timestamp
Newfilename=Replace(Newfilename,":","") 'Get rid of the colons - not allowed in filenames
Newfilename=Newfilename &".dat" 'add a fixed suffix
EndIf
NextScan


SlowSequence 'Just to do the ftp without interferring with measurements.
Scan (1,min,3,0) 'Every minute check.
If Sendit Then
SentOK = FTPClient (ServerIP,User,Password,LastFileName,Newfilename,0)
tries=tries+1
If SentOK OR tries=3 Then Sendit=false
EndIf
NextScan


EndProg

Andrew Sandford, Technical Director, Campbell Scientific Ltd., U.K.

[Report Inappropriate or Erroneous Content]

joshdr83


Posts: 19
Joined: 05/29/12

RE: Can you use ShortCut to make a CR1000 w/ NL120 push to FTP?
06/01/12 9:34 AM

Thank you very much - I will see how this does over the weekend. I appreciate your patience with my lacking of experience.

If there seems to be a problem with checking Outstat, I will let you know.

[Report Inappropriate or Erroneous Content]

Next Page

1 2

Previous Page

Reply

Please login to post a response.