Example #1
0
 private void connect()
 {
     controller = JeromeController.create(currentConnection.jeromeParams);
     if (currentTemplate.uartEncoder)
     {
         controller.usartBytesReceived += usartBytesReceived;
     }
     controller.onDisconnected += onDisconnect;
     controller.onConnected    += onConnect;
     controller.usartBinaryMode = true;
     if (currentConnection.hwLimits)
     {
         controller.lineStateChanged += lineStateChanged;
     }
     controller.asyncConnect();
     updateGUI(
         delegate()
     {
         connectionsDropdown = new ToolStripMenuItem[miConnections.DropDownItems.Count];
         miConnections.Text  = "Отключиться";
         miConnections.DropDownItems.CopyTo(connectionsDropdown, 0);
         miConnections.DropDownItems.Clear();
         Text          = currentConnection.name + " идет соединение";
         lCaption.Text = Text;
         Icon          = (Icon)Resources.ResourceManager.GetObject(CommonInf.icons[currentConnection.icon]);
     });
 }
Example #2
0
 protected void connect(JeromeConnectionParams cp)
 {
     connections[cp].active     = true;
     connections[cp].controller = JeromeController.create(cp);
     connections[cp].controller.onDisconnected += controllerDisconnected;
     connections[cp].controller.onConnected    += controllerConnected;
     writeConfig();
     connections[cp].controller.asyncConnect();
 }
Example #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;
            }
        }
Example #4
0
 protected void connect(JeromeConnectionParams cp)
 {
     foreach (JeromeConnectionParams c in connections.Keys)
     {
         if (connections[c].active)
         {
             disconnect(c);
             menuControl[c].Checked = false;
         }
     }
     connections[cp].active     = true;
     connections[cp].controller = JeromeController.create(cp);
     connections[cp].controller.onDisconnected += controllerDisconnected;
     connections[cp].controller.onConnected    += controllerConnected;
     writeConfig();
     connections[cp].controller.asyncConnect();
     activeConnection = connections[cp];
 }
Example #5
0
        private void connect()
        {
            miConnections.Enabled = false;
            if (controller == null)
            {
                controller = JeromeController.create(currentConnection.jeromeParams);
            }
            UseWaitCursor = true;
            if (controller.connect())
            {
                miConnections.Text         = "Отключиться";
                controller.usartBinaryMode = true;
                if (currentConnection.hwLimits)
                {
                    controller.lineStateChanged += lineStateChanged;
                }
                controller.usartBytesReceived += usartBytesReceived;
                controller.disconnected       += onDisconnect;
                connectionsDropdown            = new ToolStripMenuItem[miConnections.DropDownItems.Count];
                miConnections.DropDownItems.CopyTo(connectionsDropdown, 0);
                miConnections.DropDownItems.Clear();

                miConnectionGroups.Visible = false;
                //miConnectionParams.Enabled = false;


                setLine(currentTemplate.ledLine, 0);
                foreach (int[] dir in currentTemplate.engineLines.Values)
                {
                    foreach (int line in dir)
                    {
                        setLine(line, 0);
                        toggleLine(line, 0);
                    }
                }
                setLine(currentTemplate.uartTRLine, 0);
                foreach (int line in currentTemplate.limitsLines.Values)
                {
                    setLine(line, 1);
                }

                timer.Enabled = true;

                miSetNorth.Visible = true;
                miSetNorth.Enabled = true;

                Text          = currentConnection.name;
                lCaption.Text = currentConnection.name;
                if (currentConnectionGroup != null)
                {
                    Text += " (" + currentConnectionGroup.name + ")";
                }
                Icon = (Icon)Resources.ResourceManager.GetObject(CommonInf.icons[currentConnection.icon]);
                if (currentConnection.hwLimits)
                {
                    string lines = controller.readlines();
                    foreach (KeyValuePair <int, int> kv in currentTemplate.limitsLines)
                    {
                        if (lines[kv.Value - 1] == '0')
                        {
                            onLimit(kv.Key);
                        }
                    }
                }
                else if (currentConnection.northAngle != -1)
                {
                    currentConnection.limits = new Dictionary <int, int> {
                        { 1, currentConnection.northAngle + 180 }, { -1, currentConnection.northAngle + 180 }
                    }
                }
                ;
                scheduleTimeoutTimer();
            }
            else
            {
                showMessage("Подключение не удалось", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            miConnections.Enabled = true;
            UseWaitCursor         = false;
        }
Example #6
0
 public WX0BController(WX0BControllerConfigEntry _config)
 {
     config      = _config;
     jConnection = JeromeController.create(config.connectionParams);
 }