|
<< Click to Display Table of Contents >>
Handling Commands |
This Driver supports receiving Select, Operate, or Direct Operate commands for Objects 12 Variation 1 (one) and 41 Variations 1 (one), 2 (two), 3 (three), or 4 (four).
If the Command Response Profile option on the DNP tab is defined with the value Wait for Application Response, the full sequence to handle a command is the following:
1.A Select, Operate, or Direct Operate command is received.
2.A PLC or Block Tag with the N2 parameter equal to 3 (three), 4 (four), or 5 (five) must be read and handled by an application, such as by sending to another Driver that then sends it to a device.
3.When receiving the response for this command to a device, users must write back the status to the same Tag whose command was read. If the response of this command to a device was positive, it must write the same value back. Otherwise, it must write a different value back.
4.If no writing was performed to the Tag during a 10-second interval, this Driver sends a response with a status equal to 6 (six, Request Not Accepted. Hardware Problems).
To receive a command request for these Objects, users can use an individual Tag or a Block Tag.
For an individual Tag, this Tag's value when read contains the value of the Control Code field. To use Select and Operate operations, two Tags must be created and each one receives the reading at the moment the corresponding operation, Select or Operate, occurs. To use a Direct Operate operation (five), only a single Tag is needed with the following parameters:
•N1: Not used
•N2: 3 (three), 4 (four), or 5 (five)
•N3: 1201 or 41XX
•N4: Index of a point
For a Block Tag, the same previous configurations are valid, but this Block Tag can have up to 6 (six) Elements. The difference is that regardless the operation, Select, Operate,or Direct Operate, only a single Block Tag is needed, because the operation returns in Element 5 (five):
•Element 0: Control Code
•Element 1: Count
•Element 2: On Time
•Element 3: Off Time
•Element 4: Status
•Element 5: Operation (3: Select, 4: Operate, or 5: Direct Operate)
•Element 6: Master address
For an individual Tag, this Tag's value when read contains the value of the Control Code field. To use Select and Operate operations, two Tags must be created, and each one receives the reading at the moment the corresponding operation, Select or Operate, occurs. To use a Direct Operate operation (five), only a single operation is needed, with the following parameters:
•N1: Not used
•N2: 5 (five)
•N3: 1201 or 41XX
•N4: Index of a point
For a Block Tag, the same previous configurations are valid, but this Block Tag can have up to 3 (three) Elements:
•Element 0: Value
•Element 1: Status
•Element 2: Operation
Example of a script to handle the reception of commands in an Object 12 Variation 1 (one).
// The OpenClose Block is formed by 5 (five) Elements
// This example assumes sending the received command
// to another DNP Master Driver
Sub OpenClose_OnRead()
Set Digital = Parent.Parent.Item("DigitalReading")
ControlCode = Item("ControlCode").Value
Trip = 1
Close = 0
CmdOk = 1
Select Case ControlCode
Case 65 'Pulse On Close
VCommand = Close
Case 66 'Pulse Off close
VCommand = Close
Case 67 'Latch On Close
VCommand = Close
Case 68 'Latch Off Close
VCommand = Close
Case 129 'Pulse On Trip
VCommand = Trip
Case 130 'Pulse Off Trip
VCommand = Trip
Case 131 'Latch On Trip
VCommand = Trip
Case 132 'Latch Off Trip
VCommand = Trip
Case Else 'Invalid or not formatted command
CmdOk = 0
End Select
If Not(CmdOk) Then
WStatus = 7
Else
If Digital.Item("STATUSDL01").WriteEx(VCommand, , , WStatus) Then
WStatus = 0 'Forces a value (0) or success when writing
Status expected by a Master in case of error:
Select Case WStatus
Case 1
Endtext = " Operate received after selection time-out"
Case 2
Endtext = " No previous selection message"
Case 3
Endtext = " Format error in command"
Case 4
Endtext = " Operation not supported for this point"
Case 5
Endtext = " Queue is full or this point is already active"
Case 6
Endtext = " Hardware problems"
Case Else
Endtext = " Undefined problem"
End Select
Else
WStatus = 7
End If
End If
Item("Status").Value = WStatus
Write(EWriteSyncMode)
End Sub