Exemplo n.º 1
0
        public bool Enable()
        {
            if (!com.Connected())
            {
                return(false);
            }

            com.Send("enable\n");

            return(true);
            //ip.Init(ipAddress, port);
            //return ip.Connected();
        }
Exemplo n.º 2
0
        // 疑似操作卓LEDスイッチとの同期(疑似操作卓とアプリの双方の操作のスイッチ操作を許し状態をLEDに反映させる/疑似操作卓のハードウェアスイッチ状態とソフトウェア上の状態(=LED表示)が一致しない場合を許す)
        void InterlockLedSwitch(bool[] Requests, bool[] PrevHardRequests, bool[] PrevSoftRequests, EnableButton[] Buttons)
        {
            bool LedUpdated = false;

            for (int i = 0; i < Requests.Length; i++)
            {
                if (Buttons[i] == null)
                {
                    continue;
                }
                if (Buttons[i].Enabled != PrevSoftRequests[i])
                {
                    // ソフト側で操作された⇒LEDに反映
                    PrevSoftRequests[i] = Buttons[i].Enabled;
                    LedUpdated          = true;
                }
                if (Requests[i] != PrevHardRequests[i])
                {
                    // ハード側で操作された⇒LEDに反映
                    PrevHardRequests[i] = Requests[i];
                    LedUpdated          = true;
                    // ハード側の要求操作とソフト側の現在の状態が違う⇒ソフト側に反映
                    if (Buttons[i].Enabled != Requests[i])
                    {
                        Buttons[i].Enabled = Requests[i];
                    }
                }
            }
            if (LedUpdated)
            {
                string message = "";
                for (int i = 0; i < 4; i++)
                {
                    message += string.Format("{0} ", (Buttons[i].Enabled ? 1 : 0));
                }
                com.Send(message);
            }
        }