コード例 #1
0
 private void btnAssociate_Click(object sender, EventArgs e)
 {
     if (_selectedMotor == null)
     {
         return;
     }
     _selectedMotor.Stepper = (RampsSteppers)cbStepper.SelectedItem;
     _selectedMotor.Board   = (HardwareConfigBoard)cbBoard.SelectedItem;
     using (var state = GlobalState.GetState())
     {
         state.SaveConfiguration();
     }
 }
コード例 #2
0
        private void btnCalculateAngle_Click(object sender, EventArgs e)
        {
            if (_selectedMotor == null)
            {
                return;
            }

            using (var state = GlobalState.GetState())
            {
                _selectedMotor.DegreesFromMiddleToContact = _selectedMotor.Position * 360.0 / state.HardwareConfigGlobal.StepsPerMotorRotation / state.HardwareConfigGlobal.StepperDriverSubSteps / state.HardwareConfigGlobal.MotorReduction;
            }
            grid.Refresh();
        }
コード例 #3
0
        private void radio_CheckedChanged(object sender, EventArgs e)
        {
            var radio = sender as RadioButton;

            if (radio == null || !radio.Checked)
            {
                return;
            }

            using (var state = GlobalState.GetState())
            {
                SelectedMotor = GetByTag(state, radio.Tag);;
            }
        }
コード例 #4
0
        private Motor GetByTag(GlobalState state, object tag)
        {
            var couronneName = tag as string;

            Motor m;

            if (couronneName == null || couronneName.Length != 2)
            {
                return(null);
            }

            Axe a;

            if (!Enum.TryParse <Axe>(couronneName[0].ToString(), out a))
            {
                return(null);
            }

            int ic;

            if (!int.TryParse(couronneName[1].ToString(), out ic))
            {
                return(null);
            }

            Couronne c;

            switch (ic)
            {
            case 1:
                c = Couronne.MidMin;
                break;

            case 2:
                c = Couronne.MidMax;
                break;

            case 3:
                c = Couronne.Max;
                break;

            default:
                return(null);
            }

            return(state.Motors.Motors.FirstOrDefault((x) => x.Courronne == c && x.Axe == a));
        }
コード例 #5
0
        private void LED_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            using (var state = GlobalState.GetState())
            {
                var m = GetByTag(state, (sender as Control)?.Tag);

                if (m != null)
                {
                    if (m.Enabled)
                    {
                        Runner.DisableMotor(m);
                    }
                    else
                    {
                        Runner.EnableMotor(m);
                    }
                }
            }
        }
コード例 #6
0
        public void PeriodicUpdate(GlobalState formerState, GlobalState currentState)
        {
            var config = currentState.HardwareConfig(Index);

            lblTitle.Text = "Carte " + Index;

            if (Board.Connected)
            {
                ledConnected.Color = Color.Lime;
                btnConnect.Text    = "Déconnexion";
                lblConnect.Text    = "Connecté (" + config.COMPort + ", " + config.BaudRate + " bauds)";
            }
            else
            {
                ledConnected.Color = Color.Red;
                btnConnect.Text    = "Connexion";
                lblConnect.Text    = "Déconnecté";
            }

            grpMain.Enabled = Board.Connected;
        }
コード例 #7
0
        public void ImportConfiguration()
        {
            XmlSerializer xs = new XmlSerializer(typeof(GlobalState));

            using (StreamReader rd = new StreamReader("GlobalState.xml"))
            {
                GlobalState p = xs.Deserialize(rd) as GlobalState;
                this.HardwareConfig1      = p.HardwareConfig1;
                this.HardwareConfig2      = p.HardwareConfig2;
                this.HardwareConfigGlobal = p.HardwareConfigGlobal;
                this.VideoParameters      = p.VideoParameters;
                if (p.Motors?.Motors == null || p.Motors.Motors.Count == 0)
                {
                    this.Motors.Reset();
                }
                else
                {
                    this.Motors = p.Motors;
                }
            }
        }
コード例 #8
0
        private void PeriodicUpdate()
        {
            // get state
            GlobalState currentState;

            using (var state = GlobalState.GetState())
            {
                currentState = state.CloneState();
            }


            if (currentState.Alarms.Count > 0)
            {
                stripAlarm.Visible = true;
                var last = currentState.Alarms.Last();
                stripAlarm.Text        = "(" + currentState.Alarms.Count + ") " + last.Message;
                stripAlarm.ToolTipText = last.AdditionnalInfo;
            }
            else
            {
                stripAlarm.Visible = false;
            }

            strpAcq.Visible = stripAlarm.Visible;

            // Refresh HMI
            _viewer.PeriodicUpdate(_formerState, currentState);

            var right = navPnl.Controls.OfType <INavigableForm>().FirstOrDefault();

            if (right != null)
            {
                right.PeriodicUpdate(_formerState, currentState);
            }


            // update previous state
            _formerState = currentState;
        }
コード例 #9
0
        public static void Log(string message, TraceEventType level = TraceEventType.Information, string AdditionnalInfo = "")
        {
            _source.TraceEvent(level, id, message);

            if (!string.IsNullOrEmpty(AdditionnalInfo))
            {
                _source.TraceEvent(level, id, AdditionnalInfo);
            }

            if (level == TraceEventType.Error || level == TraceEventType.Warning || level == TraceEventType.Critical)
            {
                using (var state = GlobalState.GetState())
                {
                    var al = new Alarm();
                    al.Message         = message;
                    al.AdditionnalInfo = AdditionnalInfo;
                    state.Alarms.Add(al);
                }
            }

            id++;
        }
コード例 #10
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            byte[] buffer;

            using (var state = GlobalState.GetState())
            {
                buffer = state.InitialCube?.FaceColors?.Select((x) => (byte)x.ToString()[0]).ToArray();
            }

            if (buffer != null)
            {
                if (dlgSave.ShowDialog() == DialogResult.OK)
                {
                    using (var stream = dlgSave.OpenFile())
                    {
                        stream.Flush();

                        stream.Write(buffer, 0, buffer.Length);
                    }
                }
            }
        }
コード例 #11
0
 public void PeriodicUpdate(GlobalState formerState, GlobalState currentState)
 {
 }
コード例 #12
0
 public void PeriodicUpdate(GlobalState formerState, GlobalState currentState)
 {
     resolutionSessionSupervisionControl.PeriodicUpdate(currentState);
 }
コード例 #13
0
 public void PeriodicUpdate(GlobalState formerState, GlobalState currentState)
 {
     boardControl1.PeriodicUpdate(formerState, currentState);
     boardControl2.PeriodicUpdate(formerState, currentState);
 }