/// <summary>
        /// Called whenever a network command is received that the task should deal with
        /// </summary>
        /// <param name="c">The command that was received</param>
        /// <param name="server">The server that received the command</param>
        /// <param name="handler">The client that sent the command. Use the client and server object if you need to send a reply</param>
        public override void ProcessNetworkCommand(ICommand c, INetworkServer server, Socket client)
        {
            eCommands command = (eCommands)c.CommandType;

            switch (command)
            {
            case eCommands.Message:
                string msg = c.getParameterAsString((int)eMessageCommandParameters.Message);
                logger.Info("Received message from:" + client.RemoteEndPoint.ToString() + ", " + msg);
                break;

            case eCommands.TaskCompleted:
            {
                logger.Info("Received task completed command from:" + client.RemoteEndPoint.ToString());

                _sendCommandStopTrial();
                _sendCommandFadeOut();
            }
            break;

//                default:
//                    logger.Info("Received unknown command " + c.ToString() + " from:" + client.RemoteEndPoint.ToString() + "\r\n" + c.ToString());
//                    break;
            }
        }
Example #2
0
        private object ProcessRxData(object obj)
        {
            //CrestronConsole.PrintLine("RxHandler thread {ID# {0}) is running", Thread.CurrentThread.ManagedThreadId);
            StringBuilder RxData = new StringBuilder();
            int           Pos    = -1;

            String MatchString = String.Empty;

            // the Dequeue method will wait, making this an acceptable
            // while (true) implementation.
            while (true)
            {
                try
                {
                    //CrestronConsole.PrintLine("Crestron proocessing sting data");
                    // removes string from queue, blocks until an item is queued
                    string tmpString = RxQueue.Dequeue();

                    if (tmpString == null)
                    {
                        return(null);         // terminate the thread
                    }
                    RxData.Append(tmpString); //Append received data to the COM buffer
                    MatchString = RxData.ToString();
                    //CrestronConsole.PrintLine("matchstring is {0}", MatchString);
                    //find the delimiter
                    Pos = MatchString.IndexOf(Convert.ToChar("\x03"));
                    //Pos = MatchString.IndexOf(Convert.ToChar(etx));
                    if (Pos >= 0)
                    {
                        // delimiter found
                        // create temporary string with matched data.
                        //CrestronConsole.PrintLine("we achieved delimeter {0}, length {1}",MatchString,MatchString.Length);
                        MatchString = MatchString.Substring(0, Pos);
                        RxData.Remove(0, Pos + 1); // remove data from COM buffer
                        // parse data here
                        //CrestronConsole.PrintLine("Matchstrng is {0}", MatchString);
                        ProcessResponse(MatchString);
                    }
                }
                catch (Exception ex)
                {
                    CrestronConsole.PrintLine("Exception in thread: {0}\n\r{1}", ex.Message, ex.StackTrace);
                }

                if (TxQueue.IsEmpty)
                {
                    LastCommand = eCommands.Idle;
                    //CrestronConsole.PrintLine("Last Command is second {0}, postion is {1}", LastCommand, Pos);
                }
                else
                {
                    LastCommand = TxQueue.Dequeue();
                    _com.Send(CommandStrings[LastCommand]);
                    RxWaitTimer.Reset(500);
                }
            }
        }
Example #3
0
    public override void Attack(eCommands direction, eCommands key)
    {
        if (_Player.GetState() != CharacterBase.eState.Idle && _Player.GetState() != CharacterBase.eState.Move && !_isCancelable) // 서있거나 이동중이 아니고 캔슬이 불가능할 때
        {
            return;
        }
        if (_Player.GetComponent <Rigidbody2D>().velocity.y != 0) // 공중에 있을 때
        {
            return;
        }
        if (_isCancelable && direction == eCommands.None) // 캔슬이 가능하지만 입력한 커맨드가 평타일 때
        {
            return;
        }

        base.Attack(direction, key);

        bool isAttacked = false;

        switch (direction)
        {
        case eCommands.None:
            if (key == eCommands.Left)
            {
                PlayAnimation(_ComboCounter % 2 == 0 ? "Player_Glove_WeakAttack" : "Player_Glove_StrongAttack", out isAttacked);
                _ComboCounter++;
            }
            break;

        case eCommands.Front:
            if (key == eCommands.Right)
            {
                PlayAnimation("Player_Glove_Smash", out isAttacked);
            }
            else if (key == eCommands.Left)
            {
                PlayAnimation("Player_Glove_Special", out isAttacked);
            }
            break;

        case eCommands.Up:
            if (key == eCommands.Right)
            {
                PlayAnimation("Player_Glove_Airborne", out isAttacked);
            }
            break;
        }

        if (isAttacked == false) // 입력한 키에 맞는 공격이 없을 때
        {
            _Player.SetState(CharacterBase.eState.Idle);
        }
    }
