Exemple #1
0
        override /// <summary>
        /// HandleCommand
        /// </summary>
        /// <param name="pContext">CommandContext</param>
        /// <param name="pSyncResult">ISyncResult</param>
        /// <returns>int</returns>
        public int HandleCommand(CommandContext pContext, ISyncResult pSyncResult)
        {
            var guid = Guid.NewGuid().ToString();

            string commandId = pContext != null?pContext.iCommandId.ToString() : string.Empty;

            GlobalDefinition.LoggerWrapper.LogDevInfo("####################Receive Command.#######################" +
                                                      guid + "########commandid:" + commandId);

            if (null == pContext || null == pSyncResult)
            {
                GlobalDefinition.LoggerWrapper.LogDevInfo(
                    "####################processed Command.#######################" + guid + "########commandid:" +
                    commandId);
                GlobalDefinition.LoggerWrapper.LogDevError("ICLRCommandHandler's param is null.");
                return(0);
            }

            if (null == CmdMap || null == CmdMapByte)
            {
                GlobalDefinition.LoggerWrapper.LogDevInfo(
                    "####################processed Command.#######################" + guid + "########commandid:" +
                    commandId);
                GlobalDefinition.LoggerWrapper.LogDevError("Not initialize the CmdMap");
                return(0);
            }

            if (CmdMap.ContainsKey(pContext.iCommandId))
            {
                string result = CmdMap[pContext.iCommandId](pContext);

                pSyncResult.SetSerializedString(result);
            }
            else if (CmdMapByte.ContainsKey(pContext.iCommandId))
            {
                byte[] result = CmdMapByte[pContext.iCommandId](pContext);

                pSyncResult.SetSerializedObject(result);
            }
            else
            {
                GlobalDefinition.LoggerWrapper.LogDevInfo(
                    "####################processed Command.#######################" + guid + "########commandid:" +
                    commandId);
                GlobalDefinition.LoggerWrapper.LogDevError("Not process this command id: " +
                                                           pContext.iCommandId.ToString());
                return(0);
            }

            GlobalDefinition.LoggerWrapper.LogDevInfo(pSyncResult.GetSerializedString());

            GlobalDefinition.LoggerWrapper.LogDevInfo("####################processed Command.#######################" +
                                                      guid + "########commandid:" + commandId);
            return(0);
        }
    // Parse the command by splitting it up into arguments and determining which command is being run.
    public string Parse(string _command)
    {
        string _result = "No.";

        string[] _arguments = _command.Split(' ');

        if (_command.ToLower().StartsWith("say"))
        {
            _arguments = new string[] {
                "say", _command.Replace("say ", string.Empty).Replace("Say ", string.Empty)
            };
        }
        else
        {
            _arguments = _command.Split(' ');
        }
        if (_arguments.Length >= 2)
        {
            string _cmd = _arguments[0] + " " + _arguments[1];
            CmdMap _map = new CmdMap();
            if (_map.Run(_cmd))
            {
                _result = string.Empty;
            }
        }
        return(_result);
    }
Exemple #3
0
        public static Dictionary <string, AlgCmd> InitCmdMap()
        {
            CmdMap.Add("file_name", new AlgCmd("CMD_FILE_NAME", 0x80));
            CmdMap.Add("next_line", new AlgCmd("CMD_FILE_NEXTLINE", 0x81));
            CmdMap.Add("file_end", new AlgCmd("CMD_FILE_END", 0x82));

            CmdMap.Add("comment", new AlgCmd("CMD_COMMENT", 0x84));
            CmdMap.Add("print", new AlgCmd("CMD_PRINTSTR", 0x85));

            CmdMap.Add("delay_s", new AlgCmd("CMD_DELAY_S", 0x86));
            CmdMap.Add("delay_ms", new AlgCmd("CMD_DELAY_MS", 0x87));
            CmdMap.Add("delay_us", new AlgCmd("CMD_DELAY_US", 0x88));
            CmdMap.Add("show_data", new AlgCmd("CMD_MEMORY_SHOW", 0x89));

            CmdMap.Add("ssd_powermode", new AlgCmd("CMD_SSD2832_POWERMODE", 0x90));
            CmdMap.Add("ssd_rest", new AlgCmd("CMD_SSD2832_RESET", 0x91));
            CmdMap.Add("ssd_pll", new AlgCmd("CMD_SSD2832_PLL", 0x92));
            CmdMap.Add("ssd_write", new AlgCmd("CMD_SSD2832_WRITE", 0x93));
            CmdMap.Add("ssd_read", new AlgCmd("CMD_SSD2832_READ", 0x94));


            CmdMap.Add("mipi_write", new AlgCmd("CMD_MIPI_WRITE", 0xA0));
            CmdMap.Add("mipi_read", new AlgCmd("CMD_MIPI_READ", 0xA1));
            CmdMap.Add("mipi_video", new AlgCmd("CMD_MIPI_VIDEO", 0xA2));
            CmdMap.Add("mipi_timing", new AlgCmd("CMD_MIPI_TIMING", 0xA3));
            CmdMap.Add("mipi_mode", new AlgCmd("CMD_MIPI_MODE", 0xA4));

            //CmdMap.Add("driver_reset", new AlgCmd("CMD_FPGA_RESET", 0xB0));
            CmdMap.Add("driver_write", new AlgCmd("CMD_FPGA_WRITE", 0xB1));
            CmdMap.Add("driver_read", new AlgCmd("CMD_FPGA_READ", 0xB2));
            CmdMap.Add("driver_dsc", new AlgCmd("CMD_FPGA_DSC", 0xB3));
            CmdMap.Add("driver_video", new AlgCmd("CMD_FPGA_VIDEO", 0xB4));
            CmdMap.Add("driver_pclk", new AlgCmd("CMD_FPGA_PCLK", 0xB5));
            CmdMap.Add("driver_timing", new AlgCmd("CMD_FPGA_TIMING", 0xB6));

            CmdMap.Add("show_image", new AlgCmd("CMD_SHOW_IMAGE", 0xB8));
            CmdMap.Add("show_color", new AlgCmd("CMD_SHOW_COLOR", 0xB9));
            CmdMap.Add("show_special", new AlgCmd("CMD_SHOW_SPECIAL", 0xBa));
            CmdMap.Add("show_cycle", new AlgCmd("CMD_SHOW_CYCLE", 0xBb));

            CmdMap.Add("set_volt", new AlgCmd("CMD_VOLT_SET", 0xC0));
            CmdMap.Add("set_curr", new AlgCmd("CMD_CURR_SET", 0xC1));
            CmdMap.Add("get_volt", new AlgCmd("CMD_VOLT_GET", 0xC2));
            CmdMap.Add("get_curr", new AlgCmd("CMD_CURR_GET", 0xC3));

            CmdMap.Add("gpio_reset", new AlgCmd("CMD_GPIO_RESET", 0xD0));
            CmdMap.Add("gpio_on", new AlgCmd("CMD_GPIO_ON", 0xD1));
            CmdMap.Add("gpio_off", new AlgCmd("CMD_GPIO_OFF", 0xD2));

            CmdMap.Add("pwm", new AlgCmd("CMD_PWM", 0xE0));

            CmdMap.Add("iic_write", new AlgCmd("CMD_IIC_WRITE", 0xE5));
            CmdMap.Add("iic_read", new AlgCmd("CMD_IIC_READ", 0xE6));
            return(CmdMap);
        }
