Beispiel #1
0
        public bool editConnection(AntennaeRotatorConnectionSettings conn)
        {
            fConnectionParams fParams = new fConnectionParams(conn);

            fParams.ShowDialog(this);
            bool result = fParams.DialogResult == DialogResult.OK;

            if (result)
            {
                conn.jeromeParams.host = fParams.tbHost.Text.Trim();
                conn.jeromeParams.port = Convert.ToInt16(fParams.tbPort.Text.Trim());
                conn.name = fParams.tbName.Text.Trim();
                conn.jeromeParams.usartPort = Convert.ToInt16(fParams.tbUSARTPort.Text.Trim());
                conn.icon               = fParams.icon;
                conn.hwLimits           = fParams.chbHwLimits.Checked;
                conn.switchIntervals[0] = Convert.ToInt32(fParams.nudIntervalOn.Value);
                conn.switchIntervals[1] = Convert.ToInt32(fParams.nudIntervalOff.Value);
                writeConfig();
                if (conn.Equals(currentConnection))
                {
                    Icon = (Icon)Resources.ResourceManager.GetObject(CommonInf.icons[conn.icon]);
                }
            }
            return(result);
        }
Beispiel #2
0
 private void onDisconnect(object obj, DisconnectEventArgs e)
 {
     currentConnection = null;
     if (!closingFl)
     {
         this.Invoke((MethodInvoker) delegate
         {
             Text               = "Нет соединения";
             lCaption.Text      = "Нет соединения";
             Icon               = (Icon)Resources.ResourceManager.GetObject(CommonInf.icons[0]);
             miConnections.Text = "Соединения";
             if (connectionsDropdown != null)
             {
                 miConnections.DropDownItems.AddRange(connectionsDropdown);
             }
             miSetNorth.Visible                 = false;
             miCalibrate.Visible                = false;
             miConnectionGroups.Visible         = true;
             miIngnoreEngineOffMovement.Visible = false;
             timer.Enabled = false;
             targetAngle   = -1;
             pMap.Invalidate();
             offLimit();
         });
     }
 }
Beispiel #3
0
        public void loadConnection(int index)
        {
            if (currentConnection == config.connections[index])
            {
                return;
            }
            disconnect();

            currentConnection           = config.connections[index];
            formState.currentConnection = index;

            currentTemplate = getTemplate(currentConnection.deviceType);
            if (currentConnection.limitsSerialize != null)
            {
                currentConnection.limits = new Dictionary <int, int> {
                    { 1, currentConnection.limitsSerialize[0] },
                    { -1, currentConnection.limitsSerialize[1] }
                };
            }
            if (currentTemplate.adc != 0 && currentConnection.limits[1] == currentConnection.limits[-1])
            {
                currentConnection.calibrated = false;
            }

            writeConfig();

            System.Diagnostics.Debug.WriteLine("Rotator connnection loaded");
            connect();
            pMap.Refresh();
        }
Beispiel #4
0
        private void miNewConnection_Click(object sender, EventArgs e)
        {
            AntennaeRotatorConnectionSettings nConn = new AntennaeRotatorConnectionSettings();

            if (editConnection(nConn))
            {
                config.connections.Add(nConn);
                createConnectionMenuItem(config.connections.IndexOf(nConn));
                writeConfig();
            }
        }
Beispiel #5
0
        private void formSPfromConnection(int ci)
        {
            AntennaeRotatorConnectionSettings c = config.connections[ci];

            if (!c.formSize.IsEmpty)
            {
                this.DesktopBounds =
                    new Rectangle(c.formLocation, c.formSize);
                formSPmodified = false;
            }
        }
Beispiel #6
0
 private void onDisconnect(object obj, DisconnectEventArgs e)
 {
     timer.Enabled = false;
     if (adcTimer != null)
     {
         adcTimer.Change(Timeout.Infinite, Timeout.Infinite);
     }
     targetAngle  = -1;
     currentAngle = -1;
     encGrayVal   = -1;
     pMap.Invalidate();
     offLimit();
     if (e.requested && !controller.active)
     {
         currentConnection = null;
         if (!closingFl)
         {
             formState.currentConnection = -1;
             writeConfig();
             this.Invoke((MethodInvoker) delegate
             {
                 Text               = "Нет соединения";
                 lCaption.Text      = "Нет соединения";
                 Icon               = (Icon)Resources.ResourceManager.GetObject(CommonInf.icons[0]);
                 miConnections.Text = "Соединения";
                 if (connectionsDropdown != null)
                 {
                     miConnections.DropDownItems.AddRange(connectionsDropdown);
                 }
                 miSetNorth.Visible  = false;
                 miCalibrate.Visible = false;
                 miIngnoreEngineOffMovement.Visible = false;
             });
         }
     }
     else
     {
         this.Invoke((MethodInvoker) delegate
         {
             Text              += " - нет соединения";
             lCaption.Text     += " - нет соединения";
             pMap.Enabled       = false;
             miSetNorth.Enabled = false;
             appContext.showNotification("AntennaNetRotator", currentConnection.name + ": соединение потеряно!", ToolTipIcon.Error);
         });
     }
 }
Beispiel #7
0
        public fConnectionParams(AntennaeRotatorConnectionSettings cSettings)
        {
            InitializeComponent();

            tbName.Text                = cSettings.name;
            tbHost.Text                = cSettings.jeromeParams.host;
            tbPort.Text                = cSettings.jeromeParams.port.ToString();
            tbUSARTPort.Text           = cSettings.jeromeParams.usartPort.ToString();
            tbPassword.Text            = cSettings.jeromeParams.password;
            nudIntervalOn.Value        = cSettings.switchIntervals[0];
            nudIntervalOff.Value       = cSettings.switchIntervals[1];
            cbDeviceType.SelectedIndex = cSettings.deviceType;
            chbHwLimits.Checked        = cSettings.hwLimits;
            tbESMHz.Text               = cSettings.esMhz.ToString();
            icon = cSettings.icon;


            displayIcon();
        }
Beispiel #8
0
 public FSetNorth(AntennaeRotatorConnectionSettings cs)
 {
     InitializeComponent();
     northAngle = cs.northAngle;
     if (cs.hwLimits)
     {
         bStop0.Enabled       = false;
         bStop1.Enabled       = false;
         bDeleteStops.Enabled = false;
     }
     else
     {
         limits = new Dictionary <int, int>(cs.limits);
     }
     _cs = cs;
     if (!cs.hwLimits)
     {
         bDeleteStops.Visible = false;
     }
 }
Beispiel #9
0
        private void loadConnection(int index)
        {
            currentConnection        = config.connections[index];
            config.currentConnection = index;
            if (!formSPmodified)
            {
                formSPfromConnection(index);
            }

            currentTemplate = getTemplate(currentConnection.deviceType);
            if (currentConnection.limitsSerialize != null)
            {
                currentConnection.limits = new Dictionary <int, int> {
                    { 1, currentConnection.limitsSerialize[0] },
                    { -1, currentConnection.limitsSerialize[1] }
                };
            }

            writeConfig();

            connect();
            pMap.Refresh();
        }