Ejemplo De Código Crbasic - RST Instruments RSTAR L900 Manual De Instruccion

Sistema de radio
Tabla de contenido

Publicidad

E
JEMPLO DE CÓDIGO
El siguiente programa asignará datos de sensor y de diagnóstico de 2 adquisidores
DT2011B a la cadena DT11Data(). El intervalo de lectura de la red es de 10 minutos
y el RTU está conectado por cable al Puerto Com C1/C2 sobre un adquisidor de
datos de tipo CR300™.
01
'Declare number of DT2011B loggers in RSTAR network
02
Const
nDT2011B =
2
03
04
'Declare variables
05
Public
DT11Data(nDT2011B * 12)
06
Public
i, timeSendString
07
Public
RTUflag
As String
08
Public
rstarTimeString
09
10
BeginProg
11
Scan(1,Min,0,0)
12
If
TimeIntoInterval(0,10,Min)
the RTU
13
14
SerialOpen(Com1,115200,0,0,100)
15
16
RTUflag =
""
'Reset RTU flag to guard against failed query
17
18
For
i =
1
To
30
19
Delay(0,10,Sec)
20
SerialOut(Com1,"QT"+CHR(13),"",0,10)
21
SerialIn(RTUflag,Com1,50,0,100)
22
SplitStr(parsedRTUflag(1),RTUflag,",",1,0)
23
SerialFlush(Com1)
24
25
If
parsedRTUflag(1) =
transmissions
26
Delay(0,500,mSec)
27
SerialOut(Com1,"DT"+CHR(13),"",0,100)
transmission
28
SerialIn(rstarTimeString,Com1,50,0,100)
29
Delay(0,500,mSec)
30
SerialFlush(Com1)
31
SerialClose(Com1)
32
33
ModbusMaster(modBusResult,Com1,115200,128,4,DT11Data(),1,nDT2011B * 12,3,100)
RTU for collected RSTAR data
34
35
SerialOpen(Com1,115200,0,0,100)
36
SerialFlush(Com1)
37
Delay(0,500,mSec)
38
SerialOut(Com1,"ND
39
SerialFlush(Com1)
40
SerialClose(Com1)
41
ExitFor
42
End If
43
44
Next
i
45
46
Else If
TimeIntoInterval(9,10,Min)
gathering data at the RTU
47
SerialOpen(Com1,115200,0,0,100)
48
RealTime(rstarTime())
49
timeSendString =
rstarTime(4) +
" "
+ rstarTime(5) +
CR300 time into compatible format for RTU
50
SerialOut(Com1,timeSendString,"",0,100)
51
SerialFlush(Com1)
52
SerialClose(Com1)
53
End If
54
NextScan
ELM0078 B
Manual de instrucción del Sistema de radio RSTAR L900
CRB
as string
* 28, rstarTime(9)
* 16, parsedRTUflag(6)
As String
* 32, modBusResult
Then
'Execute when RSTAR network begins gathering data at
'Try every 10 seconds for 5 minutes
1
Then
'Execute if RTU is no longer listening for Node logger
1"+CHR(13),"",0,100)
Then
'Execute 1 minute before RSTAR network begins
'Get current time of CR300 logger
"WT "
+ rstarTime(1) +
" "
+ rstarTime(6) +
RST Instruments Ltd.
ASIC
As String
*
10
'Query for RSTAR Listening State
'Parse response
'Ask RTU for date-time of last RSTAR
'Acknowledge data from RTU
" "
+ rstarTime(2) +
" "
" "
+ rstarTime(7) + CHR(13)
'Send CR300 time to RTU
'Query
+ rstarTime(3) +
" "
+
'Package
Página 27

Publicidad

Tabla de contenido
loading

Tabla de contenido