Example #4
0
        public static void WriteCommand(eCommands command, FastColoredTextBox box, params string[] paths)
        {
            string str           = command.ToString();
            bool   needs_newline = NeedsNewLine(box);

            foreach (var path in paths)
            {
                str += " " + path;
            }
            box.Text += needs_newline ? Environment.NewLine : string.Empty;
            box.Text += str + Environment.NewLine;
            Core.WriteEndscriptLine(str);
        }
        private void TxCommand(eCommands cmd)
        {
            if (!_ready)
            {
                throw new NotRegisteredException("This object was not fully initialized");
            }

            if (LastCommand == eCommands.Idle)
            {
                CrestronConsole.PrintLine("sending {0}", cmd.ToString());

                LastCommand = cmd;

                switch (cmd)
                {
                case eCommands.PowerOn:
                case eCommands.PowerOff:
                case eCommands.PowerQuery:
                //case eCommands.InputQuery:
                case eCommands.LampQuery:
                case eCommands.InputDVI:
                case eCommands.InputRGB1:
                case eCommands.VideoMuteOn:
                case eCommands.VideoMuteOff:
                case eCommands.LampHour1Query:
                case eCommands.LampHour2Query:
                    _com.Send(CommandStrings[cmd]);
                    RxWaitTimer.Reset(500);
                    break;

                default:
                    break;
                }
            }
            else
            {
                CrestronConsole.PrintLine("adding {0} to txqueue", cmd.ToString());
                TxQueue.Enqueue(cmd);
            }
        }
        // -------------------------------------------------------------------------------------------------------------------------
        // callback that gets notified whenever a network command has been received
        private static void _serverReceivedCommand(ICommand c, INetworkServer server, Socket handler)
        {
            eCommands command = (eCommands)c.CommandType;

            switch (command)
            {
            case eCommands.Message:
            {
                string message = c.getParameterAsString((int)eMessageCommandParameters.Message);
                logger.Info("Network: received message from " + IPAddress.Parse(((IPEndPoint)handler.RemoteEndPoint).Address.ToString()) + ": " + message);
            }

            break;

            case eCommands.RegisterClient:
            {
                int    nc          = 0;
                string versionInfo = "UNDEFINED";
                try {
                    versionInfo = c.getParameterAsString((int)eRegisterClientCommandParameters.VersionInfo);
                    nc          = c.getParameterAsInt((int)eRegisterClientCommandParameters.NumScenes);
                } catch (Exception) {
                }

                logger.Info("Network: Client version: " + versionInfo);
                logger.Info("Network: Client number of scenes: " + nc);

                MainForm.GetMainForm().NumberOfScenesInNetworkClients = nc;
            }
            break;

            default:
                if (currentTask != null)
                {
                    currentTask.ProcessNetworkCommand(c, server, handler);
                }
                break;
            }
        }
 public byte[] eReason()
 {
     m_State     = eCommands.eReason;
     m_Confirmed = false;
     return(MakeCommand("vStopped"));
 }
 public byte[] eStepSingle()
 {
     m_State     = eCommands.eStepSingle;
     m_Confirmed = false;
     return(MakeCommand("i"));
 }
 public byte[] eRegister(string register)
 {
     m_State     = eCommands.eRegister;
     m_Confirmed = false;
     return(MakeCommand("p " + register));
 }
 public byte[] eRegisters()
 {
     m_State     = eCommands.eRegisters;
     m_Confirmed = false;
     return(MakeCommand("g"));
 }
 public byte[] eExtendedMode()
 {
     m_State     = eCommands.eExtendedMode;
     m_Confirmed = false;
     return(MakeCommand("eExtendedMode"));
 }
 public byte[] qSupported()
 {
     m_State     = eCommands.qSupported;
     m_Confirmed = false;
     return(MakeCommand("qSupported"));
 }
