Esempio n. 1
0
        private void ExecuteCommands(char[] commandsArray)
        {
            for (int i = 0; i < commandsArray.Length; i++)
            {
                if (!char.IsWhiteSpace(commandsArray[i]))
                {
                    CommandEnum command = commandsArray[i].GetEnumFromCharValue <CommandEnum>();

                    switch (command)
                    {
                    case CommandEnum.SpinLeft:
                        SpinLeft();
                        break;

                    case CommandEnum.SpinRight:
                        SpinRight();
                        break;

                    case CommandEnum.MoveForward:
                        MoveForward();
                        break;

                    default:
                        throw new ArgumentException();
                    }
                }
            }
        }
Esempio n. 2
0
        private unsafe ushort _createAndSendControlPayload(
            CommandEnum command,
            ReadOnlySpan <ushort> arguments = new ReadOnlySpan <ushort>()
            )
        {
            Debug.Assert(Connected);

            var id = _nextId++;

            // the extra is for an id
            var payloadSize = sizeof(CommandEnum) / 2 + arguments.Length + 1;
            var payload     = stackalloc ushort[payloadSize];

            payload[0] = (ushort)command;
            payload[1] = id;

            for (var i = 0; i < arguments.Length; i++)
            {
                payload[i + 2] = arguments[i];
            }

            var payloadSpan = new ReadOnlySpan <byte>(payload, payloadSize * 2);

            _control.Send(payloadSpan);

            return(id);
        }
Esempio n. 3
0
 protected void FireOnNewStateRequested(CommandEnum command)
 {
     if (OnNewStateRequested != null)
     {
         OnNewStateRequested(command);
     }
 }
Esempio n. 4
0
        public string getWay(CommandEnum commandEnum, string[] args, bool isHash)
        {
            string outputstring = "";

            switch ((int)commandEnum)
            {
            case 1:
            {
                AsistMail mService = new AsistMail();
                outputstring = mService.execute(args, isHash);
            };
                break;

            case 2:
            { GetMail mail = new GetMail();
              outputstring = mail.execute(args, isHash); };
                break;

            case 3:
            {
                SearchMail searchMail = new SearchMail();
                outputstring = searchMail.execute(args, isHash);
            };
                break;;

            case 4:
            {
                SearchMail searchMail = new SearchMail();
                outputstring = searchMail.execute(args, isHash);
            };
                break;
            }
            return(outputstring);
        }
