VarsState BuildCopy() { var st = new VarsState(); foreach (var item in Vars) { st.Vars[item.Key] = item.Value; } return(st); }
private CNCState(MachineParameters config, AxisState axisState, DrillingState drillingState, SyncToolState syncToolState, IReadOnlyDictionary <int, IToolState> ts, VarsState vs) { AxisState = axisState; toolStates = ts.ToDictionary(entry => entry.Key, entry => entry.Value); DrillingState = drillingState; SyncToolState = syncToolState; VarsState = vs; this.config = config; }
public CNCState(MachineParameters config) { AxisState = new AxisState { Feed = config.fastfeed / 60m, }; DrillingState = new DrillingState(); SyncToolState = new SyncToolState(); toolStates = new Dictionary <int, IToolState>(); VarsState = new VarsState(); foreach (var item in config.tools) { int id = item.Key; var driver = item.Value; if (driver is N700E_Tool) { toolStates[id] = new SpindleState(); } else if (driver is GPIO_Tool) { toolStates[id] = new BinaryState(); } else if (driver is RawModbus_Tool) { toolStates[id] = new BinaryState(); } else if (driver is Dummy_Tool) { toolStates[id] = null; } else { throw new ArgumentOutOfRangeException(); } } }