Example #13
0
    public override void Attack(eCommands direction, eCommands key)
    {
        if (_Player.GetState() != CharacterBase.eState.Idle && _Player.GetState() != CharacterBase.eState.Move && !_isCancelable)         // 서있거나 이동중이 아니고 캔슬이 불가능할 때
        {
            return;
        }
        if (_Player.GetComponent <Rigidbody2D>().velocity.y != 0)        // 공중에 있을 때
        {
            return;
        }
        if (_isCancelable && ((direction == eCommands.None) || (direction == eCommands.Front && key == eCommands.Left)))         // 캔슬이 가능하지만 입력한 커맨드가 평타일 때
        {
            return;
        }

        bool isAttacked = false;

        switch (direction)
        {
        case eCommands.None:
            if (key == eCommands.Left)
            {
                switch (_ComboCounter)
                {
                case 0: PlayAnimation("Player_Sword_Swing1", out isAttacked); break;

                case 1: PlayAnimation("Player_Sword_Swing2", out isAttacked); break;

                case 2: PlayAnimation("Player_Sword_Swing3", out isAttacked); break;
                }
                _ComboCounter = (_ComboCounter + 1) % 3;
            }
            break;

        case eCommands.Front:
            if (key == eCommands.Right)
            {
                PlayAnimation("Player_Sword_ShieldSlam", out isAttacked);
            }
            else if (key == eCommands.Left)
            {
                switch (_ComboCounter)
                {
                case 0: PlayAnimation("Player_Sword_Swing1", out isAttacked); break;

                case 1: PlayAnimation("Player_Sword_Swing2", out isAttacked); break;

                case 2: PlayAnimation("Player_Sword_Swing3", out isAttacked); break;
                }
                _ComboCounter = (_ComboCounter + 1) % 3;
            }
            break;

        case eCommands.Down:
            if (key == eCommands.Left)
            {
                PlayAnimation("Player_Sword_Parrying_Ready", out isAttacked);
            }
            break;
        }

        if (isAttacked == false && _isCancelable == false)         // 입력한 키에 맞는 공격이 없을 때
        {
            _Player.SetState(CharacterBase.eState.Idle);
            return;
        }
        base.Attack(direction, key);
    }
Example #14
0
    public override void Attack(eCommands direction, eCommands key)
    {
        if (_Player.GetState() != CharacterBase.eState.Idle && _Player.GetState() != CharacterBase.eState.Move && !_isCancelable)         // 서있거나 이동중이 아니고 캔슬이 불가능할 때
        {
            return;
        }
        if (_Player.GetComponent <Rigidbody2D>().velocity.y != 0)        // 공중에 있을 때
        {
            return;
        }
        if (_isCancelable && ((direction == eCommands.None) || (direction == eCommands.Front && key == eCommands.Left)))         // 캔슬이 가능하지만 입력한 커맨드가 평타일 때
        {
            return;
        }

        bool isAttacked = false;

        switch (direction)
        {
        case eCommands.None:
            if (key == eCommands.Left)
            {
                PlayAnimation("Player_Akimbo_Pistol_WeakAttack", out isAttacked);
            }
            break;

        case eCommands.Front:
            if (key == eCommands.Right)
            {
                PlayAnimation("Player_Akimbo_Pistol_Spin", out isAttacked);
                _SpinMoveRoutine = MoveWhileSpinRoutine(_Player);
                _Player.StartCoroutine(_SpinMoveRoutine);
            }
            else if (key == eCommands.Left)
            {
                PlayAnimation("Player_Akimbo_Pistol_WeakAttack", out isAttacked);
            }
            break;

        case eCommands.Up:
            if (key == eCommands.Right)
            {
                PlayAnimation("Player_Akimbo_Pistol_Vault", out isAttacked);
            }
            break;

        case eCommands.Down:
            if (key == eCommands.Right)
            {
                PlayAnimation("Player_Akimbo_Pistol_ChargeShot", out isAttacked);
            }
            break;
        }

        if (isAttacked == false && _isCancelable == false)         // 입력한 키에 맞는 공격이 없을 때
        {
            _Player.SetState(CharacterBase.eState.Idle);
            return;
        }
        base.Attack(direction, key);
    }