Esempio n. 1
0
 private void updateController(WX0BTerminalSwitch sw)
 {
     if (sw != null && config.activeController != -1 && config.activeController < controllers.Count)
     {
         controllers[config.activeController].setLines(sw.controllerLinesState);
     }
 }
Esempio n. 2
0
        private void TerminalJControllerConnected(object sender, EventArgs e)
        {
            Invoke((MethodInvoker) delegate()
            {
                cbConnectTerminal.Checked = true;
                cbConnectTerminal.Image   = JeromeControl.Properties.Resources.icon_connected;
                fStatus.pTerminalStatus.BackgroundImage = JeromeControl.Properties.Resources.icon_connected;
            });
            foreach (WX0BTerminalSwitchTemplate st in TerminalTemplate.switches)
            {
                terminalJConnection.setLineMode(st.button, 1);
                terminalJConnection.setLineMode(st.led, 0);
            }
            terminalJConnection.setLineMode(TerminalTemplate.pttLED, 0);
            terminalJConnection.setLineMode(TerminalTemplate.lockLED, 0);
            terminalJConnection.setLineMode(TerminalTemplate.pttButton, 1);
            terminalJConnection.setLineMode(TerminalTemplate.lockButton, 1);
            displayActiveSwitch();
            displayLockSwitch();
            displayPTT();
            WX0BTerminalSwitch s = tx ? lockSwitch : activeSwitch;

            if (terminalJConnection.connected)
            {
                foreach (WX0BTerminalSwitchTemplate st in TerminalTemplate.switches)
                {
                    terminalJConnection.switchLine(st.led, switches[st] == s ? 1 : 0);
                }
            }
        }
Esempio n. 3
0
        public FWX0B(JCAppContext _appContext, int __idx) : base(_appContext, __idx)
        {
            appContext = _appContext;
            _idx       = __idx;
            InitializeComponent();
            fStatus = new FWX0BStatus(this);
            foreach (WX0BTerminalSwitchTemplate st in TerminalTemplate.switches)
            {
                switches[st] = new WX0BTerminalSwitch(st);
                if (st.isDefault)
                {
                    defaultSwitch = switches[st];
                    activeSwitch  = switches[st];
                }
            }
            defForeColor = cbConnectTerminal.ForeColor;
            if (config.terminalConnectionParams == null)
            {
                config.terminalConnectionParams = new JeromeConnectionParams();
            }
            updateTerminalConnectionParamsCaption();
            terminalJConnection                   = JeromeController.create(config.terminalConnectionParams);
            terminalJConnection.onConnected      += TerminalJControllerConnected;
            terminalJConnection.onDisconnected   += TerminalJControllerDisconnected;
            terminalJConnection.lineStateChanged += TerminalJConnectionLineStateChanged;
            foreach (WX0BControllerConfigEntry cConfig in config.controllers)
            {
                createController(cConfig);
            }
            if (config.terminalConnectionParams != null)
            {
                cbConnectTerminal.Enabled = true;
                if (config.terminalActive)
                {
                    //new System.Threading.Timer(new TimerCallback(x => connectTerminal()), null, 5000, Timeout.Infinite);*/
                    connectTerminal();
                }
            }
            else
            {
                cbConnectTerminal.Enabled = false;
            }
            if (config.activeController != -1 && config.activeController < controllers.Count)
            {
                controllers[config.activeController].jConnection.asyncConnect();
            }
            else
            {
                setActiveController(-1);
            }

            if (config.statusOnly)
            {
                WindowState = FormWindowState.Minimized;
            }
        }
Esempio n. 4
0
 private void switchLeds(WX0BTerminalSwitch oldSwitch, WX0BTerminalSwitch newSwitch)
 {
     if (terminalJConnection.connected)
     {
         if (oldSwitch != null)
         {
             terminalJConnection.switchLine(oldSwitch.template.led, 0);
         }
         if (newSwitch != null)
         {
             terminalJConnection.switchLine(newSwitch.template.led, 1);
         }
     }
 }
Esempio n. 5
0
 private void TerminalJConnectionLineStateChanged(object sender, LineStateChangedEventArgs e)
 {
     if (e.line == TerminalTemplate.pttButton)
     {
         if (e.state != pttState)
         {
             pttState = e.state;
             updateTX();
         }
     }
     else if (!tx && e.line == TerminalTemplate.lockButton)
     {
         if (e.state != lockButtonState)
         {
             lockButtonState = e.state;
             if (e.state == 0)
             {
                 lockSwitch = lockSwitch == null ? activeSwitch : null;
                 displayLockSwitch();
             }
         }
     }
     else if (!tx)
     {
         KeyValuePair <WX0BTerminalSwitchTemplate, WX0BTerminalSwitch> kv = switches.Where(x => x.Key.button == e.line).FirstOrDefault();
         if (kv.Key != null && kv.Value.lineState != e.state)
         {
             kv.Value.lineState = e.state;
             if (e.state == 0)
             {
                 switchLeds(activeSwitch, kv.Value);
                 activeSwitch = kv.Value;
                 displayActiveSwitch();
                 updateController(activeSwitch);
             }
         }
     }
 }