/// <summary> /// Sends the telecontrol command. /// </summary> public void SendCommand(TeleCommand command, WriteFlags writeFlags, out CommandResult commandResult) { if (command.CnlNum > 0) { // validate and send command coreLogic.SendCommand(command, writeFlags, out commandResult); } else { // process acknowledgment command that can only be sent by module if (command.CmdCode == ServerCmdCode.AckEvent) { coreLogic.AckEvent(new EventAck { EventID = BitConverter.DoubleToInt64Bits(command.CmdVal), Timestamp = command.CreationTime, UserID = command.UserID }, false, false); } // set command ID and creation time if (command.CommandID <= 0) { DateTime utcNow = DateTime.UtcNow; command.CommandID = ScadaUtils.GenerateUniqueID(utcNow); command.CreationTime = utcNow; } // pass command directly to clients listener.EnqueueCommand(command); commandResult = new CommandResult(true); } }
/// <summary> /// Acknowledges the event. /// </summary> protected void AckEvent(ConnectedClient client, DataPacket request, out ResponsePacket response) { byte[] buffer = request.Buffer; int index = ArgumentIndex; long eventID = GetInt64(buffer, ref index); DateTime timestamp = GetTime(buffer, ref index); int userID = GetInt32(buffer, ref index); coreLogic.AckEvent(eventID, timestamp, userID); response = new ResponsePacket(request, client.OutBuf); }
/// <summary> /// Acknowledges the event. /// </summary> private void AckEvent(ConnectedClient client, DataPacket request, out ResponsePacket response) { byte[] buffer = request.Buffer; int index = ArgumentIndex; EventAck eventAck = new EventAck { EventID = GetInt64(buffer, ref index), Timestamp = GetTime(buffer, ref index), UserID = GetInt32(buffer, ref index) }; if (eventAck.UserID <= 0) { eventAck.UserID = client.UserID; } coreLogic.AckEvent(eventAck); response = new ResponsePacket(request, client.OutBuf); }