Esempio n. 5
0
        public bool TryToSendNewOffsets(out CommandEnum command)
        {
            Dashboard.Sgt.LogAsync($"I will send new offsets to the server.");
            try
            {
                var rand = new Random((int)DateTime.Now.Millisecond);

                _fakeCoffeMachine.Signals.CoffeeMin = (float)rand.NextDouble();
                _fakeCoffeMachine.Signals.CoffeeMax = (float)rand.NextDouble() + 4;
                _fakeCoffeMachine.Signals.SugarMin  = (float)rand.NextDouble();
                _fakeCoffeMachine.Signals.SugarMax  = (float)rand.NextDouble() + 4;
                _fakeCoffeMachine.Signals.WaterMin  = (float)rand.NextDouble();
                _fakeCoffeMachine.Signals.WaterMax  = (float)rand.NextDouble() + 4;

                var request = _ardRequestFac.Offsets();
                RegistrationResponse response;
                var ack = Send(request, out response, _serverApiUrl + REGISTRATION_ROUTE);
                command = ack ? response.c : CommandEnum.Undef;
                if (ack)
                {
                    Dashboard.Sgt.LogAsync($"Offsets have been reset on the server.");
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                command = CommandEnum.Undef;
                return(false);
            }
        }
Esempio n. 6
0
        /// <summary>Get the data size associated with a command.</summary>
        /// <param name="command">Command</param>
        /// <returns>int</returns>
        public static int GetCommandDataSize(CommandEnum command)
        {
            FieldInfo fi   = typeof(CommandEnum).GetRuntimeField(command.ToString());
            Attribute attr = fi.GetCustomAttribute(typeof(CommandDataSize));

            return(((CommandDataSize)attr).DataSize);
        }
Esempio n. 7
0
 public static void AddCommand(string commandName, CommandEnum @enum, ICommand command)
 {
     mtx.WaitOne();
     stringToCommand.Add(commandName, @enum);
     enumToCommand.Add(@enum, command);
     mtx.ReleaseMutex();
 }
Esempio n. 8
0
        /// <summary>
        /// parsing from CommunicationProtocol to ServiceInfoEventArgs.
        /// </summary>
        public static ServiceInfoEventArgs Parse(CommunicationProtocol e)
        {
            CommandEnum ce = (CommandEnum)e.Command_Id;

            string[] args = e.Command_Args;
            if (args == null)
            {
                return(null);
            }
            ServiceInfoEventArgs siea = new ServiceInfoEventArgs();

            if (ce == CommandEnum.GetConfigCommand)
            {
                ClientServerArgsParser.GetConfigCommand(siea, args);
            }
            else if (ce == CommandEnum.CloseHandlerCommand)
            {
                ClientServerArgsParser.CloseHandlerCommand(siea, args);
            }
            else if (ce == CommandEnum.GetLogCommand)
            {
                ClientServerArgsParser.GetLogCommand(siea, args);
            }
            return(siea);
        }
Esempio n. 9
0
        /// <summary>
        /// Messages from server.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="CommandEventArgs" /> instance containing the event data.</param>
        public void MessageFromServer(object sender, CommandEventArgs args)
        {
            CommandEnum commandID = args.CommandID;

            if (commandID == CommandEnum.GetAllLogsCommand)
            {
                GUIClient client  = (GUIClient)sender;
                string    message = args.CommandArgs[0];
                var       obj     = Newtonsoft.Json.JsonConvert.DeserializeObject <List <MessageRecievedEventArgs> >(message);
                List <MessageRecievedEventArgs> logs = (List <MessageRecievedEventArgs>)obj;
                logs.Reverse();
                foreach (MessageRecievedEventArgs log in (List <MessageRecievedEventArgs>)obj)
                {
                    ReceivedLog?.Invoke(this, log);
                }
                //for (int i = logs.Count - 1; i >= 0; i++) {  ReceivedLog?.Invoke(this, logs[i]); }
            }
            else if (commandID == CommandEnum.LogCommand)
            {
                GUIClient client  = (GUIClient)sender;
                string    message = args.CommandArgs[0];
                var       obj     = Newtonsoft.Json.JsonConvert.DeserializeObject <MessageRecievedEventArgs>(args.CommandArgs[0]);
                //string log = message.Substring(1);
                // string log = message;
                // MessageRecievedEventArgs logInfo = ParseLogFromString(log);
                MessageRecievedEventArgs logInfo = (MessageRecievedEventArgs)obj;
                ReceivedLog?.Invoke(this, logInfo);
            }
        }
Esempio n. 10
0
 public ResultEnum hleUtilsBufferCopyWithRange(byte* Out, int outsize, byte* In, int insize, CommandEnum Command, bool do_check = true)
 {
     switch (Command)
     {
         case CommandEnum.PSP_KIRK_CMD_DECRYPT_PRIVATE: return (ResultEnum)kirk_CMD1(Out, In, insize, do_check);
         case CommandEnum.PSP_KIRK_CMD_ENCRYPT: return (ResultEnum)kirk_CMD4(Out, In, insize);
         case CommandEnum.PSP_KIRK_CMD_ENCRYPT_FUSE:
             throw(new NotImplementedException());
             //return kirk_CMD5(Out, In, insize);
         case CommandEnum.PSP_KIRK_CMD_DECRYPT: return (ResultEnum)kirk_CMD7(Out, In, insize);
         case CommandEnum.PSP_KIRK_CMD_DECRYPT_FUSE:
             throw(new NotImplementedException());
             //return executeKIRKCmd8(Out, In, insize);
         case CommandEnum.PSP_KIRK_CMD_PRIV_SIG_CHECK: return (ResultEnum)kirk_CMD10(In, insize);
         case CommandEnum.PSP_KIRK_CMD_SHA1_HASH: return (ResultEnum)kirk_CMD11(Out, In, insize);
         case CommandEnum.PSP_KIRK_CMD_ECDSA_GEN_KEYS:
             throw(new NotImplementedException());
             //return executeKIRKCmd12(Out, outsize);
         case CommandEnum.PSP_KIRK_CMD_ECDSA_MULTIPLY_POINT:
             throw (new NotImplementedException());
             //return executeKIRKCmd13(Out, outsize, In, insize);
         case CommandEnum.PSP_KIRK_CMD_PRNG: return (ResultEnum)kirk_CMD14(Out, insize);
         case CommandEnum.PSP_KIRK_CMD_ECDSA_SIGN:
             throw(new NotImplementedException());
             //return executeKIRKCmd16(Out, outsize, In, insize);
         case CommandEnum.PSP_KIRK_CMD_ECDSA_VERIFY:
             throw(new NotImplementedException());
             //return executeKIRKCmd17(In, insize);
         default:
             return ResultEnum.PSP_KIRK_INVALID_OPERATION; // Dummy.
     }
 }
Esempio n. 11
0
        public void WriteEnums(List <CommandEnum> enums, List <string> enumValues)
        {
            this.WriteUVarInt((uint)enums.Count);
            for (int i = 0; i < enums.Count; ++i)
            {
                CommandEnum enumData = enums[i];
                int         count    = enumData.Values.Length;
                string      name     = enumData.Name;
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }

                this.WriteString(name);
                this.WriteUVarInt((uint)count);
                for (int j = 0; j < count; ++j)
                {
                    if (enumValues.Count < 0x100)
                    {
                        this.WriteByte((byte)enumValues.IndexOf(enumData.Values[j]));
                    }
                    else if (enumValues.Count < 0x10000)
                    {
                        this.WriteLShort((ushort)enumValues.IndexOf(enumData.Values[j]));
                    }
                    else
                    {
                        this.WriteLInt((uint)enumValues.IndexOf(enumData.Values[j]));
                    }
                }
            }
        }
