public Command(Action runMethod, string text, CommandCode code, params int[] args) { RunMethod = runMethod; Text = text; Code = code; Args = args; }
public RequestHeader(CommandCode commandCode, int payloadSize, int payloadOffset = 0, int payloadLength2 = 0) { CommandCode = commandCode; PayloadSize = payloadSize; PayloadOffset = payloadOffset; PayloadSize2 = payloadLength2; }
public AbstractBlockCommand( IoSession session, CommandCode commandCode, TimeoutNotifyProducerConsumer<AbstractAsyncCommand> producer) :base(session, commandCode, producer) { Callback += BlockCommand_Callback; }
public Command(CommandCode Command_Code, object Data1, object Data2, object Data3, object Data4, object Data5) { this.Command_Code = Command_Code; this.Data1 = Data1; this.Data2 = Data2; this.Data3 = Data3; this.Data4 = Data4; this.Data5 = Data5; }
private static byte[] transfer(CommandCode cmd, byte len) { if (len == 0 || len > 8) { throw new ArgumentException("Bit data len should be from 1 to 8"); } return(new byte[] { (byte)cmd, (byte)(len - 1) }); }
/// <summary> /// Command code 47: Write to continuous registers. /// </summary> /// <param name="slaveStationNo">Slave Station No</param> /// <param name="cmmdCode">Command Code</param> /// <param name="numberOfPoints">Number Of Points.</param> /// <param name="mType">Memory Type</param> /// <param name="startRegister">Start register No(6 or 7 words)</param> /// <param name="dType">Data Type</param> /// <param name="data">Data of registers</param> /// <returns>string</returns> public string GetMessageWriteMultipeRegisters(int slaveStationNo, CommandCode cmmdCode, ushort numberOfPoints, MemoryType mType, ushort startRegister, DataType dType, object[] data) { string values = string.Empty; string frame = string.Format("{0:X2}", slaveStationNo); // Slave station no. frame += string.Format("{0:X2}", (byte)cmmdCode); // Command no. frame += string.Format("{0:X2}", numberOfPoints); // Number Of Points. switch (dType) { case DataType.INT: frame += string.Format("W{0}{1:X4}", mType, Conversion.HEXToWORD(startRegister.ToString())); // Start register No. foreach (short item in data) { values += string.Format("{0:X4}", item); } break; case DataType.WORD: frame += string.Format("W{0}{1:X4}", mType, Conversion.HEXToWORD(startRegister.ToString())); // Start register No. foreach (ushort item in data) { values += string.Format("{0:X4}", item); } break; case DataType.DINT: frame += string.Format("DW{0}{1:X8}", mType, Conversion.HEXToWORD(startRegister.ToString())); // Start register No. foreach (int item in data) { values += string.Format("{0:X8}", item); } break; case DataType.DWORD: frame += string.Format("DW{0}{1:X8}", mType, Conversion.HEXToWORD(startRegister.ToString())); // Start register No. foreach (uint item in data) { values += string.Format("{0:X8}", item); } break; case DataType.REAL: frame += string.Format("DW{0}{1:X8}", mType, Conversion.HEXToWORD(startRegister.ToString())); // Start register No. foreach (float item in data) { values += string.Format("{0:X8}", item); } break; default: throw new InvalidOperationException("Data type is invalid"); } frame += string.Format("{0}", values); // values. frame += CheckSum(frame); return(Convert.ToChar(STX) + frame + Convert.ToChar(EXT)); }
public virtual void OnNetworkMessage(CommandCode messageCode, Stream messageStream) { if (!receivers.ContainsKey(messageCode)) { Debug.LogError($"No receiver registered for {messageCode}"); return; } receivers[messageCode].ReceiveMessage(messageCode, messageStream); }
private static string GetDetailedTarantoolMessage(CommandCode code) { switch ((uint)code) { case 0x8012: return("If index part type is NUM, unsigned int should be used."); } return(null); }
/// <summary> /// Register processor to process command that has the command code of cmdCode. /// </summary> /// <param name="cmdCode"> </param> /// <param name="processor"> </param> public virtual void registerProcessor(CommandCode cmdCode, RemotingProcessor processor) { if (cmd2processors.ContainsKey(cmdCode)) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: cmd2processors.TryGetValue(cmdCode, out var remotingProcessor); logger.LogWarning("Processor for cmd={} is already registered, the processor is {}, and changed to {}", cmdCode, ikvm.extensions.ExtensionMethods.getClass(remotingProcessor).getName(), ikvm.extensions.ExtensionMethods.getClass(processor).getName()); } cmd2processors.AddOrUpdate(cmdCode, processor, (commandCode, remotingProcessor) => processor); }
public void Encode(ProtocolBuffer protocolBuffer, object data) { Command command = (Command)data; Type type = command.GetType(); CommandCode code = this.codeByType[type]; Codec codec = this.protocol.GetCodec(type); this.commandCodeCodec.Encode(protocolBuffer, code); codec.Encode(protocolBuffer, command); }
public QCommand(CommandCode Code, bool Shift, bool Control, bool Alt, QPoint Point, double Data = 0, string String = "") { this.Shift = Shift; this.Control = Control; this.Alt = Alt; this.String = String; this.Data = Data; this.CommandCode = Code; this.Point = Point; }
private static byte[] transfer(CommandCode cmd, uint len) { if (len == 0 || len > 0x10000) { throw new ArgumentException("Data len should be from 1 to 65536"); } len--; return(new byte[] { (byte)cmd, (byte)(len & 0xFF), (byte)(len >> 8) }); }
/// <summary> /// Послать запрос SQL на сервер приложений. /// </summary> /// <param name="typeQuery">TypeQuery: Select или Exec</param> /// <param name="numQuery">Счётчик запросов. Если подключения нет, то устанавливаем автоматически. /// Этот счётчик, чтобы не зациклиться, если соединение не удалось. Так как процедура вызывается рекурсивно.</param> /// <param name="sql">Запрос любой, select, update, delete, ddl</param> /// <param name="ds">System.Data.DataSet</param> /// <returns>Если успешно, то true</returns> private bool AppQuery(TypeQuery typeQuery, int numQuery, string sql, out System.Data.DataSet ds) { ds = null; if ((ConnectionGUID == "") || (ServerAppName == "")) { sys.SM("Ошибка. соединение с сервером приложений не установлено!"); return(false); } CommandCode commandCode = CommandCode.C103; if (typeQuery == TypeQuery.EXEC) { commandCode = CommandCode.C104; } string requestStr = sys.ServerAppSendHTTPMessage("Client", ServerAppName, ServerAppPort, commandCode, ConnectionGUID, sql, "", 0); if (requestStr == "") { return(true); } if (requestStr.Left(3) == ErrorCode.S501.ToString()) //"501. Ошибка. Сессия с сервером не найдена!") { if (numQuery < 2) //Переподключаемся только 1 раз, чтобы не зацикливаться. { if (!(sys.Enter(this.ConnectionName, Var.enterMode, Var.UserLogin, Var.UserPass))) { sys.SM(requestStr + Var.CR + "Ошибка повторного входа в систему!"); return(false); } numQuery = numQuery + 1; //this.ConnectionGUID = NextConnectionGUID; //Здесь важно именно писать Var.con.AppQuery, а не просто AppQuery, //для того, чтобы AppQuery выполнился в другом созданном con, //для того чтобы использовался ConnectionGUID уже другого con. //то что SystemEnter возвращает ConnectionGUID ничего не меняет. //Можно убрать возврат ConnectionGUID из SystemEnter - это ничего не изменит. Var.con.AppQuery(typeQuery, numQuery, sql, out ds); return(true); } sys.SM(requestStr + Var.CR + "Ошибка подключения к серверу приложений!"); return(false); } if (requestStr.Substring(0, 1) == "5") { //Все ошибки начинаются на 5: sys.SM(requestStr); return(false); } ds = sys.StrToDataSet(requestStr); //LastQueryDateTime = DateTime.Now; return(true); }
public string FormSmsCommand(CommandCode commandCode) { string command = ""; int fromN = fromTxt.Text != "" ? Convert.ToInt32(fromTxt.Text) : 0; int beforeN = beforeTxt.Text != "" ? Convert.ToInt32(beforeTxt.Text) : 0; int messageCount = messageCountTxt.Text != "" ? Convert.ToInt32(messageCountTxt.Text) : 0; string phoneNumber = (choosePhoneNumber.SelectedItem as ComboBoxItem).Content.ToString(); switch (commandCode) { case CommandCode.RangeMessage: { if (fromTxt.Text != "" && beforeTxt.Text == "" && messageCountTxt.Text == "") { command = phoneNumber + "1" + ConvertDecimalNumberToHex(fromN, 8) + "01" + "00000000"; messageCountTxt.Text = "1"; beforeTxt.Text = fromTxt.Text; } else { if (fromTxt.Text != "" && beforeTxt.Text != "" && messageCountTxt.Text == "") { messageCount = beforeN - fromN + 1; messageCountTxt.Text = messageCount.ToString(); } else if (fromTxt.Text != "" && beforeTxt.Text == "" && messageCountTxt.Text != "") { beforeN = fromN + messageCount; beforeTxt.Text = beforeN.ToString(); } else if (fromTxt.Text != "" && beforeTxt.Text != "" && messageCountTxt.Text != "") { if (beforeN - fromN + 1 != messageCount) { return("Ошибка! Проверьте правильность введенных данных."); } } else { return("Ошибка! Проверьте правильность введенных данных."); } command = phoneNumber + "2" + ConvertDecimalNumberToHex(fromN, 8) + ConvertDecimalNumberToHex(messageCount, 2) + ConvertDecimalNumberToHex(beforeN, 8); } break; } case CommandCode.LastMessage: command = phoneNumber + "0"; break; } return(command); }
public MyStruct(CommandCode commandCode, string commandData) { this.StartOfText = 0x02; this.DisableChecksum = 0x00; this.ProtocolVersion = 0x35; this.Code = (byte)commandCode; this.Size = (Int16)commandData.Length; this.Data = new byte[commandData.Length]; this.Data = Encoding.ASCII.GetBytes(commandData); this.EndOfText = 0x03; }
/// <summary> /// peek at current bytes of input array for a specific telnet command code. /// </summary> /// <param name="InputArray"></param> /// <param name="CmdCode"></param> /// <returns></returns> public static CommandCode?PeekTelnetCommandCode( this InputByteArray InputArray, CommandCode CmdCode) { var cmdCode = InputArray.PeekTelnetCommandCode(); if ((cmdCode != null) && (cmdCode.Value != CmdCode)) { cmdCode = null; } return(cmdCode); }
/// <summary> /// Get the custom serializer for command code. /// </summary> /// <param name="code"> /// @return </param> public static CustomSerializer getCustomSerializer(CommandCode code) { if (!commandCustomSerializer.IsEmpty) { if (commandCustomSerializer.ContainsKey(code)) { return(commandCustomSerializer[code]); } } return(null); }
public override void ReceiveMessage(CommandCode commandCode, Stream messageStream) { switch (commandCode) { case CommandCode.PlayerStartMove: var command = new PlayerStartMoveCommand(); command.Read(messageStream); command.Execute(this); break; } }
protected AbstractAsyncCommand( IoSession session, CommandCode commandCode, TimeoutNotifyProducerConsumer <AbstractAsyncCommand> producer) { this.session = session; this.CommandCode = commandCode; this.producer = producer; this.ID = Guid.NewGuid().ToByteArray().ToBase64(); this.Version = MessageVersion.V1; }
public static DuplexMessage CreateCommandMessage( string messageId, MessageVersion version, CommandCode commandCode) { return(CreateCommandMessage( messageId, version, commandCode, MessageFilterType.Checksum, MessageFilterFactory.CreateDefaultFilterCode(), SerializeMode.None, null)); }
public void RegisterCommandReceiver(CommandCode code, ICommandReceiver receiver) { var typeName = code; if (receivers.ContainsKey(typeName)) { Debug.LogError($"Attempt to register 2 receivers for {code}, aborting"); return; } receivers[typeName] = receiver; }
/// <summary> /// Get the specific processor with command code of cmdCode if registered, otherwise the default processor is returned. /// </summary> /// <param name="cmdCode"> /// @return </param> //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: public RemotingProcessor<?> getProcessor(CommandCode cmdCode) public virtual RemotingProcessor getProcessor(CommandCode cmdCode) { //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: RemotingProcessor<?> processor = this.cmd2processors.get(cmdCode); var isGetValue = cmd2processors.TryGetValue(cmdCode, out var processor); if (isGetValue) { return(processor); } return(defaultProcessor); }
/// <summary> /// Command code 43: The status reading of ENABLE/DISABLE of continuous discrete. /// </summary> /// <param name="slaveStationNo">Slave Station No</param> /// <param name="numberOfPoints">Number Of Points.</param> /// <param name="mType">Memory Type</param> /// <param name="startNo">Start No</param> /// <param name="dType">Data Type</param> public void ReadEnableOrDisable(int slaveStationNo, CommandCode cmmdCode, ushort numberOfPoints, MemoryType mType, ushort startNo, DataType dType) { try { string frame = this.GetMessageReadDiscretes(slaveStationNo, cmmdCode, numberOfPoints, mType, startNo, dType); objSerialPort.WriteLine(frame); } catch (Exception ex) { throw ex; } }
public virtual void testRegisterProcessor() { ProcessorManager processorManager = new ProcessorManager(); CommandCode cmd1 = RpcCommandCode.RPC_REQUEST; CommandCode cmd2 = RpcCommandCode.RPC_REQUEST; RpcRequestProcessor rpcRequestProcessor1 = new RpcRequestProcessor(); RpcRequestProcessor rpcRequestProcessor2 = new RpcRequestProcessor(); processorManager.registerProcessor(cmd1, rpcRequestProcessor1); processorManager.registerProcessor(cmd2, rpcRequestProcessor2); Assert.Equal(processorManager.getProcessor(cmd1), rpcRequestProcessor2); Assert.Equal(processorManager.getProcessor(cmd2), rpcRequestProcessor2); }
public MyStruct(CommandCode commandCode, string commandData) { this.StartOfText = 0x02; this.DisableChecksum = 0x00; this.ProtocolVersion = 0x35; this.Code = (byte)commandCode; this.Size = (Int16)commandData.Length; this.Data = new byte[ARRAY_SIZE]; byte[] bytes = Encoding.ASCII.GetBytes(commandData); Array.Copy(bytes, Data, bytes.Length); //this.Data = Encoding.ASCII.GetBytes(commandData); this.EndOfText = 0x03; }
public CommandCode GetOptionResponse(TelnetSubject Option) { CommandCode resp = CommandCode.WILL; if (this.OptionDict.ContainsKey(Option) == false) { resp = CommandCode.WONT; } else { resp = this.OptionDict[Option]; } return(resp); }
public object Decode(ProtocolBuffer protocolBuffer) { Type type; CommandCode key = (CommandCode)this.commandCodeCodec.Decode(protocolBuffer); if (!this.typeByCode.TryGetValue(key, out type)) { throw new UnknownCommandException(key); } object instance = ProtocolFlowInstances.GetInstance(type); this.protocol.GetCodec(type).DecodeToInstance(protocolBuffer, instance); return(instance); }
/// <summary> /// Creates a <see cref="Command"/> object with the specified command code and parameter. Additionally creates a <see cref="CommandDataPacket"/> with the specific data. /// </summary> /// <param name="commandCode">The command code.</param> /// <param name="parameter">The parameter.</param> /// <param name="data">A byte array representing the data for a <see cref="CommandDataPacket"/>.</param> /// <returns>A <see cref="Command"/> object containing a <see cref="CommandDataPacket"/>.</returns> /// <exception cref="ArgumentNullException">data.</exception> /// <exception cref="ArgumentOutOfRangeException">data - Current data length does not match expected data length for the command.</exception> internal static Command Create(CommandCode commandCode, int parameter, byte[] data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } if (CommandDataLength.ContainsKey(commandCode) && data.Length != CommandDataLength[commandCode]) { throw new ArgumentOutOfRangeException(nameof(data), "Current data length does not match expected data length for the command."); } return(new Command(commandCode, parameter, data)); }
internal static Response GetResponse(byte[] bytes) { CommandCode code = CommandCode.Unknown; if (bytes.Length > 0) { code = (CommandCode)bytes[0]; } Func <byte[], Response> constructor; return(responseConstructors.TryGetValue(code, out constructor) ? constructor(bytes) : new UnknownResponse(bytes)); }
public static DuplexMessage CreateAckMessage( string messageId, MessageVersion version, string identifier, CommandCode commandCode, ErrorCode errorCode) { return(new DuplexMessage(new MessageHeader( messageId, version, identifier, MessageFilterFactory.CreateDefaultFilterCode(), MessageFilterType.Checksum, MessageState.Fail, errorCode, SerializeMode.None, commandCode, MessageType.CommandAck), null)); }
public IAsyncCommand <DuplexMessage> CreateCommand(CommandCode code) { if (!Connected) { throw new SessionOpenException(endPoint); } using (var scope = ObjectHost.Host.BeginLifetimeScope()) { lock (syncRoot) { return(scope.ResolveOptionalKeyed <AbstractAsyncCommand>(code, new NamedParameter("session", sessionImpl))); } } }
//发送指令 //处理视觉消息 public void ProcessVisualMessage(TcpMeas meassage) { if (meassage != null) { CommandCode Code = (CommandCode)meassage.MeasCode; switch (Code) { case CommandCode.GetVisualState: { } break; default: break; } } }
/// <summary> /// Инициализирует новый экземпляр класса /// </summary> /// <param name="bytes">массив байт заголовка</param> public ResponseHeader(byte[] bytes) { if (bytes.Length >= SctpProtocol.HeaderLength) { commandCode = (CommandCode)bytes[0]; id = BitConverter.ToUInt32(bytes, sizeof(CommandCode)); returnCode = (ReturnCode)bytes[sizeof(CommandCode) + sizeof(uint)]; returnSize = BitConverter.ToUInt32(bytes, sizeof(CommandCode) + sizeof(uint) + sizeof(ReturnCode)); } else { commandCode = CommandCode.Unknown; id = default(uint); returnCode = default(ReturnCode); returnSize = default(uint); } }
public MessageHeader( string messageID, MessageVersion version, string identifier, byte[] filterCode, MessageFilterType filterType, MessageState state, ErrorCode errorCode, SerializeMode serializeMode, CommandCode commandCode, MessageType messageType) { this.MessageID = messageID; this.Version = version; this.State = state; this.FilterCode = filterCode; this.FilterType = filterType; this.ErrorCode = errorCode; this.SerializeMode = serializeMode; this.CommandCode = commandCode; this.Identifier = identifier; this.MessageType = messageType; }
private Request(CommandCode commandCode, Payload payload = null) { CommandCode = commandCode; Payload = payload; }
private static string GetCommandCodeName(CommandCode code) { Enum c = code; return c.ToString(); }
public void DynamicHostMode(CommandCode game_type, byte game_time_minutes, byte tags, byte reloads, byte sheilds, byte mega, bool team_tag, bool medic_mode, byte number_of_teams) { game_state.game_type = game_type; BaseGameSet(game_time_minutes, tags, reloads, sheilds, mega, team_tag, medic_mode); game_state.number_of_teams = number_of_teams; }
ConsoleCommandStruct(CommandCode command, string commandData) { this.commandCode = command; this.commandData = commandData; }
public static ICommand GetCommand(Action run, string text, CommandCode code, params int[] args) { return new Command(run, text, code, args); }
protected virtual IConfigurationSourceContainer CreateConfiguration( MigrationTool tool, CommandCode commandCode, string[] commandArgs) { var configuration = CreateConfiguration(); CommandLineConfigurationSource commandLineConfigSource; string configFile; if (commandArgs != null && commandArgs.Any()) { commandLineConfigSource = new CommandLineConfigurationSource(commandArgs); commandLineConfigSource.Load(); commandLineConfigSource.TryGet(MigrationTool.Constants.ConfigFileOption, out configFile); } else { commandLineConfigSource = null; configFile = null; } if (commandCode != CommandCode.CommitConfiguration) { if (!string.IsNullOrEmpty(configFile)) { configuration.AddIniFile(tool.ResolvePath(configFile)); } else { configFile = tool.ResolvePath(MigrationTool.Constants.DefaultConfigFile); if (File.Exists(configFile)) { configuration.AddIniFile(configFile); } } } if (commandLineConfigSource != null) { configuration.Add(commandLineConfigSource); } return configuration; }
protected ReadUniqueIdentifierCommand(CommandCode commandCode, PacketAddressInfo addrInfo) : base(commandCode, addrInfo) { UniqueID = new DeviceUniqueIDInfo(); }
protected BusMasterCommandBase(CommandCode commandCode, PacketAddressInfo addrInfo) : this(new Packet((byte)commandCode, addrInfo)) { }
public Packet(CommandCode commandCode, PacketAddressInfo addrInfo) : this((byte) commandCode, addrInfo) { }
public virtual void CommandCodeReceived(int id, CommandCode code) { }
public SingleByteMsledCommandWithModifier(CommandCode command, Modifier modifier, byte value) : base((byte)command, (byte)modifier, value) { }
public SingleByteMsledCommand(CommandCode command, byte value) : base((byte)command, value) { }
private void OnCommandCodeEvent(object o, CommandCode code) { // TODO: do some verification. there might be some error messages IAsyncCommandResponseListener listener = slots[currentCommand] as IAsyncCommandResponseListener; if (listener != null) listener. CommandCodeReceived (currentCommand, code); }
public static RequestHeader CreateRequestHeader(CommandCode commandCode, int payloadSize, int payloadOffset = 0, int payloadSize2 = 0) { return new RequestHeader(commandCode, payloadSize, payloadOffset, payloadSize2); }