예제 #1
0
        protected void controllerConnected(object sender, EventArgs e)
        {
            bool senderFound = false;
            KeyValuePair <JeromeConnectionParams, JeromeConnectionState> senderEntry =
                connections.FirstOrDefault(x => x.Value.controller == sender && (senderFound = true));

            if (!senderFound)
            {
                return;
            }
            JeromeConnectionParams cp = senderEntry.Key;

            this.Invoke((MethodInvoker) delegate
            {
                connections[cp].watch   = false;
                menuWatch[cp].Visible   = false;
                menuWatch[cp].Checked   = false;
                menuControl[cp].Checked = true;
                this.Text = cp.name;
                updateButtonsMode();
                string linesState = connections[cp].controller.readlines();
                for (var c = 0; c < lines.Count(); c++)
                {
                    connections[cp].controller.setLineMode(lines[c], 0);
                    buttons[c].Checked = linesState[lines[c] - 1] == '1';
                }
                connections[cp].controller.setLineMode(enLine, 0);
                connections[cp].controller.switchLine(enLine, 1);
                connections[cp].controller.setLineMode(clkLine, 0);
                connections[cp].controller.switchLine(clkLine, 0);
            });
        }
예제 #2
0
        protected void connectionCreated(object obj, EventArgs e)
        {
            JeromeConnectionParams c = (JeromeConnectionParams)obj;

            connections[c] = new JeromeConnectionState();
            createConnectionMI(c);
            writeConfig();
        }
예제 #3
0
        protected void connectionEdited(object obj, EventArgs e)
        {
            JeromeConnectionParams c = (JeromeConnectionParams)obj;

            menuControl[c].Text = c.name;
            c.usartPort         = 0;
            writeConfig();
        }
예제 #4
0
        protected void connectionEdited(object obj, EventArgs e)
        {
            JeromeConnectionParams c = (JeromeConnectionParams)obj;

            menuControl[c].Text = connections[c].active ? "Отключиться от " + c.name : c.name;
            menuWatch[c].Text   = c.name;
            writeConfig();
        }
예제 #5
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();
 }
예제 #6
0
        protected void connectionCreated(object obj, EventArgs e)
        {
            JeromeConnectionParams c = (JeromeConnectionParams)obj;

            connections[c] = new JeromeConnectionState();
            createConnectionMI(c);
            miRelaySettings.Enabled = true;
            writeConfig();
        }
예제 #7
0
 protected void disconnect(JeromeConnectionParams c)
 {
     if (connections[c].controller != null)
     {
         connections[c].controller.disconnect();
     }
     connections[c].active = false;
     writeConfig();
 }
예제 #8
0
        protected void controllerConnected(object sender, EventArgs e)
        {
            bool senderFound = false;
            KeyValuePair <JeromeConnectionParams, JeromeConnectionState> senderEntry =
                connections.FirstOrDefault(x => x.Value.controller == sender && (senderFound = true));

            if (!senderFound)
            {
                return;
            }
            JeromeConnectionParams cp = senderEntry.Key;

            this.Invoke((MethodInvoker) delegate
            {
                connections[cp].watch   = false;
                menuControl[cp].Checked = true;
                this.Text = cp.name;
                updateButtonsMode();
            });
            JeromeController controller = connections[cp].controller;
            string           linesState = controller.readlines();

            controller.setLineMode(controllerTemplate.dir, 0);
            controller.setLineMode(controllerTemplate.pulse, 0);
            controller.setLineMode(controllerTemplate.enable, 0);
            controller.setLineMode(controllerTemplate.ptt, 0);
            controller.switchLine(controllerTemplate.enable, 1);
            controller.switchLine(controllerTemplate.pulse, 0);
            controller.switchLine(controllerTemplate.ptt, 0);
            for (int co = 0; co < controllerTemplate.relays.Length; co++)
            {
                controller.setLineMode(controllerTemplate.relays[co], 0);
                controller.switchLine(controllerTemplate.relays[co], 0);
            }
            foreach (int line in controllerTemplate.limits.Values)
            {
                controller.setLineMode(line, 1);
            }
            controller.lineStateChanged += controllerLineStateChanged;
            if (linesState[controllerTemplate.limits[-1] - 1] == '0')
            {
                limit = -1;
            }
            else if (linesState[controllerTemplate.limits[1] - 1] == '0')
            {
                limit = 1;
            }
            if (position == -1)
            {
                rotate(0);
            }
        }
