예제 #1
0
 public OsciloscopeFullScreen(IAllowsShowingGraphFullScreen callOnExit)
 {
     DataContext = VM_SciChartOsciloscope.MakeNew(null);
     InitializeComponent();
     Unloaded += (a, e) => {
         if (callOnExit != null)
         {
             callOnExit.CanOpenGraphFullScreen = true;
         }
     };
 }
 public static void Restore(string fileName, VM_SciChartOsciloscope vmsci)
 {
     for (int i = 0; i < 5; i++)
     {
         try {
             ReadHistoryFile(getFullFilePath(fileName), vmsci);
             break;
         } catch (Exception e) {
             Globals.StopReadingHIstoryFile = true;
             Thread.Sleep(100);
         }
     }
 }
예제 #3
0
        public UI_HistoryAdvanced(VM_SciChartOsciloscope sci)
        {
            vm_sciChartOsciloscope = sci;
            InitializeComponent();
            List <string> comboItems = SaveToDisk.getHistoryValues();

            foreach (var comboItem in comboItems)
            {
                combo.Items.Add(comboItem);
            }
            if (comboItems.Count != 0)
            {
                combo.SelectedItem = comboItems[0];
            }
        }
        public static void SendCCComand(int ccValue = 60, VM_SciChartOsciloscope vm_sci = null)
        {
            FrequencyManager.ccValue = (byte)ccValue;

            List <Tuple <VM_SciChartOsciloscope, uint> > restore =
                Globals.Vm_scis
                .Select(w => new Tuple <VM_SciChartOsciloscope, uint>(w, w.PlotTime))
                .ToList();

            Frequency = 1 / ((6.0 / ccValue));
            foreach (var tuple in restore)
            {
                tuple.Item1.PlotTime = tuple.Item2;
                tuple.Item1.SynchronizeFrequency(vm_sci);
            }
            CAN_Common.WriteToAll("CC", 0, false, false, (ccValue * 3).ToString());
        }
예제 #5
0
        public UI_HistoryChooser(VM_SciChartOsciloscope sci)
        {
            vm_sciChartOsciloscope = sci;
            InitializeComponent();
            List <string> comboItems = SaveToDisk.getHistoryValues();

            foreach (var comboItem in comboItems)
            {
                combo.Items.Add(comboItem);
            }
            if (comboItems.Count != 0)
            {
                if (selectedIndex != -1 && comboItems.Count > selectedIndex)
                {
                    combo.SelectedItem = comboItems[selectedIndex];
                }
                else
                {
                    combo.SelectedItem = comboItems[comboItems.Count - 1];
                }
            }
        }
예제 #6
0
        public SciChartOsciloscope()
        {
            //DataContext = new VM_SciChartOsciloscope();

            InitializeComponent();
            oscilloscopeChart.ZoomExtentsCommand = null;

            Loaded += (a, e) => {
                if (!DesignerProperties.GetIsInDesignMode(this))
                {
                    _dataContext = ((VM_SciChartOsciloscope)DataContext);
                    _dataContext.sciChartSurface         = oscilloscopeChart;
                    oscilloscopeChart.MouseDoubleClick  += MouseDoubleClicked;
                    oscilloscopeChart.MouseLeftButtonUp += OscilloscopeChart_OnMouseLeftButtonUp;
                    Unloaded += (b, c) => ((VM_SciChartOsciloscope)DataContext).Dispose();

#if !DEBUG
                    btn_stop.Visibility = Visibility.Collapsed;
#else
                    oscilloscopeChart.Rendered += oscilloscopeChart_Rendered;
#endif
                }
            };
        }
        private static void ReadHistoryFile(string fileFullPath, VM_SciChartOsciloscope vmsci)
        {
            float min = -1, max;

            using (FileStream rd = new FileStream(
                       fileFullPath, FileMode.Open, FileAccess.Read, FileShare.None, 12, FileOptions.SequentialScan)){
                rd.ReadByte();
                byte[] pckt0 = new byte[16];

                while (min < 0)
                {
                    rd.Read(pckt0, 0, 16);
                    if (pckt0[0] == 'F' && pckt0[1] == 'T')
                    {
                        min = BitConverter.ToSingle(pckt0, 8);
                        break;
                    }
                    min += 0.01f;
                }


                rd.Seek(-8, SeekOrigin.End);
                byte[] pckt = new byte[4];
                rd.Read(pckt, 0, 4);
                max = BitConverter.ToSingle(pckt, 0);
            }

            Globals.StopReadingHIstoryFile = false;
            IsRecording = false;
            FrequencyManager.IsReadingHistory = true;
            Stopwatch sw = Stopwatch.StartNew();
            int       restoreUnderSample       = vmsci.UnderSample;
            bool      restoreUnderSampleEnable = vmsci.IsUnderSampling;
            var       restoreRefreshTime       = vmsci.RefreshTime;

            vmsci.IsUnderSampling = false;

            vmsci.CmdClear.Execute(null);
            vmsci.PlotTime              = (uint)max;
            vmsci.NumOfPointsToPlot     = int.MaxValue;
            vmsci.AnimatedXVisibleRange = new DoubleRange(min, max);
            dic_readData.Clear();

            Task.Factory.StartNew(
                action: () => {
                Thread.Sleep(100);
                using (FileStream rd = new FileStream(
                           fileFullPath,
                           FileMode.Open,
                           FileAccess.Read,
                           FileShare.None,
                           16,
                           FileOptions.SequentialScan)){
                    rd.Seek(0, SeekOrigin.Begin);
                    int ccvalue = rd.ReadByte();
                    FrequencyManager.Frequency = ccvalue / 6.0;

                    vmsci.RefreshTime = 500;
                    while (!Globals.StopReadingHIstoryFile)
                    {
                        byte[] pckt = new byte[16];
                        if (rd.Read(pckt, 0, 16) != 16)
                        {
                            break;
                        }
                        AddReadData(pckt);
                        CAN_Common.Instance.innerTranmit(pckt);
                    }
                }
                vmsci.finishedReadingData();
                Thread.Sleep(vmsci.RefreshTime * 2);
                FrequencyManager.IsReadingHistory = false;
                Thread.Sleep(vmsci.RefreshTime * 6);
                vmsci.IsUnderSampling = restoreUnderSampleEnable;
                vmsci.UnderSample     = restoreUnderSample;
                vmsci.RefreshTime     = restoreRefreshTime;
            });
        }