Esempio n. 12
0
        /**public bool ConnectToServer()
         * {
         *  IPEndPoint ep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8000);
         *  client = new TcpClient();
         *  try
         *  {
         *      client.Connect(ep);
         *      isConnected = true;
         *      Console.WriteLine("You are connected");
         *      return true;
         *  }
         *  catch
         *  {
         *      Console.WriteLine("Unable to connect to server. Please check your connection.");
         *      isConnected = false;
         *      return false;
         *  }
         * }*/

        /// <summary>
        /// Sends the message to server.
        /// </summary>
        /// <param name="commandID">The command identifier.</param>
        /// <param name="args">The arguments.</param>
        public void SendMessageToServer(CommandEnum commandID, string[] args)
        {
            Task.Run(() => clientChannel.SendMessageToServer(new CommandEventArgs()
            {
                CommandID = commandID, CommandArgs = args
            }));
        }
Esempio n. 13
0
        /// <summary>
        /// Ejecuta un comando en la consola de Windows
        /// </summary>
        /// <param name="arguments"></param>
        public void Exec(string arguments, CommandEnum type)
        {
            string output = string.Empty;

            ProcessStartInfo processStartInfo = new ProcessStartInfo();

            switch (type)
            {
            case CommandEnum.Adb:
                processStartInfo.FileName = $@"{NoxPath}";
                break;

            case CommandEnum.Ocr:
                processStartInfo.FileName = $@"{OcrPath}";
                break;

            default:
                break;
            }
            processStartInfo.WorkingDirectory = $@"{Directory.GetCurrentDirectory()}";
            processStartInfo.Arguments        = $@"{arguments}";
            processStartInfo.CreateNoWindow   = true;
            processStartInfo.WindowStyle      = ProcessWindowStyle.Hidden;
            processStartInfo.UseShellExecute  = true;

            process = Process.Start(processStartInfo);
            process.Dispose();
        }
Esempio n. 14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ImageController"/> class.
        /// </summary>
        /// <param name="modal">The modal.</param>
        public ImageController(IImageServiceModal modal, ILoggingService loggingService)
        {
            m_modal = modal;                    // Storing the Modal Of The System
            CommandEnum y = CommandEnum.NewFileCommand;
            CommandEnum g = CommandEnum.GetConfigCommand;
            CommandEnum l = CommandEnum.LogCommand;
            //CommandEnum a = CommandEnum.AddLog;
            CommandEnum c = CommandEnum.CloseCommand;
            CommandEnum d = CommandEnum.DeleteFileCommand;

            //  CommandEnum cc = CommandEnum.CloseClient;
            commands = new Dictionary <int, ICommand>()
            {
                // For Now will contain NEW_FILE_COMMAND
                { (int)y, new NewFileCommand(m_modal) },
                { (int)g, new GetConfigCommand() },
                { (int)l, new LogCommand(loggingService) },
                //{ (int)a, new AddLog(m_modal)},
                { (int)c, new CloseCommand(m_modal) },
                { (int)d, new DeleteFileCommand(m_modal) },

                //  { (int)ch, new CloseHandlerCommand(imageServer)}
                // { (int)cc, new CloseClient()}
            };
        }
Esempio n. 15
0
        public ICommand CreateInstance(string value)
        {
            string[]    words       = value.Split(' ');
            CommandEnum commandEnum = CommandEnum.none;

            Enum.TryParse(words[0], true, out commandEnum);

            switch (commandEnum)
            {
            case CommandEnum.move:
                return(CreateMoveCommandInstance(words));

            case CommandEnum.set:
                return(CreateSetCommandInstance(words));

            case CommandEnum.turnend:
                return(CreateTurnEndCommandInstance(words));

            case CommandEnum.extend:
                return(CreateExtendCommandInstance(words));

            case CommandEnum.undo:
                return(CreateUndoCommandInstance(words));

            case CommandEnum.quit:
                return(CreateQuitCommandInstance(words));

            default:
                return(null);
            }
        }
