Beispiel #1
0
 private void PreInit()
 {
     CheckAxisPending    = true;
     AxisOptions         = null;
     TriggerOptions      = null;
     RecorderMode        = RecorderModeKinds.RecorderModeLocalOnly;
     LastRecorderMode    = RecorderModeKinds.RecorderModeIdle;
     CurrentSystemModeId = 0;
     LastSystemModeId    = 0xff;
     OptionsTab          = new Options(this);
     AxesTab             = new Axes(this);
     TriggersTab         = new Triggers(this);
     JobStorageTab       = new JobStorage(this);
     MotionTab           = new Motion(this);
     RecorderScope       = new RecorderChart(this);
     Controller          = new AxesController(this);
 }
Beispiel #2
0
        // Set the mode of the controller to the currently selected Recorder Action.
        public bool SetMode()
        {
            int index = RecorderAction.SelectedIndex;

            if (index < 0 || index >= (int)RecorderActionKinds.RecorderActionNum)
            {
                index = 0;
                RecorderAction.SelectedIndex = index;
            }
            RecorderActionKinds action = (RecorderActionKinds)index;

            if (Controller != null && (Controller.AxesReady || (action == RecorderActionKinds.RecorderActionIdle)))
            {
                // Convert RecorderAction {Idle,Play,Record} to RecorderModeKind.
                RecorderModeKinds mode = RecorderModeKinds.RecorderModeIdle;
                switch (action)
                {
                case RecorderActionKinds.RecorderActionPlay:
                    mode = RecorderModeKinds.RecorderModePlayStandby;
                    CurrentSystemModeId = 0;
                    break;

                case RecorderActionKinds.RecorderActionRecord:
                    mode = RecorderModeKinds.RecorderModeRecordStandby;
                    CurrentSystemModeId = 0;
                    break;

                default:
                    mode = RecorderModeKinds.RecorderModeIdle;
                    ++CurrentSystemModeId;
                    if (CurrentSystemModeId == 0)
                    {
                        CurrentSystemModeId = 1;
                    }
                    break;
                }
                // Send SetMode message, and let response set mode.
                Controller.IssueSetModeCommandToAll((byte)mode, CurrentSystemModeId);
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        // Here is where mode actions are taken.
        public void UpdateMode(byte mode, byte id)
        {
            if (Application.Current.Dispatcher.CheckAccess())
            {
                if (Controller != null && !IsClosing && mode < (byte)RecorderModeKinds.RecorderModeNum)
                {
                    RecorderMode = (RecorderModeKinds)mode;
                    if (LastRecorderMode == RecorderMode)
                    {
                        if ((RecorderMode != RecorderModeKinds.RecorderModeLocalOnly) &&
                            (RecorderMode != RecorderModeKinds.RecorderModeIdle) &&
                            (RecorderMode != RecorderModeKinds.RecorderModeIdleStopped)
                            )
                        {
                            return;
                        }
                        if (id == LastSystemModeId)
                        {
                            return;
                        }
                    }
                    LastSystemModeId = id;
                    lock (Controller.SchedulerLock) {
                        Controller.PlayIsSignalled   = false;
                        Controller.RecordIsSignalled = false;
                        switch (RecorderMode)
                        {
                        case RecorderModeKinds.RecorderModeLocalOnly:
                        case RecorderModeKinds.RecorderModeIdle:
                            // Switch chart back to normal mode.
                            // Reset chart cache.
                            RecorderScope.ResetCache();
                            RecorderScope.ResetSeries();
                            Controller.ResetTriggers();
                            // Reset timeline?
                            break;

                        case RecorderModeKinds.RecorderModePlayStandby:
                            // Copy pvt cache to chart cache setting actual pos to zero.
                            // Show static chart of current pvtCache.
                            Controller.CurrentPlayPVTCacheIndex = 0;
                            Controller.LastChartCacheIndex      = 0;
                            Controller.LastChartCacheTime       = 0.0;
                            Controller.LastStoppedTime          = 0.0;
                            RecorderScope.ResetCache();
                            RecorderScope.ResetSeries();
                            RecorderScope.ChartCache.DeepCopy(Controller.PVTCache);
                            RecorderScope.ChartCache.ZeroElements(1, AxesController.FIELDS_PER_AXIS);     // time,actual,target.
                            RecorderScope.ChartCache.RefreshMinMax();
                            RecorderScope.RenewChart();
                            Controller.ResetTriggers();
                            break;

                        case RecorderModeKinds.RecorderModePlaying:
                            // Start playback.
                            // TODO: unless resuming from a pause.
                            Controller.PlayIsSignalled = true;
                            break;

                        case RecorderModeKinds.RecorderModeRecordStandby:
                            // Reset chart cache & pvt cache?
                            // Reset timeline?
                            Controller.CurrentRecordStartTime = 0.0;
                            RecorderScope.ResetCache();
                            RecorderScope.ResetSeries();
                            Controller.PVTCache.Reset();
                            Controller.ResetTriggers();
                            break;

                        case RecorderModeKinds.RecorderModeRecording:
                            Controller.RecordIsSignalled = true;
                            // Make sure iso sending is active.
                            Controller.CheckMonitoringActive(true);
                            break;

                        case RecorderModeKinds.RecorderModeIdleStopped:
                            break;

                        case RecorderModeKinds.RecorderModePlayStopped:
                            // Rewind CurrentPlayPVTCacheIndex to LastStoppedTime.
                            Controller.RewindCurrentPlayPVTCacheIndex();
                            break;

                        case RecorderModeKinds.RecorderModeRecordStopped:
                            Controller.CurrentRecordStartTime = Controller.LastStoppedTime;
                            break;
                        }
                    }
                    LastRecorderMode          = RecorderMode;
                    RecorderStatus.Text       = RecorderModeMessages[(int)mode];
                    RecorderStatus.Background = RecorderModeBrushes[(int)mode];
                }
            }
            else
            {
                Application.Current.Dispatcher.Invoke((Action)(() => { UpdateMode(mode, id); }));
            }
        }