Campbell Scientific NL116 NL116 Ethernet and CompactFlash Module - Page 21

PROGRAM, TCPOpen, PakBus/TCP Client

Page 21 highlights

NL116 Ethernet and CompactFlash® Module PROGRAM ' CR1000 ' IP_Callback.cr1 ' LoggerNet server Pak Bus Address assumed = 4094 ' PC IP address assumed = 192.168.7.231 ' LoggerNet IPPort "IP Port Used for Call-Back" = 6785 ' LoggerNet IPPort "Call-Back Enabled" is checked ' LoggerNet CR1000 "Call-Back Enabled" is checked ' LoggerNet PakBusPort "PakBus Port Always Open" is checked ' IP Call-back using auto-discover (-1) neighbor in SendVariables Public PanelTemperature, BatteryVoltage, Result1, dummy1 Dim Socket as LONG DataTable (CLBK1,1,1000) DataInterval (0,0,Sec,10) Sample (1,PanelTemperature,FP2) Sample (1,BatteryVoltage,FP2) EndTable BeginProg Scan (5,Sec,6,0) PanelTemp (PanelTemperature,250) Battery (BatteryVoltage) If not Route(4094) then Socket = TCPOpen ("192.168.7.231",6785,0) SendVariables (Result1,Socket,-1,4094,0000,100,"Public","Callback",dummy1,1) CallTable CLBK1 NextScan EndProg 7.1.1.2 Datalogger-to-Datalogger Communication Communication between dataloggers is possible over TCP/IP. In order to do this, a socket must be opened between the two dataloggers using the TCPOpen() instruction or using the PakBus/TCP Client setting. Note that only one datalogger should be set up to open the connection. The socket opened by the TCPOpen() instruction or the PakBus/TCP Client setting is used by the instructions performing datalogger-to-datalogger communication. The example program below gets the battery voltage from a remote datalogger and sends its panel temperature to the remote datalogger. The remote datalogger is at IP address 192.168.7.125 and port 6785 is used for communication between the dataloggers. The remote datalogger must have its battery voltage stored in a public variable, BattVolt. It must also have a public variable declared, PTemp_Base. This will be used to store the panel temperature of the base datalogger. 13

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44

NL116 Ethernet and CompactFlash
®
Module
PROGRAM
' CR1000
' IP_Callback.cr1
' LoggerNet server Pak Bus Address
assumed = 4094
' PC IP address assumed = 192.168.7.231
' LoggerNet IPPort "IP Port Used for Call-Back" = 6785
' LoggerNet IPPort "Call-Back Enabled" is checked
' LoggerNet CR1000 "Call-Back Enabled" is checked
' LoggerNet PakBusPort "PakBus Port Always Open" is checked
' IP Call-back using auto-discover (-1) neighbor in SendVariables
Public PanelTemperature, BatteryVoltage, Result1, dummy1
Dim Socket as LONG
DataTable (CLBK1,1,1000)
DataInterval (0,0,Sec,10)
Sample (1,PanelTemperature,FP2)
Sample (1,BatteryVoltage,FP2)
EndTable
BeginProg
Scan (5,Sec,6,0)
PanelTemp (PanelTemperature,250)
Battery (BatteryVoltage)
If not Route(4094) then Socket = TCPOpen ("192.168.7.231",6785,0)
SendVariables (Result1,Socket,-1,4094,0000,100,"Public","Callback",dummy1,1)
CallTable CLBK1
NextScan
EndProg
7.1.1.2 Datalogger-to-Datalogger Communication
Communication between dataloggers is possible over TCP/IP.
In order to do
this, a socket must be opened between the two dataloggers using the
TCPOpen()
instruction or using the
PakBus/TCP Client
setting. Note that
only one datalogger should be set up to open the connection.
The socket
opened by the
TCPOpen()
instruction or the
PakBus/TCP Client
setting is
used by the instructions performing datalogger-to-datalogger communication.
The example program below gets the battery voltage from a remote datalogger
and sends its panel temperature to the remote datalogger.
The remote
datalogger is at IP address 192.168.7.125 and port 6785 is used for
communication between the dataloggers.
The remote datalogger must have its
battery voltage stored in a public variable,
BattVolt
.
It must also have a public
variable declared,
PTemp_Base
.
This will be used to store the panel
temperature of the base datalogger.
13