Esempio n. 16
0
 private CommandDefinition.CommandFormat ReplyCreate(CommandEnum command, BooleanValue isAck, ActionEnum action, byte subAction, byte[] data)
 {
     CommandDefinition.CommandAckStruct /*can't name it command*/ cmd = new CommandDefinition.CommandAckStruct(command, BooleanValue.False, isAck);
     CommandDefinition.ActionStruct /*can't name it action*/ act = new CommandDefinition.ActionStruct(ActionEnum.Response, subAction);
     CommandDefinition.CommandFormat packet = new CommandDefinition.CommandFormat(cmd, act, data);
     return packet;
 }
Esempio n. 17
0
        public string ExecuteCommand(CommandEnum commandID, string[] args, out bool resultSuccesful)
        {
            ICommand value;

            Commands.TryGetValue(commandID, out value);
            return(value.Execute(args, out resultSuccesful));
        }
Esempio n. 18
0
 public RegistrationResponse RegistrationOK(CommandEnum command = CommandEnum.Void)
 => new RegistrationResponse()
 {
     c  = command,
     e  = ErrorEnum.Void,
     rc = ResponseCodeEnum.OK
 };
        public void MessageFromServer(object sender, CommandEventArgs args)
        {
            CommandEnum commandID = args.CommandID;

            if (commandID == CommandEnum.GetAllLogsCommand)
            {
                Client client  = (Client)sender;
                string message = args.CommandArgs[0];
                var    obj     = Newtonsoft.Json.JsonConvert.DeserializeObject <List <MessageRecievedEventArgs> >(message);
                List <MessageRecievedEventArgs> logs = (List <MessageRecievedEventArgs>)obj;
                logs.Reverse();
                foreach (MessageRecievedEventArgs log in (List <MessageRecievedEventArgs>)obj)
                {
                    ReceivedLog?.Invoke(this, log);
                }
            }
            else if (commandID == CommandEnum.LogCommand)
            {
                Client client  = (Client)sender;
                string message = args.CommandArgs[0];
                var    obj     = Newtonsoft.Json.JsonConvert.DeserializeObject <MessageRecievedEventArgs>(args.CommandArgs[0]);

                MessageRecievedEventArgs SpecificLogView = (MessageRecievedEventArgs)obj;
                ReceivedLog?.Invoke(this, SpecificLogView);
            }
        }
Esempio n. 20
0
 private CommandDefinition.CommandFormat ReplyCreate(CommandEnum command, BooleanValue isAck, ActionEnum action, byte subAction, byte[] data)
 {
     CommandDefinition.CommandAckStruct /*can't name it command*/ cmd = new CommandDefinition.CommandAckStruct(command, BooleanValue.False, isAck);
     CommandDefinition.ActionStruct /*can't name it action*/      act = new CommandDefinition.ActionStruct(ActionEnum.Response, subAction);
     CommandDefinition.CommandFormat packet = new CommandDefinition.CommandFormat(cmd, act, data);
     return(packet);
 }
Esempio n. 21
0
 public void Dispose(bool Dispose)
 {
     if (!Disposed)
     {
         if (Dispose)
         {
             if (Token != null)
             {
                 Token = null;
             }
             if (Header != null)
             {
                 Header = null;
             }
             if (Command != 0)
             {
                 Command = 0;
             }
             if (Response != 0)
             {
                 Response = 0;
             }
             if (!string.IsNullOrEmpty(Username))
             {
                 Username = null;
             }
             if (!string.IsNullOrEmpty(Argument))
             {
                 Argument = null;
             }
         }
         Disposed = true;
     }
 }
