MOSCAD
MOSCAD
v5.4x
MOSCAD_user.DOC 23/10/2002 2
Driver Design Specification
1.1 Contents
3 USER INTERFACE 10
3.1 Introduction 10
3.2 Driver Name 10
3.3 Boards Form 10
3.4 Ports Form 10
3.5 IO Devices Form 10
3.5.1 Address : # NameOfDevice 11
3.5.1.1 The critical RTU must be the first device in the IO Devices form 11
3.6 Pulldown lists Help 11
3.7 IO Device Variable Types 12
3.7.1 Formats and types 12
3.7.2 Event data types (alarm and trend) 13
3.7.3 Cicode functions to access timestamped event data 15
3.7.4 MOSCAD.dbf Entries 16
3.8 PROTDIR.DBF 16
MOSCAD_user.DOC 23/10/2002 3
Driver Design Specification
MOSCAD_user.DOC 23/10/2002 4
Driver Design Specification
2.1 Introduction
This section defines the types of I/O Devices that are targeted by this driver.
MOSCAD_user.DOC 23/10/2002 5
Driver Design Specification
Ethernet
RTU
Gateway Gateway
RS 485
Communications set up is a function of windows. The network card must be installed with
support for TCP/IP loaded and the local IP address selected.
The Gateway toolbox is used to modify the following four groups of parameters.
• TCP/IP Driver (IP address)
• MDLC Gateway configuration (MDLC Gateway, Site-id and Link-ids)
• MDLC Network configuration (system wide MDLC routers)
MOSCAD_user.DOC 23/10/2002 6
Driver Design Specification
• If 1 Gateway is being used, the user should set the Gateway startup mode as “standalone”.
• For Gateway redundancy, the user should setup 1 Gateway as “Primary” mode and the second
Gateway as “Standby” mode. This can be set using the Gateway ToolBox program.
• For “Primary” gateway operation, the user should set the gateway startup mode as “GW1”. For
“Standby” gateway operation, the user should set the gateway startup mode as “GW2”.
The Gateway toolbox is used to modify the following four groups of parameters.
• SiteId (RTU address)
• RTU Site configuration (I/O cards, ports, etc)
• RTU Database configuration (RTU tables of data)
• RTU User Application configuration (RTU ladder logic)
The RTU Database configuration is used to hold either real I/O or user variables.
The RTU User Application configuration (ladder logic) is used to process variable and I/O data for
monitoring and control purposes.
The amount of User Application configuration required is dependant on the communication strategy
that is to be implemented. Sample RTU configuration is also included with (and is required for) the
sample Citect project for this driver.
MOSCAD_user.DOC 23/10/2002 7
Driver Design Specification
configuration file as TS1 for the column copied from “TmMost”, and TS2 for the column copied from
“TmLeas”.
Note, if a Digital Input is being used in a Time Stamped Digital Input table, then it should not be
duplicated in a standard Digital Input table. This may result in a value being shown in a timestamped
digital alarm and a different (older) value still being shown in the Digital Input tag, as the Digital Input
tag will not be updated with the Time Stamped Digital Input data.
TmMost TmLeas
Day Month Year Hour Minute Second Millisecond
1 Byte 1 Byte 1 Byte 1 Byte 1 Byte 1 Byte 2 Bytes
1-31 1-12 0-99 0-23 0-59 0-59 0-999
MOSCAD_user.DOC 23/10/2002 8
Driver Design Specification
advantage of the second case is that the timestamps for the hardware based Time Stamped Digital
Inputs will have the identical functionality of the application based timestamped data, ie the timestamp
relates to the time at which the data was acquired. In this way, a tag read to the timestamp of this
data will display the last point in time at which this data was acquired, either through unsolicited
response or polling. This mechanism will also ensure that a timestamp value is obtained for a
timestamp tag read, even if an event has not yet occurred since Citect startup.
If TimeStamp tags (that is reading the TimeStamp value) will not be used in the project for these
points, then application timestamping of these hardware timestamped points is not required.
2048 bits
MOSCAD_user.DOC 23/10/2002 9
Driver Design Specification
3 User Interface
3.1 Introduction
This section defines how the user will see the driver. This relates directly to how the Citect
forms need to be filled out and any special INI options. For the kernel, the debug trace
messages and the Stats.Special counters are documented.
Example: –I280.9.21.60
There may or may not be a hot backup gateway. If there is a hot backup defined then the user must follow
the instructions detailed in section 2.5.3.2 Gateway Mode of Operation Configuration
MOSCAD_user.DOC 23/10/2002 10
Driver Design Specification
Name This field is user defined, and is not used by the driver.
Number Must be unique, but is not used by the driver.
Address # NameOfDevice
Protocol MOSCAD
Port name Refers to the port previously defined in ‘ports’ form.
Comment This field is user defined and is not used by the driver.
where:
# is the RTU address between 1 and 32768
NameOfDevice is an optional field that associates this unit with the parameters defined in the Citect
INI file defined by the section ‘[NameOfDevice]’.
If this optional field is not utilised, then this unit will just use the values defined by the global INI
parameters defined by the [MOSCAD] section.
Note that for units that require identical configuration of INI parameters, they can all reference the
same NameOfDevice, and hence be associated with the same INI section.
3.5.1.1 The critical RTU must be the first device in the IO Devices form
MOSCAD_user.DOC 23/10/2002 11
Driver Design Specification
MOSCAD_user.DOC 23/10/2002 12
Driver Design Specification
b = TestData
c = TestRow
Argument = TargetData
If TestRow of Table 0 of an RTU holds the value
TestData, then TargetRow of Table 0 of that
RTU will be loaded with TargetData
(Note that this format is only applicable for
‘virtual units’ – memory or disk PLCs. Refer to
note below on virtual units)
Cache Age CAGEz.y.x REAL Cache Age
Tag Status STATUSx.y.x REAL Tag Status
Where:
TIMESTAMP in Seconds Since 01/01/70 (In Universal Coordinate time) – provides Date and Time
MILLISECONDS Since Midnight – provides Millisecond Accuracy for digital alarms
VALUE
VALUE TYPE (2=Bit, 4=Analog or 5=Float)
TAG NAME
MOSCAD_user.DOC 23/10/2002 13
Driver Design Specification
The event data received may, or may not, contain timestamps. Either way the value contained in the
event data is used to update the driver’s cache. If the event data is time-stamped, then the driver will
check to see if the event data is required for Time Stamped Alarms or for Trends. If it is, then it will
pass the event data onto the driver’s event que, which will then in turn be interogated by dedicated
Cicode, that will process the event data and update the associated Alarm or Trend.
The project must initiate the dedicated Cicode if event driven alarms or trends are to be used. This is
accomplished by defining a Parameters form (from the System menu) as follows:
To simplify the matching process of determining the trend tag associated with an incoming time
stamped unsolicited response, the following naming convention is used. For Periodic Trends,
determine the tagname that corresponds to the I/O point from which the event originated, and suffix
the tagname with “T_”. For instance, if B1.0.0 generates an event, and has a tag
PUMP_20_RUNNING defined for it, then the corresponding trend tag should be named
T_PUMP_20_RUNNING. By using the tag PUMP_20_RUNNING as the trend tags expression, the
trend will continue to trend the value held in cache in between events. Note that the event will be
inserted into the trend at the time in which the event occurred, not the time at which the event was
received. The dedicated Cicode will then redraw the trend (with the new value) from the time of the
event up until the present time. Similarly, for a Periodic Event trend, the trend tagname should be
suffixed with “P_”. For example, P_PUMP_20_RUNNING.
In the future, Event trends will be supported by the “E_” suffix, as in E_PUMP_20_RUNNING.
Trends for analog received events are not currently supported, but will be implemented in the same
manner as that described for digital received events, once they are supported.
Only use standard templates when constructing trend displays to be used by event driven trends. If a
“zoomtrend” is to be used, then set the [DNP] parameter ZoomTrendInUse=1.
It is still possible to use normal Citect trends. By using a trend name that does not follow the above
naming convention(eg simply using the tagname as the trend tagname), then the trend will be of the
value held in driver cache and will be relative to Citect time. This implies that changes in value will
relate to the time at which the data was received, rather than when the event occurred.
Note that the trending system does not support the importing of data in millisecond resolution, hence
the main use of trending time stamped data is in a system where there is unacceptable, or variable,
delay between when the RTU scans its I/O and when Citect receives and timestamps the data. If this
is not an issue, then normal trending can be used, with Citect trending the data held in the driver
cache. Note that the driver cache will be updated in between polls if an unsolicited response is
received.
For each time stamped digital alarm configured in the RTU to be “burst” to Citect, two tags are to be
defined in the following format. Determine the tagname that corresponds to the I/O point from which
the alarm originated, and suffix the tagname with “A_”. For instance, if B1.0.1 generates an event, and
has a tag PUMP_20_TRIPPED defined for it, then the corresponding Time Stamped Alarm tag should
be named A_PUMP_20_TRIPPED. The variable tag for the alarm should be suffixed by “V_”, as in
V_PUMP_20_TRIPPED, and the timer tag should be suffixed by “S_”, as in S_PUMP_20_TRIPPED.
Both the “V_” and “S_” tags should be virtual tags defined for a memory PLC, with the “V_” tag having
a Dn address and of type Digital, and the “S_” tag having a Ln address and of type Long.
Cicode will extract events from the driver’s event queue, and if the data is digital, write the time stamp
to the “S” tag, and then write the value to the ‘V” tag (if they have been configured). This will trigger
the Time Stamped Alarm tag, which will then display with the state and time of occurrence as
timestamped in the RTU.
As the Alarm system polls tags for changes in value, but events are received compressed in time,
then any consecutive events for the same point must be delayed by an interval equal to or greater
than the polling time used by the alarm system. If this is not assured, then there is a risk of alarms
being missed as the events will be fed to the alarm server quicker than it is polling for changes. The
[ALARM] parameter ScanTime allows the user to control the actual trend system polling time. The
driver reads this value, and enforces its own minimum of 1 second, so that it can enforce this delay
between consecutive events of the same point. The “Citect Info” function can be used to determine
the “Maximum time between code execution (cycles)” for Time Stamped Alarms –
CitectInfo(“Stats”,”High Res. Al”,1). The ScanTime parameter must be adjusted so as to ensure that
the actual alarm scan time does not exceed the expected alarm scan time.
MOSCAD_user.DOC 23/10/2002 14
Driver Design Specification
Note also that the timestamp can be viewed in one of two forms, Date/Time or Time/Millisecond. The
form to be used is defined by the [ALARM] parameter HresType. Setting HresType=4 defines
Date/Time format, and setting HresType=7 defines Time/Millisecond format. A format must be
selected in order for device timestamped alarms to work, so an error will be generated if it is not
defined in the CITECT.INI file. The [ALARM] parameter HighResOff should be set to 1
(HighResOff=1) to force millisecond accuracy when alarms are turned off, if Time/Millisecond format
is being used. An appropriate alarm category must also be defined to correctly utilise the selected
format.
Refer to the sample project for examples of event driven Trend tags and event driven Time
Stamped Alarm tags.
GetRTULogStatus()
Purpose: To indicate whether there are records available for extraction from
the internal driver event cache.
Return Value: A value representing the number of records remaining in the driver
cache (LONG).
Parameters: NONE
GetRTUNextEvent()
Purpose: To remove the event record from the front of the internal driver event
cache, and make it available for field data extraction using
GetRTUEventField.
Return Value: A handle to the first event OR -1 if no events in internal queue
(LONG)
Parameters: NONE
GetRTUEventField(hEvent, fieldNumber)
Purpose: To obain a field from the current extracted event record.
Return Value: Selected event record field as a string (STRING)
Parameters: hEvent - event handle (LONG) Range 1-65,535
fieldNumber - field number (LONG) Range 1-5
EmptyEventQue()
Purpose: To empty the internal driver event queue.
Return Value: Always returns 0.
MOSCAD_user.DOC 23/10/2002 15
Driver Design Specification
The driver has access to information of the makeup the columns and rows from the API, and so can
optimise the requests from Citect.
Note that since the driver will block along columns rather than rows (i.e. against the natural order the
API uses), the writing of multiple data items e.g. strings will result in one Citect write request being
split into multiple API requests to write individual data items.
3.8 PROTDIR.DBF
MaxBits calculated as
Max size of Moscad receive buffer = 20480 * 8 = 163840 bits
MOSCAD_user.DOC 23/10/2002 16
Driver Design Specification
*1
- Supports Digital, Integer, Long, Real, Byte and blocking on 8 bit boundaries.
MOSCAD_user.DOC 23/10/2002 17
Driver Design Specification
MOSCAD_user.DOC 23/10/2002 18
Driver Design Specification
3.10
To work properly, the MOSCAD driver need information about the MOSCAD system and
about the RTU types (communication table format). This information must be provided via
an ASCII files, called configuration file. The configuration files (“<mdlc_par>.cfg”, where
mdlc_par is your file name) can be any name and anywhere in your local driver provided the
path of this file is set up in Citect.ini file properly. To set up the path in Citect INI file, simply
put SetupFile=”Your File Path\\<mdlc_par>.cfg “ under [MOSCAD] section in INI file. Note,
use double back slash as delimiter. Please see the example in 5.10.3 for details.
<mdlc_par>.cfg - This file describes the format of the different existing RTU types (and
future but currently non-existing RTU types) and type of each RTU in the MOSCAD system.
There is a description of the communication tables format for each of the RTU types. The
format defines the number of columns in a table, and the type of each column. A column
can be either “Bit”, “Val”, “Float”, “C_Bit”, “TS1” or “TS2”; with Bit being for digitals, Val for
16 bit integers, Float for reals, C_Bit for eight columns of bits being compressed into one
byte, and TS1 and TS2 used collectively for Time Stamping. Note that a TS1 column must
be immediately followed by a TS2 column.
In this driver, there are two methods of timestamping data: individually or on a “per row”
basis. To individually timestamp a data element, the data column in the table should be
immediately followed by a TS1 and a TS2 column to hold the timestamp for that data
element ( eg Bit TS1 TS2). In order to collectively timestamp an entire row, the first column
should be of type TS1 and the second column should be of type TS2, all subsequent
columns in the row will be timestamped by this value.
Format of line:
<label>:<id>:<parameter 1>;<parameter 2>[<arglist>];...<parameter n>:<text command>
where:
label is a text string without space and not starting with a number. eg Table0, Table_0.
id is a number 0-65536 used to identify the entity.
parameter 1.. n
for tables are:
polled this table will be polled.
MOSCAD_user.DOC 23/10/2002 19
Driver Design Specification
text command
for tables:
this command defines the column type in the table.
<type> <type> <type>
where:
type can be:
“real”
“discrete”
“analog”
for units:
this command defines the path and file name of the persistent cache of the unit
Note in standard unix form the line can traverse several line in the file by making the last
charactor of the line prior to the <CR> a \.
Any charactors to the right of a # to the end of the line is comment.
MOSCAD_user.DOC 23/10/2002 20
Driver Design Specification
3.10.3.1.1 Station=STATIONABC
! The Master station is the one responsible for polling the moscad gateways
!Citect timeout and retry
Timeout=10000
Retry = 2
3.10.3.1.2 Channel=7
! Channel = 7 sets the mode of the channel.
Since it follows the station name definition and preceeds any specific channel.(e.g. STATIONABC) It
is the default channel mode for any following channel definitions, 7 = 4 + 2 + 1
!Other Parameters
! DebugLevel
! MaxTimeouts
! ConnTimeout
! RedundancyTick
! Tick
debugstr=PORT3_BOARD1 all
[STATIONABC0]
!Channels is not capable of fullduplex comms
3.10.3.1.2.1 Multiplexed = 1
! Multiplexed This permits multiple requests on a single channel.
Timeout=30000
NoPollPeriod=2000
3.10.3.1.2.1.1.1.1 SetupFile=”d:\\CTDDK5\\VC6\\Drivers\\moscadip\\moscad1.cfg”
[STATIONABC1]
!Channels is not capable of fullduplex comms
Multiplexed = 0
Timeout=30000
NoPollPeriod=2000
3.10.3.1.2.1.1.1.2 SetupFile=”d:\\CTDDK5\\VC6\\Drivers\\moscadip\\moscad2.cfg”
[STATIONABC2]
!Channels is not capable of fullduplex comms
MOSCAD_user.DOC 23/10/2002 21
Driver Design Specification
Multiplexed = 1
Timeout=3000
NoPollPeriod=7000
!Rtus 2 on link2 configuration
3.10.3.1.2.1.1.1.3 SetupFile=”d:\\CTDDK5\\VC6\\Drivers\\moscadip\\dnp.cfg”
============= End of INI -------------------------------
3.10.3.3 Cache and scheduling sections in the IO Device form apply only to IOServer caching. Not
the drivers.
Please be aware that the MOSCAD driver is a Front End / Back End (FE/BE) driver. Which means
that there is an internal driver cache - separate from the IOServer cache.
Note: The parameters in the .cfg file pertain to the BE of the driver. I.e. the driver has a back end
polling engine which will perform the regular polling tasks and processing of burst data regardless of
data demand from the IOServer.
4. The channel will transmit data in one of the following means. Full (Integrity) Poll, COS Poll and
burst modes. The combination of these will allow the engineer to optimise the
bandwidth/throughput for the channel.
[CitectChannel0]
GatewayMode=1 !treat gateway as “active” mode
[CitectChannel1]
GatewayMode=2 !treat gateway as “inactive” mode
[Refer to section 5.9.2 Driver Specific Parameters for details of the different startup modes]
[Refer to section 2.5.3.2 Gateway Mode of Operation Configuration for details]
MOSCAD_user.DOC 23/10/2002 22
Driver Design Specification
3.12 Remapping
Remapping is not required or supported.
MOSCAD_user.DOC 23/10/2002 23
Driver Design Specification
The following entries should be included in the Citect PROTERR.DBF spec file.
PROTOCOL MASK ERROR MESSAGE REFERENCE ACTION COMMENT
0x1031 ERR_ERROR General Error
MOSCAD
0x1032 ERR_BUSY Busy Error
MOSCAD
0x1033 ERR_READY Ready
MOSCAD
0x1034 ERR_EMPTY Item Is Empty
MOSCAD
0x1035 ERR_FULL Item Is Full
MOSCAD
0x1036 ERR_SIZE Size Problem
MOSCAD
0x1037 ERR_SIGN Sign Problem
MOSCAD
0x1038 ERR_PORT Port Problem
MOSCAD
0x1039 ERR_CODE Code Problem
MOSCAD
0x103A ERR_DATA Data Problem
MOSCAD
0x103B ERR_FAIL Failure Problem
MOSCAD
0x103C ERR_TIME Time Problem
MOSCAD
0x103D ERR_LOCK Lock Problem
MOSCAD
0x103E ERR_NOT_FOUND Not Found
MOSCAD
0x103F ERR_EXIST Exists
MOSCAD
0x1040 ERR_TYPE Illegal Type
MOSCAD
0x1041 ERR_RATE Illegal Rate
MOSCAD
0x1042 ERR_FLASH_ERASE Erasing Flash Failed
MOSCAD
0x1043 ERR_FLASH_PRGRM Prgrm Flash Failed
MOSCAD
0x1044 ERR_MODE Illegal Mode
MOSCAD
0x1045 ERR_FORMAT Illegal Format
MOSCAD
0x1046 ERR_ABORT Abort
MOSCAD
0x1047 ERR_LOOP Non Existing Loop
MOSCAD
0x1081 ERR_COMM Communication Error
MOSCAD
0x1082 ERR_APPLIC Application Error
MOSCAD
0x1083 ERR_SECONDARY Secondary Mode Error
MOSCAD
0x1084 ERR_DUP Duplicate Entries
MOSCAD
0x1085 ERR_NAME Illegal Name.
MOSCAD
0x1086 ERR_VERSION Invalid File Version.
MOSCAD
0x1087 ERR_MEM Failed To Allocate Memory.
MOSCAD
0x1088 ERR_FILE Problem Accessing The Deffinition Files.
MOSCAD
0x1089 ERR_PARSE Error In The Definition Files.
MOSCAD
0x108A ERR_SITE Non Existing Site ID.
MOSCAD
0x108B ERR_SYSTEM The API Internal Data Structure Is Corrupted
MOSCAD
0x108C ERR_ROW Invaid Row
MOSCAD
0x108D ERR_COLUMN Invalid Column
MOSCAD
0x108E ERR_TABLE Table Number Error - Out Of Range Or Table Is
MOSCAD
Not A Valid Communication Table
0x108F ERR_COORD Data Element Coordinate Error - Site ID Or
MOSCAD
Table Number Unknown.
MOSCAD_user.DOC 23/10/2002 24
Driver Design Specification
MOSCAD_user.DOC 23/10/2002 25
Driver Design Specification
0 TOTAL ROWS IN CACHE Total number of allocated table row structures in the cache
1 NUM ROWS CURRENTLY ACTIVE The number of active rows found while executing the polling
algorithm (value accumulates during the cycle, and is then
overwritten by the next cycle)
2 NUM OUTSTANDING REQUESTS Number of outstanding physical requests to a gateway
3 DATA Rx THREAD WATCHDOG Watchdog counter used to indicate whether the incoming
data reception thread is operational
4 CACHE UPDATE THREAD W.DOG Watchdog counter used to indicate whether the cache
freshness check thread is operational
5 CHAN. INIT THREAD ACTIVE Flag to indicate whether the channel initialisation thread and
socket creation function is running (should only be true
when a channel is being initialised)
6 CHAN. INIT CNTR Counter to indicate how many times the channel initialisation
function has been called
7 INIT STATE (1-16) Counter to indicate which of the 16 states (stages) the
initialisation function is operating at (should be at 16 during
normal operation after initialisation).
8 DATA BUFFER ACQUIRED CNTR Counter to indicate how many times buffer transfer has been
undertaken between the gateway and the driver.
9 UNSOLICITED RESPONSES RxD Counter which increments whenever an unsolicted response
is received
10 TOTAL UNIT POLLS Counter which increments on every poll to a unit
12 DRIVER EVENT QUE LENGTH This value applies to entire driver, not just to this channel.
The number of events held in the driver’s event queue.
13 DRIVER DELAYED EVENT QUE This value applies to entire driver, not just to this channel.
The number of events currently being delayed prior to being
placed on the driver’s event queue (for repeating alarms)
14 DRIVER TOTAL EVENTS This value applies to entire driver, not just to this channel.
The total number of events the driver has processed.
MOSCAD_user.DOC 23/10/2002 26
Driver Design Specification
MOSCAD_user.DOC 23/10/2002 27
Driver Design Specification
Each gateway to be configured for “standalone” mode and each to have unique SiteIds.
Each gateway must have its “health check” flag disabled.
Each RTU has to be configured to detect a broadcast from the driver and to redirect its “burst”
target to the relevant SiteId. This is required as only one gateway is active at a time, and the
RTUs must burst their data back to the correct gateway. This is only a minor amount of RTU
configuration. Refer to “Overview of redundancy using two standalone gateways”.
The Citect project will require cicode that broadcasts instructions to the RTU, causing them to
redirect to a new burst target. This is required for failover. It must also periodically broadcast to
cover the case of an RTU that may have been offline at change over. Tom Sabitzer, of the Lieden
office, has written Cicode that provides this functionality. It has been tested exhaustively during
the FAT, and is part of the solution for the Getronics project. Contact Tom for a copy of this
cicode (royalties may apply!!).
Any cicode commands issuing tag reads or tag writes should check the status virtual tag to
ensure the device is available before actually issuing a command.
It is recommended that the driver be set with 0 retries due to the reasons described in “Issues”.
The “Timeout” parameter must be set large enough to cater for the indeterminate nature of the
gateway (as described in “Issues”). If required use the additional “TimeoutExt” parameter.
The “Watchtime” parameter, for the IO Server holding the primary devices, must be set large
enough so that the regular healthcheck of the critical RTU (when the channel is offline) will not
interfere with the polling operation of the standby. A typical example may be 180 seconds.
If writing application cicode that will issue commands resulting in physical communication to
devices, ensure that the command rate is throttled to prevent swamping the diver with requests.
The polling regime will also have to be tuned to free up enough idle time if this will occur on a
permanent basis. Due to the slow nature of the physical comms, providing too high a vale of
““MaxPending” will run the risk of the driver buffering up so many requests that they can not all be
processed for the IO Server in time. This will result in the IO Server deducing that the driver has
ceased functioning and it will be reset. However, not having a high enough value will result in a
bottleneck as the IO Server will have all of its requests tied up waiting for physical comms, with no
requests spare to read values from cache. This will cause very strange behaviour that is peculiar
to RTU comms (first observed in Perth on the Hunter WaterTech DNP project). The page update
will freeze and the client may actually #COM its values even though the driver and IO Server are
not reporting any errors!!!
MOSCAD_user.DOC 23/10/2002 28