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.

Getvariables via TCPopen


dandol Jul 19, 2019 02:19 PM

Hi,

i am using a CR3000 with fast ec measurements (50 ms scan) in the main scan and i want to get data from another CR3000 ( with 20 Sec scan). This variable (precipitation) shall be totalized over a 10min period in a data table.

This is the corresponding code (not all) from the CR3000 with fast ec measurements:

PipelineMode

...

...

...

DataTable (flux,TRUE,FLUX_SIZE_CPU)
DataInterval (0,10,Min,10)
CardOut (0,-1)

...

Totalize (1,precip,FP2,False)

...

Endtable

Scan (SCAN_INTERVAL,mSec,SCAN_BUFFER_SIZE,0)

...

CallTable flux

NextScan

SlowSequence
Scan (20,Sec,3,0)
GetVariables (status_get_precip,TCPOpen ("192.168.001.102",6785,0),0,2,0000,0,"Public","P_1_1_1",P_1_1_1,1)
precip = P_1_1_1
CallTable flux
NextScan

EndProg

The problem is after a precipitation event i get only zeros at the variable "precip" (totalized over 10min). The resultcode of the GetVariables parameter (status_get_precip) says ervery time "0". This should mean transmission successfully.

Some questions:

- does the above slowsequence ever work reliably in a program with 50ms main scan?

- is there still a bug I overlook?

- what can I improve so that it reliably stores the precipitation data from the other logger?

Best regards

Daniel


smile Jul 20, 2019 06:00 PM

Hi

Does it compile well? I see the CallTable flux table twice, it would be to verify if this is correct.

However, the slow scan has a lower priority than the main table and therefore will be performed only when there is time.

If the transmission is ok it's good .

I would do something like this :

1) remove the CallTable flux in the slow scan

2) after getvariable instr. in slow scan would do a calculation like tot_precip = tot_precip + precip

3) a sample in the CallTable flux instead of Totalize, for tot_precip variable

4) a reset after CallTable flux instr. , every 10 minutes, for variable tot_precip " if iftime ( 0, 10,min) then tot_precip=0 "


dandol Jul 23, 2019 06:09 AM

thanks for the quick feedback. Yes the logger compiles well. I have added the changes now. I will compare the data again at the next precipitation event.
Some more questions:
Isn't it allowed to run a calltable multiple times? What happens then?
What happens to the last 20-second value? (exactly at 10:00 minutes)? Or is the last value from 09:40 minutes?


smile Jul 24, 2019 07:37 AM

Hi

"Isn't it allowed to run a calltable multiple times? What happens then?"

I don't know I have always avoided doing it, logically it doesn't seem correct but maybe it's the case to try or read the manual well. By logic, perhaps asking the table twice for an average does not change much, but a total could be double!


"What happens to the last 20-second value? (exactly at 10:00 minutes)? Or is the last value from 09:40 minutes?"

If the slowscan is executed late, due to the lower priority, compared to 10:00 where the historical data are generated, it is probable that the missing sum is calculated and elaborated at 10:10.
However if you have a remote connection or the station is not far you can do some tests without waiting for the rain. Sorry if this suggestion is trivial!


dandol Aug 8, 2019 12:55 PM

Hi,

it's not working yet. I now have the following idea:
The logger (20 seconds main scan) with the tipping bucket should calculate the 10 minutes amount of precipitation. After 10 minutes (600 sec) and 5 seconds it should reset the value:

precip_tot_tr32 = precip_tot_tr32 + P_1_1_1_1
If IfTime(5,600,sec) Then precip_tot_tr32=0

The other logger (50ms main scan) should execute the Getvariables command in the main scan every 10 minutes:

If IfTime(0,10,Min)
GetVariables (status_get_precip,TCPOpen("192.168.001.102",6785,0),0,2,0000,0, "Public", "precip_tot_tr32",precip_tot,1)
EndIf

Should that work fine?


dandol Jan 9, 2020 01:53 PM

Hi smile,

this code works now but sometimes i still get a "1" for the resultCode1 (status_get_precip) with the getvariables command which means no response to the request.

i suspect that the a timeout at getvariables is also responible for skippd scans (in 20msec scan intervall)

Can i optimize something in the code or in the configuration that both works fine?

source CR3000 logger:

Scan (1,Sec,0,0)

......

PulseCount (P_1_1_1,1,1,2,0,0.1,0)
precip_tot_tr32 = precip_tot_tr32 + P_1_1_1
If IfTime(0,600,sec) Then precip_tot_tr32=0

.......

CR3000 which get the data:

Scan (SCAN_INTERVAL,mSec,SCAN_BUFFER_SIZE,0)

......

If IfTime(598,600,sec)
GetVariables (status_get_precip,TCPOpen ("192.168.001.102",6785,0),0,2,0000,4,"Public","precip_tot_tr32",precip_tot,1)
CallTable status_precip
EndIf

......

best regards

Daniel


JDavis Jan 9, 2020 09:49 PM

To get rid of the skipped scans, you need to move the TCPOpen and GetVariables to a slow sequence. Then, you can run the slow instructions without interrupting your fast measurements in the main scan.


dandol Jan 10, 2020 07:06 AM

Thanks. But if i move the TCPOpen and Getvariables in a slow sequence how can i make sure that the transmission of the 10-minute-value works also fine? So the transmission should be every 10 minutes more precisely at 598 seconds (If IfTime(598,600,sec)). The variable precip_tot_tr32 is not stored in a data table. 

If i understand this correctly, the slow sequence is executed when the logger has free capacity.
So the If IfTime(598,600,sec) would make no sense in the slow sequence?


JDavis Jan 13, 2020 11:51 PM

You could set the slow sequence to a scan rate of 1 second, and still use that If IfTime(598,600,sec) 

Expect that you would get some skipped scans in the slow sequence while the TCPOpen and GetVariables run. You will skip slow scans that would not have done anything. So, those skipped slow scans can be ignored.


dandol Jan 16, 2020 09:09 AM

I did this now:

SlowSequence
Scan (1,Sec,3,0)
If IfTime(598,600,sec)
GetVariables (status_get_precip,TCPOpen ("192.168.001.102",6785,0,4),0,2,0000,4,"Public","precip_tot_tr32",precip_tot,1)
CallTable status_precip
EndIf
NextScan

i got this:

timestamp Recordnumber precip_value resultcode

2020-01-15 12:39:58 0 0 1
2020-01-15 12:49:58 1 0 2
2020-01-15 12:59:58 2 0 3
2020-01-15 13:09:58 3 0 4
2020-01-15 13:19:58 4 0 5
2020-01-15 13:29:58 5 0 6
2020-01-15 13:39:58 6 0 7
2020-01-15 13:49:58 7 0 8
2020-01-15 13:59:58 8 0 9
2020-01-15 14:09:58 9 0 10
2020-01-15 14:19:58 10 0 11
2020-01-15 14:29:58 11 0 12
2020-01-15 14:39:58 12 0 13
2020-01-15 14:49:58 13 0 14
2020-01-15 14:59:58 14 0 15

Now the data transmission of the precipitation data failed. The resultcode counts up. It should be 0 if transmission was successfull.

What can i do that both works fine? 20Hz EC Scan and precipitation data transmission?

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