Esempio n. 22
0
        /// <summary>
        /// Messages from server.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="CommandEventArgs"/> instance containing the event data.</param>
        public void MessageFromServer(object sender, CommandEventArgs args)
        {
            CommandEnum commandID = args.CommandID;

            if (commandID == CommandEnum.GetAllLogsCommand)
            {
                Client client  = (Client)sender;
                string message = args.CommandArgs[0];
                var    obj     = Newtonsoft.Json.JsonConvert.DeserializeObject <List <MessageRecievedEventArgs> >(message);
                List <MessageRecievedEventArgs> logs = (List <MessageRecievedEventArgs>)obj;
                logs.Reverse();
                foreach (MessageRecievedEventArgs log in (List <MessageRecievedEventArgs>)obj)
                {
                    String StatusString = ConvertEnumType(log.Status);

                    LogEntries.Add(new Log {
                        EntryType = log.Status, Message = log.Message, Status = StatusString
                    });
                }
            }
            else if (commandID == CommandEnum.LogCommand)
            {
                Client client  = (Client)sender;
                string message = args.CommandArgs[0];
                var    obj     = Newtonsoft.Json.JsonConvert.DeserializeObject <MessageRecievedEventArgs>(args.CommandArgs[0]);

                MessageRecievedEventArgs SpecificLogView = (MessageRecievedEventArgs)obj;
                String StatusString = ConvertEnumType(SpecificLogView.Status);
                LogEntries.Insert(0, new Log {
                    EntryType = SpecificLogView.Status, Message = SpecificLogView.Message,
                    Status    = StatusString
                });
            }
        }
Esempio n. 23
0
        /// <summary>Commands the specified command.</summary>
        /// <param name="command">The command.</param>
        /// <param name="inputs">The inputs.</param>
        /// <returns></returns>
        /// <exception cref="InvalidCommandException">Robot does not exist
        /// or
        /// Invalid command</exception>
        public string Command(CommandEnum command, string inputs = "")
        {
            if (command != CommandEnum.PLACE && robot == null)
            {
                throw new InvalidCommandException("Robot does not exist");
            }
            switch (command)
            {
            case CommandEnum.PLACE:
                Place(inputs);
                break;

            case CommandEnum.MOVE:
                robot.Move();
                break;

            case CommandEnum.LEFT:
                robot.RotateLeft();
                break;

            case CommandEnum.RIGHT:
                robot.RotateRight();
                break;

            case CommandEnum.REPORT:
                return(robot.Report());

            default:
                throw new InvalidCommandException("Invalid command");
            }
            return("");
        }
Esempio n. 24
0
 private CommandDefinition.CommandFormat ConstructCommand(CommandEnum command, BooleanValue ackReq, ActionEnum action, byte subAction)
 {
     CommandDefinition.CommandAckStruct cmdAck = new CommandDefinition.CommandAckStruct(command, ackReq, BooleanValue.False);
     CommandDefinition.ActionStruct     a = new CommandDefinition.ActionStruct(action, subAction);
     CommandDefinition.CommandFormat    cmd = new CommandDefinition.CommandFormat(cmdAck.CommandWithAck, a.ActionAndSubAction);
     return(cmd);
 }
Esempio n. 25
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Out"></param>
        /// <param name="OutSize"></param>
        /// <param name="In"></param>
        /// <param name="InSize"></param>
        /// <param name="Command"></param>
        /// <param name="DoChecks"></param>
        /// <returns></returns>
        public ResultEnum hleUtilsBufferCopyWithRange(byte* Out, int OutSize, byte* In, int InSize, CommandEnum Command, bool DoChecks = true)
        {
            try
            {
                switch (Command)
                {
                    case CommandEnum.PSP_KIRK_CMD_DECRYPT_PRIVATE: kirk_CMD1(Out, In, InSize, DoChecks); break;
                    case CommandEnum.PSP_KIRK_CMD_ENCRYPT: kirk_CMD4(Out, In, InSize); break;
                    case CommandEnum.PSP_KIRK_CMD_ENCRYPT_FUSE: kirk_CMD5(Out, In, InSize); break;
                    case CommandEnum.PSP_KIRK_CMD_DECRYPT: kirk_CMD7(Out, In, InSize); break;
                    case CommandEnum.PSP_KIRK_CMD_DECRYPT_FUSE: executeKIRKCmd8(Out, In, InSize); break;
                    case CommandEnum.PSP_KIRK_CMD_PRIV_SIG_CHECK: kirk_CMD10(In, InSize); break;
                    case CommandEnum.PSP_KIRK_CMD_SHA1_HASH: KirkSha1(Out, In, InSize); break;
                    case CommandEnum.PSP_KIRK_CMD_ECDSA_GEN_KEYS: executeKIRKCmd12(Out, OutSize); break;
                    case CommandEnum.PSP_KIRK_CMD_ECDSA_MULTIPLY_POINT: executeKIRKCmd13(Out, OutSize, In, InSize); break;
                    case CommandEnum.PSP_KIRK_CMD_PRNG: kirk_CMD14(Out, InSize); break;
                    case CommandEnum.PSP_KIRK_CMD_ECDSA_SIGN: executeKIRKCmd16(Out, OutSize, In, InSize); break;
                    case CommandEnum.PSP_KIRK_CMD_ECDSA_VERIFY: executeKIRKCmd17(In, InSize); break;
                    default: throw(new KirkException(ResultEnum.PSP_KIRK_INVALID_OPERATION));
                }

                return ResultEnum.OK;
            }
            catch (KirkException KirkException)
            {
                return KirkException.Result;
            }
        }
