Handling write commands with DNP Slave driver.

The DNP Slave driver supports receiving the SELECT, OPERATE, or DIRECT OPERATE commands for the following objects:

Object 12 – Variation 1
Object 41 – Variations  1, 2, 3 or 4

To have these commands handled by the application, the Command Response Profile option must be set up as Wait for Application Response. The complete sequence for handling the command is:

1. The SELECT, OPERATE, or DIRECT OPERATE command is received by the slave driver.

2. A tag or block set up as N2 = 3, 4 or 5 must be read and handled by the application (for example, passed to another driver, which will re-send it to the device).

3. When receiving this command’s response to the device, write back in the same tag whose command’s status was read. If the command’s answer to the device was positive, write the same value back; otherwise, write a different value.

4. If nothing was written in the tag within a 10-second interval, the driver will send a response whose status=6 (Request Not Accepted. Hardware Problems.)

To receive a command request, you can use either an Individual Tag or a Block Tag.

Object 12 Variation 1:

Individual Tag: N1 = not important; N2 = 3, 4 or 5; N3 = 1201; N4 = Point Index. When read, the Tag value will contain the value in CONTROL CODE field. To use SELECT and OPERATE, create two tags; each will be read when the corresponding operation (SELECT or OPERATE) happens. To use DIRECT OPERATE (5), you will only need a single tag.

Block Tag: Has the same settings above, but the block can contain up to six elements. The difference is that the procedures are the same regardless of the operation (SELECT, OPERATE, DIRECT OPERATE), and you will only need a single block, because the operation returns in Element 5:

Object 41 Variations 1, 2, 3 or 4:

Individual Tag: N1 = not important; N2 = 3, 4 or 5; N3 = 4101, 4102, 4103 oe 4104; N4 = Point Index. When read, the Tag value will contain the value in CONTROL CODE field. To use SELECT and OPERATE, create two tags; each will be read when the corresponding operation (SELECT or OPERATE) happens. To use DIRECT OPERATE (5), you will only need a single tag.

Block Tag: Has the same settings above, but the block can contain up to three elements:
Element 0: VALUE
Element 1: STATUS
Element 2: OPERATION

Example of script for handling commands reception (object 12 Variation 1):

// The OpenClose block comprises 5 elements.
// The Example assumes sending the received command to another DNP Master driver

Sub OpenClose_OnRead()

  Set Digital = Parent.Parent.Item("DigitalRead")

  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/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 value 0 - Successful write
           'Status expected by the Master in case of error: 
           'select case WStatus
           'case 1
                      'Endtext = "Operate received after Selection Timeout"
           'case 2
                      'Endtext = "No previous Selection Message"
           'case 3 
                      'Endtext = "Format error in the command"
           'case 4 
                      'Endtext = "Operation not supported for this point"
           'case 5
                      'Endtext = "Queue is full or point is already active"
           'case 6
                      'Endtext = "Hardware issues"
           'case else 
                      'Endtext = "Undefined problem"
          'end select
       Else
               WStatus = 7
       End If
End If
Item("Status").Value = WStatus
Write(EWriteSyncMode)
End Sub

Demo application developed with Elipse E3 v4.5.245.

Attachments:

CROB_US.zip

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *