Example #1
0
        public override Node PrepareAction(Node currState, Player oponent)
        {
            ACommand partialCommand = GetCmd(currState.Boards, oponent);
            Node     state          = new Node(0, currState.Boards, partialCommand);

            return(state);
        }
Example #2
0
        /// <summary>
        /// Update safe state of Ev3 Brick sent by GetSafeState command.
        /// </summary>
        /// <param name="Command">GetSafeState command data.</param>
        /// <param name="Brick">Ev3Brick object to received data.</param>
        public override void Update(ACommand Command, Ev3Brick Brick)
        {
            Debug.Assert(Command != null);
            Debug.Assert(Brick != null);

            if (Command is Command_A0_00)
            {
                int  DataTopIndex = 4;
                byte SafeState    = Command.ResData[DataTopIndex];

                switch (SafeState)
                {
                case 0x00:
                    Brick.State.State = Model.SafeState.SAFE_STATE.SAFE_STATE_SAFE;
                    break;

                case 0x01:
                    Brick.State.State = Model.SafeState.SAFE_STATE.SAFE_STATE_ATTN;
                    break;

                case 0x02:
                    Brick.State.State = Model.SafeState.SAFE_STATE.SAFE_STATE_WARN;
                    break;

                case 0x03:
                    Brick.State.State = Model.SafeState.SAFE_STATE.SAFE_STATE_STOP;
                    break;

                default:
                    Brick.State.State = Model.SafeState.SAFE_STATE.SAFE_STATE_UNKNOWN;
                    break;
                }
            }
        }
Example #3
0
        /// <summary>
        /// Get the best command associated with a string.
        /// </summary>
        /// <param name="parse">The complete command string, including Identifier.</param>
        /// <returns>The best command associated with parse.</returns>
        private static ACommand GetCommand(string parse)
        {
            parse = parse.TrimStart().ToLower();

            List <ACommand> list;

            if (!Static.dummyCommands.TryGetValue(parse[0], out list))
            {
                return(null);
            }

            ACommand bestMatch       = null;
            int      bestMatchLength = 0;

            foreach (ACommand cmd in list)
            {
                foreach (string idOrAlias in cmd.IdAndAliases())
                {
                    if (idOrAlias.Length > bestMatchLength && parse.StartsWith(idOrAlias))
                    {
                        bestMatchLength = idOrAlias.Length;
                        bestMatch       = cmd;
                    }
                }
            }

            if (bestMatch == null)
            {
                return(null);
            }
            return(bestMatch.Clone());
        }
Example #4
0
        public void StartGooeyProgramming()
        {
            Log.DebugLog("entered");

            using (MainLock.AcquireSharedUsing())
            {
                m_currentCommand = null;
                m_listCommands   = true;
                m_commandList.Clear();
                m_syntaxErrors.Clear();

                MyTerminalControls.Static.CustomControlGetter += CustomControlGetter;
                m_block.AppendingCustomInfo += m_block_AppendingCustomInfo;

                Commands = AutopilotTerminal.GetAutopilotCommands(m_block).ToString();
                foreach (ACommand comm in ParseCommands(Commands))
                {
                    m_commandList.Add(comm);
                }
                if (m_syntaxErrors.Length != 0)
                {
                    m_block.UpdateCustomInfo();
                }
                m_block.RebuildControls();
            }
        }
        /// <summary>
        /// Update motor device information of Ev3 Brick by GetMotorPower command,
        /// especially motor output power.
        /// </summary>
        /// <param name="Command"></param>
        /// <param name="Brick"></param>
        public override void Update(ACommand Command, Ev3Brick Brick)
        {
            Debug.Assert(Command != null);
            Debug.Assert(Brick != null);

            if (Command is Command_10_01)
            {
                int Index        = 0;
                int DataTopIndex = 4;
                for (Index = 0; Index < 4; Index++)
                {
                    int  DataIndex  = DataTopIndex + Index * 2;
                    byte Connection = Command.ResData[DataIndex++];
                    int  Power      = (int)((sbyte)(Command.ResData[DataIndex]));

                    var Device = Brick.MotorDevice(Index);
                    Device.ConnectedPort = (Ev3Device.OUTPORT)Index;
                    if (0x00 == Connection)
                    {
                        Device.IsConnected = false;
                        Device.Power       = 0;
                    }
                    else
                    {
                        Device.IsConnected = true;
                        Device.Power       = Power;
                    }
                }
            }
        }
Example #6
0
        internal static AControl GetControl(ACommand command)
        {
            switch (command.ControlType)
            {
            case MappingControlType.Button:
                return(Button.AButtonControl.FromCommand(command));

            case MappingControlType.FaderOrKnob:
                return(FaderOrKnob.FaderOrKnobControl.FromCommand(command));

            case MappingControlType.Encoder:
                return(new Encoder.EncoderControl(command));

            case MappingControlType.LED:
                var d1 = typeof(LED.LedControl <>);
                var t  = command.GetType();
                while (!t.IsGenericType && t.BaseType != typeof(object))
                {
                    t = t.BaseType;
                }
                if (t.IsGenericType)
                {
                    var makeme = d1.MakeGenericType(t.GenericTypeArguments);
                    return(Activator.CreateInstance(makeme, _flags, null, new object[] { command }, _culture) as AControl);
                }
                else
                {
                    return(new LED.LedControl <int>(command));
                }

            default:
                return(null);
            }
        }
        /// <summary>
        /// Do handshake for client side.
        /// </summary>
        /// <param name="clientSocket"> Socket from client side to server side</param>
        /// <returns>null if handShake fail otherwise return instance of AProtocol</returns>
        public async Task <AProtocol> HandShakeClient(NetworkStream clientSocket)
        {
            HelloCommand hello = new HelloCommand(ClientConfig.SUPPORTED_PROTOCOLS);
            await hello.SendAsync(clientSocket);

            ACommand shouldBeOLLEH = GetCommand(await clientSocket.ReadLineAsync());

            if (shouldBeOLLEH is OllehCommand)
            {
                OllehCommand olleh    = (OllehCommand)shouldBeOLLEH;
                AProtocol    protocol = ClientConfig.PROTOCOL_FACTORY.GetProtocol(olleh.PROTOCOL);
                if (protocol != null)
                {
                    AckCommand ack = new AckCommand();
                    await ack.SendAsync(clientSocket);

                    return(protocol);
                }
                ErrorCommand error = new ErrorCommand($"Unsupported protocols '{olleh.PROTOCOL}'. Handshake failed.");
                await error.SendAsync(clientSocket);
            }
            else
            {
                printIfErrorElseSendMessage(shouldBeOLLEH, "Handshake error. Expected OllehCommand but receive " + shouldBeOLLEH.GetType().Name, clientSocket);
            }
            return(null);
        }
Example #8
0
        public static AButtonControl FromCommand(ACommand command)
        {
            switch (command.InteractionMode)
            {
            case MappingInteractionMode.Trigger:
                return(new TriggerButtonControl(command));

            case MappingInteractionMode.Toggle:
                return(new ToggleButtonControl(command));

            case MappingInteractionMode.Hold:
                return(new HoldButtonControl(command));

            case MappingInteractionMode.Direct:
            case MappingInteractionMode.Reset:
                return(new DirectButtonControl(command));

            case MappingInteractionMode.Increment:
            case MappingInteractionMode.Decrement:
                if (command.GetType().InheritsOrImplements(typeof(FloatInCommand <>)))
                {
                    return(new FloatDecIncButtonControl(command));
                }
                else
                {
                    return(new IntDecIncButtonControl(command));
                }

            default:
                return(null);
            }
        }
