/// <summary> /// Sends the telecontrol command. /// </summary> private void SendCommand(ConnectedClient client, DataPacket request, out ResponsePacket response) { byte[] buffer = request.Buffer; int index = ArgumentIndex; TeleCommand command = new TeleCommand { ClientName = client.Username, UserID = GetInt32(buffer, ref index), CnlNum = GetInt32(buffer, ref index), CmdVal = GetDouble(buffer, ref index), CmdData = GetByteArray(buffer, ref index) }; if (command.UserID <= 0) { command.UserID = client.UserID; } WriteFlags writeFlags = (WriteFlags)buffer[index]; coreLogic.SendCommand(command, writeFlags, out CommandResult commandResult); buffer = client.OutBuf; response = new ResponsePacket(request, buffer); index = ArgumentIndex; CopyInt64(command.CommandID, buffer, ref index); CopyBool(commandResult.IsSuccessful, buffer, ref index); CopyBool(commandResult.TransmitToClients, buffer, ref index); CopyString(commandResult.ErrorMessage, buffer, ref index); response.BufferLength = index; }
/// <summary> /// Sends the telecontrol command. /// </summary> protected void SendCommand(ConnectedClient client, DataPacket request, out ResponsePacket response) { byte[] buffer = request.Buffer; int index = ArgumentIndex; TeleCommand command = new TeleCommand { UserID = GetInt32(buffer, ref index), OutCnlNum = GetInt32(buffer, ref index), CmdVal = GetDouble(buffer, ref index), CmdData = GetByteArray(buffer, ref index) }; if (command.UserID <= 0) { command.UserID = client.UserID; } coreLogic.SendCommand(command, out CommandResult commandResult); buffer = client.OutBuf; response = new ResponsePacket(request, buffer); index = ArgumentIndex; CopyInt64(command.CommandID, buffer, ref index); CopyBool(commandResult.IsSuccessful, buffer, ref index); CopyString(commandResult.ErrorMessage, buffer, ref index); response.BufferLength = index; }
/// <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> /// Sends the telecontrol command. /// </summary> public void SendCommand(TeleCommand command, out CommandResult commandResult) { if (command.OutCnlNum > 0) { // validate and send command coreLogic.SendCommand(command, out commandResult); } else { // pass command directly to clients listener.EnqueueCommand(command); commandResult = new CommandResult(true); } }