Hi,
I'm trying to send data out the serial port of the datalogger whenever a new record is stored in a data table. The data table is called by means of the AcceptDataRecords instruction. So, I was using the "TableName.Output" instruction to do this but it does not work out the same way as with the "CallTable" instruction because the AcceptDataRecords only calls the table whenever the remote record is received and not at every scan. So, this means that the TableName.Output is going to be true on every scan which is not what I'm looking for. Below is an example of what I'm trying to do. The remote records are received every second but it's sending duplicate data every 500 msec out the serial port. Any way to overcome this?
DataTable(Station_1A_Meas,True,-1)
Sample (1,WindSpeed,IEEE4)
Sample (1,WindDirection,IEEE4)
Sample (1,AirTemp,IEEE4)
Sample (1,RH,IEEE4)
EndTable
BeginProg
SerialOpen (COMRS232,115200,3,0,100000)
Scan (500,mSec,1,0)
AcceptDataRecords (5,32769,Station_1A_Meas)
DataOut=Station_1A_Meas.Output(1,1)
If DataOut Then
GetRecord (RecordTable,Station_1A_Meas,1)
SerialOut (ComRS232,String_1A_Meas,"",1,0)
EndIf
NextScan
EndProg
If it's difficult to see it at this rate, try receiving the remote records once a minute and have the scan rate be one second.
Thanks.
I had a look at this and it seems once a record is received into the table the Output flag goes true but is never reset - I suspect because it is normally reset on the next call of the table.
A work around to this is shown below, where you track the record number of the last record in the table rather than the output flag.
Note for my test I changed the serial ports and also added some test code in a slow sequence which you won't need. I also corrected an error in your program in the SerialOut command where you output the table name not the string as intended.
---------
Public windspeed, winddirection, airtemp, rh, dataout As Boolean, recordtable As String * 1000, recordno, lastrecordno, go As Boolean
DataTable(Station_1A_Meas,True,-1)
Sample (1,windspeed,IEEE4)
Sample (1,winddirection,IEEE4)
Sample (1,airtemp,IEEE4)
Sample (1,rh,IEEE4)
EndTable
BeginProg
SerialOpen (ComME,-9600,3,0,1000)
lastrecordno=0
Scan (500,mSec,1,0)
AcceptDataRecords (5,32769,Station_1A_Meas)
recordno=Station_1A_Meas.record(1,1)
dataout = recordno>lastrecordno
If dataout Then
GetRecord (recordtable,Station_1A_Meas,1)
SerialOut (ComME,recordtable,"",1,0)
lastrecordno=recordno
EndIf
NextScan
'This is just test code to emulate receipt of data from a remote logger
'The go boolena is set manually
SlowSequence
Scan (10,Sec,3,0)
If go Then CallTable station_1a_meas
NextScan
EndProg