예제 #9
0
 private void cbConnection_SelectedIndexChanged(object sender, EventArgs e)
 {
     connection = _lConnections[cbConnection.SelectedIndex];
     for (int co = 0; co < cbLines.Count(); co++)
     {
         if (_connections[connection].lines.Count() > co)
         {
             cbLines[co].SelectedIndex = _connections[connection].lines[co] - 1;
         }
         else
         {
             cbLines[co].SelectedIndex = -1;
         }
     }
 }
예제 #10
0
        protected void connectionDeleted(object obj, EventArgs e)
        {
            JeromeConnectionParams c = (JeromeConnectionParams)obj;

            if (connections[c].active)
            {
                MessageBox.Show("Нельзя удалить активное соединение! Изменения не будут сохранены");
            }
            else
            {
                connections.Remove(c);
                miControl.DropDownItems.Remove(menuControl[c]);
                menuControl.Remove(c);
                writeConfig();
            }
        }
예제 #11
0
        protected void controllerDisconnected(object obj, DisconnectEventArgs e)
        {
            JeromeConnectionParams c = ((JeromeController)obj).connectionParams;

            this.Invoke((MethodInvoker) delegate
            {
                if (e.requested)
                {
                    menuControl[c].Checked = false;
                    this.Text = "Ant Comm";
                }
                else
                {
                    this.Text = "Disconnected!";
                }
                updateButtonsMode();
            });
        }
예제 #12
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];
 }
예제 #13
0
        protected void controllerDisconnected(object obj, DisconnectEventArgs e)
        {
            JeromeConnectionParams c = ((JeromeController)obj).connectionParams;

            this.Invoke((MethodInvoker) delegate
            {
                if (e.requested)
                {
                    menuControl[c].Checked = false;
                    this.Text = "Ant Comm";
                }
                else
                {
                    this.Text = "Disconnected!";
                    appContext.showNotification("NetComm", c.name + ": соединение потеряно!", ToolTipIcon.Error);
                }
                updateButtonsMode();
            });
        }
예제 #14
0
        protected void createConnectionMI(JeromeConnectionParams c)
        {
            ToolStripMenuItem mi = new ToolStripMenuItem();

            mi.Text    = c.name;
            mi.Visible = !connected;
            mi.Click  += delegate(object sender, EventArgs e)
            {
                if (connections[c].active)
                {
                    disconnect(c);
                }
                else
                {
                    connect(c);
                }
            };
            miControl.DropDownItems.Add(mi);
            menuControl[c] = mi;
        }
예제 #15
0
 private void bTerminalConnectionParams_Click(object sender, EventArgs e)
 {
     if (config.terminalConnectionParams == null)
     {
         JeromeConnectionParams nc = new JeromeConnectionParams();
         if (nc.edit())
         {
             config.terminalConnectionParams = nc;
             cbConnectTerminal.Enabled       = true;
             writeConfig();
         }
     }
     else
     {
         if (config.terminalConnectionParams.edit())
         {
             writeConfig();
         }
     }
     updateTerminalConnectionParamsCaption();
 }
예제 #16
0
 private void bConnectionParams_Click(object sender, EventArgs e)
 {
     if (controller.config.connectionParams == null)
     {
         JeromeConnectionParams nc = new JeromeConnectionParams();
         if (nc.edit())
         {
             controller.config.connectionParams = nc;
             cbConnect.Enabled = true;
             fWX0B.writeConfig();
         }
     }
     else
     {
         if (controller.config.connectionParams.edit())
         {
             fWX0B.writeConfig();
         }
     }
     updateConnectionParamsCaption();
 }
예제 #17
0
        protected void createConnectionMI(JeromeConnectionParams c, bool watch)
        {
            ToolStripMenuItem mi = new ToolStripMenuItem();

            mi.Text = c.name;
            if (watch)
            {
                mi.Visible      = true;
                mi.CheckOnClick = true;
                mi.Checked      = connections[c].watch;
                mi.Click       += delegate(object sender, EventArgs e)
                {
                    connections[c].watch = !connections[c].watch;
                    writeConfig();
                };
                miWatch.DropDownItems.Add(mi);
                menuWatch[c] = mi;
            }
            else
            {
                mi.Visible = true;
                mi.Click  += delegate(object sender, EventArgs e)
                {
                    if (connections[c].active)
                    {
                        connections[c].controller.disconnect();
                        connections[c].active = false;
                        writeConfig();
                    }
                    else
                    {
                        connect(c);
                    }
                };
                miControl.DropDownItems.Add(mi);
                menuControl[c] = mi;
            }
        }
예제 #18
0
 protected void createConnectionMI(JeromeConnectionParams c)
 {
     createConnectionMI(c, true);
     createConnectionMI(c, false);
 }