The function is used to control the actions of the controller.
[in]: The handle that is returned when the connection is successful.
[in] Operation contents: 1 for output, 2 for cancel alarm, 3 for restart device, and 4 for enable/disable normal open state.
[in] When the OperationID is output operation: If Param2 is the door output the parameter indicates the door number. If Param2 is auxiliary output, the parameter indicates the number of the auxiliary output interface (for details, see Attached table 3). If Param2 is cancel alarm, the parameter value is 0 by default.
[in]: When the OperationID is output operation, this parameter indicates the address type of the output point (1 for door output, 2 for auxiliary output), for details, see Attached table 3. When the OperationID is cancel alarm,, the parameter value is 0 by default. When the OperationID value is 4, that is enable/disable normal open state, the parameter indicates is enable/disable normal open state (0 for disable, 1 for enable).
[in]: When the OperationID is output operation, the parameter indicates the door-opening time (0 indicates the closed state, 255 indicates the normal open state, the value range is 1 to 60 seconds). The default value is 0.
[in] Reserved; the default value is 0.
[in]: The default value is null; it is used for extension.
When the returned value is 0 or a positive value, it indicates that the operation is successful. When the returned value is a negative value, it indicates that the operation fails. Attached table 5 lists the information about the error codes.
operation_id = 1 door_id = 1 index = 2 state = 6 ret = self.commpro.ControlDevice(self.hcommpro, operation_id, door_id, index, state, 0, ‘’)
int ret = 0; int operid = 1; int doorid = 0; int outputadr = 0; int doorstate = 8; ret = ControlDevice(h, operid, doorid, outputadr, doorstate, 0, "");
[DllImport("plcommpro.dll", EntryPoint = "ControlDevice")] public static extern int ControlDevice(IntPtr h, int operationid, int param1, int param2, int param3, int param4, string options); private void ControlDevice_Pull(int operID = 2, int doorOrAuxoutID = 0, int outputAddrType = 0, int doorAction = 0) { int ret = 0; if (IntPtr.Zero != h) { MessageBox.Show(operID.ToString() + "," + doorOrAuxoutID.ToString() + "," + outputAddrType.ToString() + "," + doorAction.ToString()); //call ControlDevice funtion from PullSDK ret = ControlDevice(h, operID, doorOrAuxoutID, outputAddrType, doorAction, 0, ""); } else { MessageBox.Show("Connect device failed!The error is " + PullLastError() + " ."); return; } if (ret >= 0) { MessageBox.Show("The operation succeed!"); return; } }
<DllImport("plcommpro.dll", EntryPoint:="ControlDevice")> Public Shared Function ControlDevice(h As IntPtr, operationid As Integer, param1 As Integer, param2 As Integer, param3 As Integer, param4 As Integer, options As String) As Integer End Function Private Sub ControlDevice_Pull(Optional operID As Integer = 2, Optional doorOrAuxoutID As Integer = 0, Optional outputAddrType As Integer = 0, Optional doorAction As Integer = 0) Dim ret As Integer = 0 If IntPtr.Zero <> h Then MessageBox.Show(operID.ToString() + "," + doorOrAuxoutID.ToString() + "," + outputAddrType.ToString() + "," + doorAction.ToString()) 'call ControlDevice funtion from PullSDK ret = ControlDevice(h, operID, doorOrAuxoutID, outputAddrType, doorAction, 0, "") Else MessageBox.Show("Connect device failed!The error is " + PullLastError() + " .") Return End If If ret >= 0 Then MessageBox.Show("The operation succeed!") Return End If End Sub