Esempio n. 1
0
 private void SpindleState_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     _rpmDisplay = _spindleStatePrev == GCode.SpindleState.Off ? _rpmInput : _rpm;
     if (!(SpindleState.Value.HasFlag(GCode.SpindleState.Off | GCode.SpindleState.CW) || SpindleState.Value.HasFlag(GCode.SpindleState.Off | GCode.SpindleState.CCW)))
     {
         OnPropertyChanged(nameof(SpindleState));
         OnPropertyChanged(nameof(RPM));
         _spindleStatePrev = SpindleState.Value;
     }
 }
 void rbSpindleState_CheckedChanged(object sender, EventArgs e)
 {
     if (!silent)
     {
         RadioButton rb = (RadioButton)sender;
         if (rb.Checked)
         {
             _state = rb.Name == "rbSpindleCW" ? SpindleState.CW : (rb.Name == "rbSpindleCCW" ? SpindleState.CCW :  SpindleState.Off);
             if (CommandGenerated != null)
             {
                 CommandGenerated(string.Format((string)rb.Tag, "S" + this.txtRPM.Text));
             }
         }
     }
     txtRPM.ReadOnly = _state != SpindleState.Off;
 }
        private CNCState.CNCState CommitTool(int tool_id,
                                             ActionProgram.ActionProgram program,
                                             CNCState.CNCState state)
        {
            IAction action = null;
            IDriver driver = tool_drivers[tool_id];

            if (driver is N700E_driver n700e)
            {
                SpindleState ss = state.ToolStates[tool_id] as SpindleState;
                action = n700e.CreateAction(ss.RotationState, ss.SpindleSpeed);
            }
            else if (driver is GPIO_driver gpio)
            {
                BinaryState bs = state.ToolStates[tool_id] as BinaryState;
                action = gpio.CreateAction(bs.Enabled);
            }
            else if (driver is RawModbus_driver modbus)
            {
                BinaryState bs = state.ToolStates[tool_id] as BinaryState;
                action = modbus.CreateAction(bs.Enabled);
            }
            else if (driver is Dummy_driver dummy)
            {
                action = dummy.CreateAction();
            }
            else
            {
                throw new InvalidOperationException("invalid driver: " + driver);
            }

            if (action != null)
            {
                program.AddAction(action, state, state);
                return(state);
            }
            else
            {
                return(state);
            }
        }