예제 #1
0
        public ControllerModel(string tableName, ITable table) : base(tableName, table)
        {
            if (controlModes == null)
            {
                FillControlModeOptions();
            }
            table.AddTableListenerOnSynchronizationContext(SynchronizationContext.Current, (modifiedTable, key, value, _) =>
            {
                switch (key)
                {
                case nameof(Mode):
                    Mode = (ControlMode)(int)(double)value;
                    break;

                case "Value":
                    ShowValue((double)value);
                    break;

                default:
                    break;
                }
            }, NetworkTables.NotifyFlags.NotifyImmediate | NetworkTables.NotifyFlags.NotifyUpdate | NetworkTables.NotifyFlags.NotifyNew);
            ZeroOutput = new Command(() => Numbers["Value"] = 0.0);
            ClearGraph = new Command(() =>
            {
                lock (syncRoot)
                {
                    OutputPoints.Clear();
                    SetpointLine.Clear();
                }
            });
        }
예제 #2
0
 private void ShowValue(double value)
 {
     // All missing modes do not require any special code.  They can just directly bind to [Value]
     switch (Mode)
     {
     case ControlMode.Position:
     case ControlMode.Speed:
     case ControlMode.Current:
         lock (syncRoot)
         {
             OutputPoints.Add(new OxyPlot.DataPoint(OutputPoints.Count, value));
             SetpointLine.Add(new OxyPlot.DataPoint(SetpointLine.Count, Setpoint));
         }
         break;
     }
 }