Esempio n. 26
0
        private void ExecuteAction(object sender, IncomingMessage receivedMessage)
        {
            Entity owner = networkedScene.EntityManager.Find(receivedMessage.ReadString());
            Entity other = networkedScene.EntityManager.Find(receivedMessage.ReadString());

            if (owner != null && !owner.IsDisposed && other != null && !other.IsDisposed)
            {
                WorldObject wo  = owner.FindComponent <WorldObject>();
                CommandEnum cmd = (CommandEnum)receivedMessage.ReadInt32();
                foreach (ActionBehavior act in wo.allActions)
                {
                    if (act.GetCommand() == cmd)
                    {
                        bool store = receivedMessage.ReadBoolean();
                        if (store)
                        {
                            wo.EnqueueAction(() => act.Act(other.FindComponent <WorldObject>()));
                        }
                        else
                        {
                            act.Act(other.FindComponent <WorldObject>());
                        }
                        break;
                    }
                }
            }
        }
Esempio n. 27
0
 public QueueCommand(PackageClass packageClass, CommandEnum oper)
 {
   Date = DateTime.Now;
   CommandEnum = oper;
   TargetId = packageClass.GeneralInfo.Id;
   TargetVersion = packageClass.GeneralInfo.Version;
 }
 public QueueCommand(PackageClass packageClass, CommandEnum oper)
 {
     Date          = DateTime.Now;
     CommandEnum   = oper;
     TargetId      = packageClass.GeneralInfo.Id;
     TargetVersion = packageClass.GeneralInfo.Version;
 }
Esempio n. 29
0
        private void WaitForKey(object sender, EventArgs e)
        {
            CustomButton b = sender as CustomButton;
            CommandEnum  action;

            if (Enum.TryParse(b.Text, out action))
            {
                if (!rewriting || current != action)
                {
                    Cancel();
                    lastClicked = b.number;
                    blocks[lastClicked].IsBorder     = true;
                    blocks[lastClicked].BorderColor  = Color.Blue;
                    buttons[lastClicked].BorderColor = Color.Blue;
                    rewriting = true;
                    current   = action;
                }
                else
                {
                    Cancel();
                }
            }

            WaveServices.Layout.PerformLayout(this);
        }
Esempio n. 30
0
 public ReportResponse ReportOK(CommandEnum command = CommandEnum.Void)
 => new ReportResponse()
 {
     c  = command,
     e  = ErrorEnum.Void,
     rc = ResponseCodeEnum.OK
 };
Esempio n. 31
0
        /// <summary>
        /// send command to all the handlers.
        /// </summary>
        /// <param name="commandId"> the command required to be performed </param>
        /// <param name="args"> the arguments for the command </param>
        /// <param name="path"> the path related to the command </param>
        public void sendCommand(CommandEnum commandId, string[] args, string path)
        {
            CommandRecievedEventArgs cmdEventArgs = new CommandRecievedEventArgs((int)commandId, args, path);

            CommandRecieved?.Invoke(this, cmdEventArgs);
            m_logging.Log(path + " - " + commandId, Logging.Modal.MessageTypeEnum.INFO);
        }
Esempio n. 32
0
 public void SendCommand(CommandEnum commandID, string[] args)
 {
     client.SendMessageToServer(new CommandEventArgs()
     {
         CommandID = commandID, CommandArgs = args
     });
 }