Exemple #4
0
        /// <summary>
        /// AddItemToCommandMap
        /// </summary>
        /// <param name="key">int</param>
        /// <param name="command">CmdHandler</param>
        public static void AddItemToCommandMap(int key, CmdHandler command)
        {
            if (null == CmdMap)
            {
                GlobalDefinition.LoggerWrapper.LogTraceInfo("CmdMap is  null");
                return;
            }

            if (!CmdMap.ContainsKey(key))
            {
                CmdMap.Add(key, command);
            }
        }
Exemple #5
0
    public override void Execute(CmdMap _cmd)
    {
        switch (destination)
        {
        case "left":
            GameManager.instance.player.Move("left");
            break;

        case "right":
            GameManager.instance.player.Move("right");
            break;
        }
    }
Exemple #6
0
    public override void Execute(CmdMap _cmd)
    {
        switch (destination)
        {
        case "forward":
            GameManager.instance.player.Move("forward");
            break;

        case "back":
            GameManager.instance.player.Move("back");
            break;
        }
    }
Exemple #7
0
    public override void Execute(CmdMap _cmd)
    {
        if (string.IsNullOrEmpty(message))
        {
            Debug.LogError("Tried sending message but it was empty.");
        }

        GameManager.instance.JSON.Store <Chat, JsnReceiver> (new List <Chat>
        {
            new Chat {
                PlayerName = GameManager.instance.Username,
                Level      = GameManager.instance.Level,
                Content    = message
            }
        }, MessageSuccess);
    }
Exemple #8
0
 public override void Execute(CmdMap _cmd)
 {
     switch (item)
     {
     case "key":
         if (GameManager.instance.player.IsOnItemTile)
         {
             if (GameManager.instance.player.GetItemTile.ItemName == ("Gold Key"))
             {
                 GameManager.instance.inventory.AddInventoryItem("Gold Key");
                 GameManager.instance.player.IsOnItemTile = false;
                 Destroy(GameManager.instance.player.GetItemTile.gameObject);
             }
         }
         break;
     }
 }
Exemple #9
0
        public CommandHandler(SurvivalPlayers list, SurvivalMaps maps)
        {
            _playersList  = list;
            _survivalMaps = maps;

            _cmdTools         = new CmdTools();
            _cmdSetPerms      = new CmdSetPerms();
            _cmdMap           = new CmdMap(list, _survivalMaps);
            _cmdInventory     = new CmdInventory(list, _survivalMaps);
            _cmdDrop          = new CmdDrop(list, _survivalMaps);
            _cmdCraftList     = new CmdCraftList();
            _cmdCrafting      = new CmdCrafting();
            _cmdCraft         = new CmdCraft(list, _survivalMaps);
            _cmdCmdsWhitelist = new CmdCmdsWhitelist();
            _cmdBlock         = new CmdBlock();
            _cmdActionBlocks  = new CmdActionBlocks();
            _cmdChest         = new CmdChest(list, _survivalMaps);
        }
Exemple #10
0
 public override void Execute(CmdMap _cmd)
 {
     switch (item)
     {
     case "key":
         if (GameManager.instance.player.IsOnDoorTile)
         {
             if (GameManager.instance.player.GetDoorTile.KeyName == ("Gold Key"))
             {
                 if (GameManager.instance.inventory.HasItem("Gold Key"))
                 {
                     GameManager.instance.inventory.RemoveInventoryItem("Gold Key");
                     GameManager.instance.FinishLevel();
                     // SceneManager.LoadScene(2);
                 }
             }
         }
         break;
     }
 }
Exemple #11
0
 // Set up a virtual void that is overridden by each command to perform different actions.
 public virtual void Execute(CmdMap _cmd)
 {
 }