Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Writing a file on hard drive


Ehsan Jun 27, 2011 09:35 PM

I am trying to wrtie an ASCII file on C:\ drive of my computer. Which command should I use.

Thanks
E.


Sam Jun 28, 2011 01:07 AM

If you are trying to write data from a DataTable out, I suggest using the TableFile instruction.


Public PTemp, batt_volt
Public OutStat As Boolean
Public LastFileName As String * 31
DataTable (Test,1,1000)
DataInterval (0,15,Sec,10)
TableFile("USR:Test_",8,-1,0,1,Min,OutStat,LastFileName)
Minimum (1,batt_volt,FP2,0,False)
Sample (1,PTemp,FP2)
EndTable
BeginProg
Scan (1,Sec,0,0)
PanelTemp (PTemp,250)
Battery (batt_volt)
CallTable Test
NextScan
EndProg

If you want to create a custom file then use the FileOpen, FileWrite, and FileClose instructions.



Public Var01
Public Var02
Public Var03
Public Save
Const FName = "USR:MyFile.txt"
Dim FContent As String * 63
Dim FHandle As Long
BeginProg
Scan (1,Sec,0,0)
If Save Then
Save = 0
FContent = "<Var01>" + Var01 + "</Var01>" + _
"<Var02>" + Var02 + "</Var02>" + _
"<Var03>" + Var03 + "</Var03>"
SemaphoreGet (1) 'lock file resource
FHandle = FileOpen (FName,"w",0) 'open file
FileWrite (FHandle,FContent,0) 'write file
FileClose (FHandle) 'close file
SemaphoreRelease (1) 'release file resource
EndIf
NextScan
EndProg

* Last updated by: Sam on 6/27/2011 @ 7:07 PM *


Ehsan Jun 28, 2011 04:18 PM

Thanks for your reply.
I see you are writing the file to USR.

Let me give you more details about what I am trying to do.
The daq is attached to a computer that runs another software which is supposed to read a number from a text file. That text file is writtern by Daq on the hard drive of the computer.
Let's say in your example, you want to write the "MyFile.txt" to C:\ drive of a computer that is attached to the Daq.
Is there anyway we can do that? on in other words, how can I transfer the text file from USR to the hard drive of the computer, for example C:\ drive.
Of course this transfer has to happen every 200 ms.

Thanks for your reply.
E.


Sam Jun 29, 2011 03:39 PM

Ehsan,

My apologies, I misread your initial post. My response is applicable to writing files locally on the logger.

If you would like to write files to the PC, another approach is required

* Use LoggerNet to collect the data and write to PC

* Use LoggerNet to perform a retrieval of a file written locally on the logger (like previous post)

* Use the logger's web services commands to retrieve a file via HTTP. In CRBasic help see the "Web Server/API Commands" section.

* Use Email or FTP for transfer of a file written locally on the logger (like previous post)

I'm dubious of the 200ms transfer rate.


aps Jun 30, 2011 09:07 AM

If you just want to write data being logged directly to the hard disk in real-time, there is a function in our RTDAQ product that allows you to spool the data from the logger onto disk at relatively high speed; much faster than 200 ms.

You do this using the Table Monitor tool and click on the Save to file checkbox. This is designed for short term experiements though, where the Table Monitor is left open throughout.

Details and a free trial can be found here:

http://www.campbellsci.com/rtdaq-support


Ehsan Jun 30, 2011 08:00 PM

Thanks for your replies.
I tried the Table Monitor option, but it does not write the file on HDD until the stop button is pressed. The file is written on HDD after stopping the monitor.

Is there a way to continuously write the table on HDD? for example to write every sample in the file on HDD.

I am using a CR1000 logger.

Thanks
Ehsan


aps Jul 1, 2011 09:21 AM

If you need the file to be close after every transfer, then Sam's suggestion of using a Loggernet to collect data as fast as it will allow in its schedule.

The only other way I can think to store data to a remote computers hard disk based upon when data is stored in the logger is by following the process Sam outlined above where you write a file to the dataloggers drive and then fire it off via ftp to a computer. FTP is not optimised for speed to it is unlikely you will achieve the speeds you want.

Log in or register to post/reply in the forum.