Esempio n. 33
0
        /// <summary>
        /// Get an array of bytes to use as the default arguments for a
        /// command when no arguments are given; we have to specify the
        /// expected data/response size as the arguments instead.
        /// </summary>
        /// <param name="command">Command</param>
        /// <returns>byte[]</returns>
        public static byte[] GetCommandDefaultArgumentsBytes(CommandEnum command)
        {
            ByteStream bytes = new ByteStream();

            bytes.BinaryWriter.Write(CommandHelper.GetCommandDataSize(command));
            return(bytes.GetBytes());
        }
        private void WriteCommandParameter(CommandParameter parameter, List <string> enumValues, BinaryStream stream)
        {
            stream.WriteString(parameter.Name);
            int type = parameter.Type;

            if (parameter.CommandEnum != null && parameter.CommandEnum.Values.Length > 0)
            {
                CommandEnum   commandEnum = parameter.CommandEnum;
                List <string> realValue   = new List <string>();
                for (int k = 0; k < commandEnum.Values.Length; ++k)
                {
                    string value = commandEnum.Values[k];
                    if (enumValues.Contains(value))
                    {
                        realValue.Add(value);
                    }
                    else
                    {
                        enumValues.Add(value);
                        realValue.Add(value);
                    }
                }

                CommandEnum c         = new CommandEnum(commandEnum.Name, realValue.ToArray());
                int         enumIndex = -1;
                if (this.Enums.Contains(c, new CommandEnumComparer()))
                {
                    enumIndex = this.Enums.IndexOf(c) & 0xffff;
                }
                else
                {
                    this.Enums.Add(c);
                    enumIndex = this.Enums.IndexOf(c) & 0xffff;
                }
                type = CommandParameter.ARG_FLAG_ENUM | CommandParameter.ARG_FLAG_VALID | enumIndex;
            }
            else if (!string.IsNullOrEmpty(parameter.Postfix))
            {
                int    key     = -1;
                string postFix = parameter.Postfix;
                if (this.PostFixes.Contains(postFix))
                {
                    key = this.PostFixes.IndexOf(postFix) & 0xffff;
                }
                else
                {
                    this.PostFixes.Add(postFix);
                    key = this.PostFixes.IndexOf(postFix) & 0xffff;
                }
                type = CommandParameter.ARG_FLAG_POSTFIX | CommandParameter.ARG_FLAG_VALID | key;
            }
            else
            {
                type |= CommandParameter.ARG_FLAG_VALID;
            }
            stream.WriteLInt((uint)type);
            stream.WriteBool(parameter.Optional);
            stream.WriteByte(parameter.UnknownByte);
        }
Esempio n. 35
0
 private bool DefineSquirrelOption(ArgumentSyntax syntax, string name, CommandEnum command, bool hasVersion)
 {
     Argument<string> option = syntax.DefineOption(name, ref SquirrelVersion, hasVersion, string.Empty);
     option.IsHidden = true;
     if (option.IsSpecified)
     {
         Command = command;
         return true;
     }
     return false;
 }
Esempio n. 36
0
 public void exec(CommandEnum command, List<string> attributes, Organism.Organism organism)
 {
     switch (command)
     {
         case CommandEnum.born:
             Born born = new Born(organism);
             born.exec(attributes);
             break;
         default:
             break;
     }
 }
 public void CallCommand(CommandEnum requested, RaycastHit clicked)
 {
     if(clicked.Equals(null) || team == null) return;
     switch((CommandEnum)requested){
         case CommandEnum.Move:
             team.AddCommand(new MoveCommand(team, clicked.transform.position));
             break;
         case CommandEnum.ArmMine:
             team.AddCommand(new MineCommand(team));
             break;
         case CommandEnum.BlowDoor:
             throw new System.NotImplementedException("BlowDoor");
             break;
         case CommandEnum.BlowWindow:
             throw new System.NotImplementedException("BlowWindow");
             break;
         case CommandEnum.CoverHostage:
             throw new System.NotImplementedException("CoverHostage");
             break;
         case CommandEnum.ForceDoor:
             throw new System.NotImplementedException("ForceDoor");
             break;
         case CommandEnum.OpenDoor:
             team.AddCommand(new DoorCommand(team, clicked.transform.gameObject));
             break;
         case CommandEnum.OpenWindow:
             team.AddCommand(new OpenWIndowCommand(team, clicked.transform.gameObject.GetComponent<Window>()));
             break;
         case CommandEnum.ThrowFragGrenade:
             team.AddCommand(new FragGrenadeCommand(team));
             break;
         case CommandEnum.ThrowFlashGrenade:
             throw new System.NotImplementedException("FlashGrenade");
             break;
         case CommandEnum.Wait:
             throw new System.NotImplementedException("WaitPoint");
             break;
         default:
             break;
     }
 }
Esempio n. 38
0
 public CommandAckStruct(CommandEnum cmd, BooleanValue ackReq, BooleanValue isAck)
 {
     _commandWithAck = (byte)(((byte)cmd << 2) | ((byte)ackReq << 1) | (byte)isAck);
 }