Example #9
0
        private void btnDrvClose_Click(object sender, EventArgs e)
        {
            ACommand command = CUIManager.Inst.GetCommand("REQUEST");

            command.SubCommandName = "YESDRVCLOSE";
            command.Execute();
        }
        /// <summary>
        /// Do handshake for server side.
        /// </summary>
        /// <param name="serverSocket"> Socket from client side to server side</param>
        /// <returns>null if handShake fail otherwise retur instance of AProtocol</returns>
        public async Task <AProtocol> HandShakeServer(SuperNetworkStream serverSocket)
        {
            ACommand shoudBeHELLO = GetCommand(await serverSocket.ReadLineAsync());

            if (shoudBeHELLO is HelloCommand)
            {
                String       selectedProtocolLabel;
                HelloCommand hello    = (HelloCommand)shoudBeHELLO;
                AProtocol    protocol = ServerConfig.PROTOCOL_FACTORY.GetProtocol(out selectedProtocolLabel, hello.SUPPORTED_PROTOCOLS);
                if (protocol != null)
                {
                    OllehCommand olleh = new OllehCommand(selectedProtocolLabel);
                    await olleh.SendAsync(serverSocket);

                    ACommand shoudBeACK = GetCommand(await serverSocket.ReadLineAsync());
                    if (shoudBeACK is AckCommand)
                    {
                        return(protocol);
                    }
                    else
                    {
                        printIfErrorElseSendMessage(shoudBeACK, "Handshake error. Expected HelloCommand but receive:" + shoudBeACK.GetType().Name, serverSocket);
                    }
                }
                await serverSocket.SendCommandAsync(new ErrorCommand(String.Format("Unsupported protocols '{0}'. Handshake failed.", hello.SUPPORTED_PROTOCOLS)));
            }
            else
            {
                printIfErrorElseSendMessage(shoudBeHELLO, "Handshake error. Expected HelloCommand but receive:" + shoudBeHELLO.GetType().Name, serverSocket);
            }

            return(null);
        }
Example #11
0
        private void btnProc_Click(object sender, EventArgs e)
        {
            ACommand command = CUIManager.Inst.GetCommand("REQUEST");

            command.SubCommandName = "READ_PROCESSING_GLASSDATA";
            command.Execute();
        }
Example #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow oRow in dgvAlarmView.SelectedRows)
            {
                //oRow.Cells["colTime"].Value;
                string code = oRow.Cells["colAlarmId"].Value.ToString();

                int eqpAlarmCode = 0;
                int.TryParse(code, out eqpAlarmCode);

                eqpAlarmCode = eqpAlarmCode - 30000;
                //oRow.Cells["colType"].Value;
                //oRow.Cells["colPosition"].Value;
                //oRow.Cells["colMessage"].Value;
                string clearable = oRow.Cells["colClearable"].Value.ToString();

                if (clearable == "Y")
                {
                    ACommand command = CUIManager.Inst.GetCommand("REQUEST");
                    command.SubCommandName = "ALARM_RESET";
                    command.AddParameter("ALARM_CODE", eqpAlarmCode.ToString());
                    command.Execute();
                }
            }
        }
