private void strpAcq_Click(object sender, EventArgs e) { using (var state = GlobalState.GetState()) { state.Alarms.Clear(); } }
private void btnReset_Click(object sender, EventArgs e) { using (var state = GlobalState.GetState()) { state.InitialCube = new ColorCube(); } }
public void NavigueTo() { using (var state = GlobalState.GetState()) { resolutionSessionSupervisionControl.PeriodicUpdate(state); } }
private void sauvegarderToolStripMenuItem_Click(object sender, EventArgs e) { using (var state = GlobalState.GetState()) { state.SaveConfiguration(); } }
private void bwConnect_DoWork(object sender, DoWorkEventArgs e) { try { bool connect1, connect2; using (var state = GlobalState.GetState()) { connect1 = state.HardwareConfig1.ConnectAtStartup; connect2 = state.HardwareConfig2.ConnectAtStartup; } if (connect1) { Hardware.Runner.Board1.Connect(); } if (connect2) { Hardware.Runner.Board2.Connect(); } } catch (Exception ex) { Logger.Log(ex); } }
private void CubePartControl_MouseDown(object sender, MouseEventArgs e) { if (!Clickable) { return; } using (var state = GlobalState.GetState()) { Color nextColor = Color.White; for (var i = 0; i < ColorCube.colorDictionary.Count - 1; i++) { if (state.InitialCube.colors[_index] == ColorCube.colorDictionary.Values.ElementAt(i)) { var nextI = i + (e.Button == MouseButtons.Left ? 1 : -1); if (nextI == ColorCube.colorDictionary.Count - 1) { nextI = 0; } else if (nextI == -1) { nextI = ColorCube.colorDictionary.Count - 2; } nextColor = ColorCube.colorDictionary.Values.ElementAt(nextI); break; } } var newCube = state.InitialCube.CloneCube(); newCube.colors[_index] = nextColor; state.InitialCube = newCube; PeriodicUpdate(newCube); } }
private void btnRand_Click(object sender, EventArgs e) { var cube = new Cube(); var rand = new Random(); var twists = new List <Twist>(); for (int i = 0; i < 100; i++) { var t = Twist.Twists[rand.Next(0, Twist.Twists.Length - 1)]; cube.twist(t); twists.Add(t); // ce modèle ne respecte pas la norme où les movement u,l,d,r,b bougent 2 couronnes. Ici la fonction twist n'en bouge qu'une. Le 2eme est bougé artificiellement if (char.IsLower(t.Name[0])) { var t2 = Twist.Twists.First(x => x.Name == t.Name.ToUpper()); cube.twist(t2); } } var colorCube = new ColorCube(); colorCube.setColors(cube); using (var state = GlobalState.GetState()) { state.InitialCube = colorCube; } }
public void RefreshCube() { using (var state = GlobalState.GetState()) { RefreshCube(state.InitialCube); } }
private void btnImport_Click(object sender, EventArgs e) { if (dlgOpen.ShowDialog() == DialogResult.OK) { var cube = new ColorCube(); using (var stream = dlgOpen.OpenFile()) { for (int i = 0; i < 4 * 4 * 6; i++) { var b = stream.ReadByte(); if (b < 0) { break; } Faces face; if (Enum.TryParse <Faces>(((char)b).ToString(), out face)) { cube.colors[i] = ColorCube.colorDictionary[face]; } } } using (var state = GlobalState.GetState()) { state.InitialCube = cube; } } }
public MainForm() { Instance = this; InitializeComponent(); _viewer = new CubeViewer(); splitter.Panel2.Controls.Add(_viewer); _viewer.Dock = DockStyle.Fill; using (var state = GlobalState.GetState()) { state.ImportConfiguration(); _formerState = state.CloneState(); } FormManager.Init(); foreach (var form in FormManager.Forms.OrderBy((x) => x.Value.Index)) { var tooltip = new ToolStripButton(); tooltip.Image = form.Value.Image; tooltip.Name = form.Key.Name + "tooltip"; tooltip.Text = form.Value.FormName; toolStrip2.Items.Add(tooltip); tooltip.Click += (object o, EventArgs e) => FormManager.Navigate(form.Value); tooltip.DragOver += (object o, DragEventArgs e) => { }; tooltip.DragLeave += (object o, EventArgs e) => { }; } FormManager.Navigate <ColorDefinitionControl>(); bwConnect.RunWorkerAsync(); }
public void NavigueTo() { using (var state = GlobalState.GetState()) { InitializeCornerCube(state.InitialCube); } }
private void cbBoard_SelectedIndexChanged(object sender, EventArgs e) { if (!chkIdent.Checked) { return; } var Stepper = (RampsSteppers)cbStepper.SelectedItem; var Board = (HardwareConfigBoard)cbBoard.SelectedItem; using (var state = GlobalState.GetState()) { var motor = state.Motors.Motors.FirstOrDefault((x) => x.Stepper == Stepper && x.Board == Board); if (motor == null) { return; } foreach (var radio in pnlImg.Controls.OfType <RadioButton>()) { var radioMotor = GetByTag(state, radio.Tag); if (radioMotor == null) { continue; } else if (radioMotor.Board == Board && radioMotor.Stepper == Stepper) { radio.Checked = true; return; } } } }
private void grid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { using (var state = GlobalState.GetState()) { state.SaveConfiguration(); } }
public void NavigueTo() { using (var state = GlobalState.GetState()) { pgHard1.SelectedObject = state.HardwareConfig1.Clone(); pgHard2.SelectedObject = state.HardwareConfig2.Clone(); pgGlobal.SelectedObject = state.HardwareConfigGlobal.Clone(); } }
private void btnAcq_Click(object sender, EventArgs e) { using (var state = GlobalState.GetState()) { state.Alarms.Clear(); } FormManager.Previous(); }
private void Save() { using (var state = GlobalState.GetState()) { state.HardwareConfig1 = (HardwareConfig)pgHard1.SelectedObject; state.HardwareConfig2 = (HardwareConfig)pgHard2.SelectedObject; state.HardwareConfigGlobal = (HardwareConfigGlobal)pgGlobal.SelectedObject; state.SaveConfiguration(); } }
private void btnSetAllPosMaxStop_Click(object sender, EventArgs e) { using (var state = GlobalState.GetState()) { foreach (var m in state.Motors.Motors) { Runner.SetCurrentPosition(m, m.StepsToPositivePosition); } } }
private void btnMoveAll_Click(object sender, EventArgs e) { using (var state = GlobalState.GetState()) { foreach (var m in state.Motors.Motors) { Runner.BeginMoveStep(m, (int)udMoveAll.Value); } } }
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(); }
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(); } }
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);; } }
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); } } } }
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; }
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); } } } }
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++; }