Esempio n. 39
0
 private string CommandReplyValidate(CommandDefinition.CommandFormat? reply, CommandEnum expectedCommand)
 {
     string result = /*OK*/ string.Empty;
     if (/*fail?*/ reply == null)
         result = "null reply";
     else if (/*fail?*/ !reply.HasValue)
         result = "reply has no value (!.HasValue)";
     else if (/*fail?*/ reply.Value.CommandAck.Command != expectedCommand)
         result = ".Value.CommandAck.Command(" + reply.Value.CommandAck.Command.ToString() + ") != " + expectedCommand.ToString();
     else if (/*fail?*/ reply.Value.Action.Action != ActionEnum.Response)
         result = ".Value.Action.Action(" + reply.Value.Action.Action.ToString() + ") != " + ActionEnum.Response.ToString();
     return result;
 }
Esempio n. 40
0
 private string CommandReplyValidate(CommandDefinition.CommandFormat? reply, CommandEnum expectedCommand, byte expectedSubAction)
 {
     string result = CommandReplyValidate(reply, expectedCommand);
     if (/*OK?*/ string.IsNullOrWhiteSpace(result))
         if (/*fail?*/ reply.Value.CommandAck.IsAck != BooleanValue.True)
             result = ".Value.CommandAck.IsAck(" + reply.Value.CommandAck.IsAck.ToString() + ") != BooleanValue.True";
         else if (/*fail?*/ reply.Value.Action.SubAction != expectedSubAction)
             result = ".Value.Action.SubAction(" + reply.Value.Action.SubAction.ToString() + ") != " + expectedSubAction.ToString();
     return result;
 }
Esempio n. 41
0
 private void Apcs_ApcsUpdate(CommandEnum command, ActionEnum action, byte subAction, object data)
 {
     if (command == CommandEnum.PulseWidth && action == ActionEnum.Response)
         _currentPulseWidth = (PulseWidth)PulseWidth.ToObject(typeof(PulseWidth), subAction);
     else if (command == CommandEnum.ScanMode && action == ActionEnum.Response)
         _currentApcsEnergyMode = (ScanEnergyMode)ScanEnergyMode.ToObject(typeof(ScanEnergyMode), subAction);
 }
Esempio n. 42
0
 private CommandDefinition.CommandFormat CommandMake(CommandEnum commandCode, BooleanValue acknowledgeIsRequested, ActionEnum actionCode, byte subAction)
 {
     CommandDefinition.CommandAckStruct acknowledgement = new CommandDefinition.CommandAckStruct(commandCode, acknowledgeIsRequested, BooleanValue.False);
     CommandDefinition.ActionStruct action = new CommandDefinition.ActionStruct(actionCode, subAction);
     CommandDefinition.CommandFormat returnedCommand = new CommandDefinition.CommandFormat(acknowledgement.CommandWithAck, action.ActionAndSubAction);
     return returnedCommand;
 }
Esempio n. 43
0
 private bool ConfirmSetActionResponse(CommandDefinition.CommandFormat? response, CommandEnum command, byte subAction)
 {
     return (response != null &&
             response.Value.CommandAck.Command == command &&
             response.Value.Action.Action == ActionEnum.Response &&
             response.Value.CommandAck.IsAck == BooleanValue.True &&
             response.Value.Action.SubAction == subAction);
 }
Esempio n. 44
0
 private CommandDefinition.CommandFormat ConstructCommand(CommandEnum command, BooleanValue ackReq, ActionEnum action, byte subAction)
 {
     CommandDefinition.CommandAckStruct cmdAck = new CommandDefinition.CommandAckStruct(command, ackReq, BooleanValue.False);
     CommandDefinition.ActionStruct a = new CommandDefinition.ActionStruct(action, subAction);
     CommandDefinition.CommandFormat cmd = new CommandDefinition.CommandFormat(cmdAck.CommandWithAck, a.ActionAndSubAction);
     return cmd;
 }
Esempio n. 45
0
 public void AddCommand(CommandEnum command, string commandData)
 {
     this.commands.Add(new KeyValuePair<CommandEnum, string>(command, commandData));
 }
Esempio n. 46
0
 public void AddCommand(CommandEnum command)
 {
     this.commands.Add(new KeyValuePair<CommandEnum, string>(command, null));
 }
Esempio n. 47
0
 public CopyDataTransport(CommandEnum command, string commandData)
     : this()
 {
     AddCommand(command, commandData);
 }
Esempio n. 48
0
 public CopyDataTransport(CommandEnum command)
     : this()
 {
     AddCommand(command, null);
 }
Esempio n. 49
0
            public byte Size; // Size - 1 byte - Indicates number of packet(s) following the Command Packet

            public CommandPacket(CommandEnum command, TypeEnum type)
            {
                Reserved_1 = 0x16;
                Reserved_2 = 0x16;
                Reserved_3 = 0x16;
                Reserved_4 = 0x16;

                this.Command = command;
                this.Type = type;
                Size = 0;
                Reserved2 = 0;

            }