Example #13
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "")
            {
                MessageBox.Show("PPID Select Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            foreach (DataGridViewRow item in dgvPPIDRecipeMapView.Rows)
            {
                if (item.Cells["colPPID"].Value.ToString() == comboBox1.Text)
                {
                    MessageBox.Show("PPID Duplication Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            ACommand command = CUIManager.Inst.GetCommand("REQUEST");

            command.AddParameter("PPID", comboBox1.Text);
            command.AddParameter("RECIPEID", comboBox2.Text);
            command.AddParameter("PPCINFO", "1");
            command.AddParameter("TIME", DateTime.Now.ToString());
            command.AddParameter("USER", textBox2.Text);
            command.AddParameter("DESC", textBox1.Text);
            command.SubCommandName = "PPID_MAP_REPORT";
            command.Execute();
        }
Example #14
0
        private void btnReceve_Click(object sender, EventArgs e)
        {
            ACommand command = CUIManager.Inst.GetCommand("REQUEST");

            command.SubCommandName = "READ_RECEIVED_GLASSDATA";
            command.Execute();
        }
Example #15
0
        private void btnUploadRecipe_Click(object sender, EventArgs e)
        {
            ACommand command = CUIManager.Inst.GetCommand("REQUEST");

            command.SubCommandName = "RECIPE_UPLOAD";
            command.Execute();
        }
Example #16
0
        void OnMenuButtonCliceked(object sender, EventArgs e)
        {
            try
            {
                string        service = this.Name.ToString();
                List <object> args    = new List <object>();

                if (sender is Control)
                {
                    Control control = sender as Control;
                    args.Add(control.Name);

                    switch (control.Name)
                    {
                    case "lblCurrentUser":
                        args.Add(lblCurrentUser.Text);
                        break;

                    case "btnClose":
                        ACommand command = CUIManager.Inst.GetCommand("TITLE");
                        command.SubCommandName = "SHUTDOWN";
                        command.Execute();
                        break;
                    }
                }

                this.OnRequest(this.Name.ToString(), args.ToArray());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// Updater sensor data, especially gyro sensor, device information of Ev3Brick sent
        /// by GetGyroSensor command.
        /// </summary>
        /// <param name="Command">GetGyroSensor command data.</param>
        /// <param name="Brick">Ev3Brick object to set received data.</param>
        public override void Update(ACommand Command, Ev3Brick Brick)
        {
            Debug.Assert(Command != null);
            Debug.Assert(Brick != null);

            if (Command is Command_50_01)
            {
                int Index        = 0;
                int DataTopIndex = 4;
                int DevNum       = Command.ResData[DataTopIndex++];
                for (Index = 0; Index < DevNum; Index++)
                {
                    int   DataIndex = DataTopIndex + (Index * 3);
                    byte  Port      = Command.ResData[DataIndex++];
                    short Velocity  = (short)
                                      ((ushort)Command.ResData[DataIndex] +
                                       (((ushort)Command.ResData[DataIndex + 1]) << 8));
                    var Device = Brick.SensorDevice(Port);
                    Device.ConnectedPort = (Ev3Device.INPORT)Port;
                    Device.IsConnected   = true;
                    Device.Value2        = Velocity;
                    Device.DeviceType    = Ev3SensorDevice.DEVICE_TYPE.SENSOR_DEVICE_GYRO;
                }
            }
        }
        private void btnConfirm_Click_1(object sender, EventArgs e)
        {
            List <string>          ids  = new List <string>();
            List <DataGridViewRow> rows = new List <DataGridViewRow>();

            foreach (DataGridViewRow row in dgvListView.Rows)
            {
                Dictionary <string, string> values = new Dictionary <string, string>();
                values.Add("MESSAGE_ID", row.Cells["colID"].Value.ToString());
                values.Add("TOUCH_PANLE_NO", "1");
                //ACommand command = CUIManager.Inst.GetCommand("REQUEST");
                //command.SubCommandName = "MESSAGE_CONFIRM";
                //command.Execute(values);

                rows.Add(row);
            }

            foreach (DataGridViewRow row in rows)
            {
                dgvListView.Rows.Remove(row);
            }

            dgvListView.Rows.Clear();

            //            _main.SendData(new List<string>() { "CIM_MESSAGE_ON", "O", tmpMsg });

            ACommand command = CUIManager.Inst.GetCommand("REQUEST");

            command.SubCommandName = "MESSAGE_ALLCLEAR";
            command.Execute();
        }
Example #19
0
            public virtual int Update(ACommand Command, Ev3Brick Brick, int Port, int StartIndex)
            {
                Brick.SensorDevice(Port).ConnectedPort = (Ev3Device.INPORT)Port;
                Brick.SensorDevice(Port).IsConnected   = true;

                return(2);
            }
Example #20
0
        private void btnInitIF_Click(object sender, EventArgs e)
        {
            ACommand command = CUIManager.Inst.GetCommand("REQUEST");

            command.SubCommandName = "STAGE_LINK_SIGNAL_INIT";
            command.Execute();
        }
Example #21
0
        private void btnSentOut_Click(object sender, EventArgs e)
        {
            ACommand command = CUIManager.Inst.GetCommand("REQUEST");

            command.SubCommandName = "READ_SENTOUT_GLASSDATA";
            command.Execute();
        }
Example #22
0
        private void AddCommand()
        {
            string            controlName1 = "EPM01";
            string            controlName2 = "INDEXER01";
            CControlComponent componet1    = _main.GetComponent(controlName1);
            CControlComponent componet2    = _main.GetComponent(controlName2);

            ACommand     command = null;
            ObjectHandle oh      = null;

            oh      = Activator.CreateInstanceFrom("YANGSYS.Biz.WHTM.dll", "YANGSYS.Biz.CommandHandler.CMenuGroupCommand");
            command = oh.Unwrap() as ACommand;
            command.AddArgs(new object[] { _main, componet1 }, false);
            command.Init(); CUIManager.Inst.AddCommand(command);
            oh      = Activator.CreateInstanceFrom("YANGSYS.Biz.WHTM.dll", "YANGSYS.Biz.CommandHandler.CShutdownCommand");
            command = oh.Unwrap() as ACommand;
            command.AddArgs(new object[] { _main, componet1 }, false);
            command.Init(); CUIManager.Inst.AddCommand(command);
            oh      = Activator.CreateInstanceFrom("YANGSYS.Biz.WHTM.dll", "YANGSYS.Biz.CommandHandler.CTitleGroupCommand");
            command = oh.Unwrap() as ACommand;
            command.AddArgs(new object[] { _main, componet1 }, false);
            command.Init(); CUIManager.Inst.AddCommand(command);
            oh      = Activator.CreateInstanceFrom("YANGSYS.Biz.WHTM.dll", "YANGSYS.Biz.CommandHandler.CRequestGroupCommand");
            command = oh.Unwrap() as ACommand;
            command.AddArgs(new object[] { _main, componet1 }, false);
            command.Init(); CUIManager.Inst.AddCommand(command);
        }
Example #23
0
        private void EqpModeChange(int mode)
        {
            ACommand command = CUIManager.Inst.GetCommand("MENU");

            command.SubCommandName = "EQP_MODE_CHANGE";
            command.AddParameter("EQP_MODE", mode.ToString());
            command.Execute();
        }
Example #24
0
 public Node(double value, Board boards, ACommand cmd)
 {
     VisitCount = 0;
     Boards     = boards;
     Cmd        = cmd;
     Value      = value;
     Childs     = new List <Node>();
 }
Example #25
0
        private void ExchangeModeChange(bool exchangeMode)
        {
            ACommand command = CUIManager.Inst.GetCommand("MENU");

            command.SubCommandName = "EXCHANGE_MODE_CHANGE";
            command.AddParameter("EXCHANGE_MODE", exchangeMode.ToString());
            command.Execute();
        }
Example #26
0
        private void ExchangePossibleModeChange(bool value)
        {
            ACommand command = CUIManager.Inst.GetCommand("MENU");

            command.SubCommandName = "EXCHANGE_POSSIBLE_CHANGE";
            command.AddParameter("EXCHANGE_POSSIBLE", value.ToString());
            command.Execute();
        }
Example #27
0
        private void DownstreamInlineModeChange(bool value)
        {
            ACommand command = CUIManager.Inst.GetCommand("MENU");

            command.SubCommandName = "DOWNSTREAM_INLINE_MODE_CHANGE";
            command.AddParameter("DOWNSTREAM_INLINE_MODE", value.ToString());
            command.Execute();
        }
Example #28
0
        private void CIMModeChange(short cimMode)
        {
            ACommand command = CUIManager.Inst.GetCommand("MENU");

            command.SubCommandName = "CIM_MODE_CHANGE";
            command.AddParameter("CIM_MODE", cimMode.ToString());
            command.Execute();
        }
Example #29
0
        private void AutoRecipeModeChange(bool enable)
        {
            ACommand command = CUIManager.Inst.GetCommand("MENU");

            command.SubCommandName = "AUTO_RECIPE_CHANGE";
            command.AddParameter("AUTO_RECIPE_CHANGE", enable.ToString());
            command.Execute();
        }
Example #30
0
 public void SendCommand(ACommand cmd, bool update)
 {
     cmd.Send(this);
     if (update)
     {
         UpdateStatus();
     }
 }
Example #31
0
        public void RollbackMarkerIsWrittenOnRollback()
        {
            //Arrange
            var config = EngineConfiguration.Create().ForIsolatedTest();
            var store = new InMemoryCommandStore(config);
            store.Initialize();
            var target = new JournalAppender(1, new StreamJournalWriter(config, store.CreateJournalWriterStream));

            var command = new ACommand();
            command.Timestamp = DateTime.Now;
            target.Append(command);
            target.Append(command);

            //Act
            target.AppendRollbackMarker();

            //Assert
            Assert.AreEqual(3, store.GetJournalEntries().Count());
            Assert.AreEqual(1, store.GetJournalEntries().OfType<JournalEntry<RollbackMarker>>().Count());
            Assert.IsTrue(store.GetJournalEntries().Last() is JournalEntry<RollbackMarker>);
        }
 public void SetCommand(ACommand command)
 {
     this.command = command;
 }