private void data_sending(object sender, ElapsedEventArgs e) { if (gen_q.Count > 0) { messg = gen_q.Dequeue(); if (messg == null) { return; } switch (messg.GetRequest()) { case Message.MsgRequest.GEN_NEXT: if (toSend == 0) { if (sendingChannel == 1 && actual_channels == 2) { toSend = signal_ch2.Length; sent = 0; index = 0; actualSend = 0; sendingChannel = 2; send_next(signal_ch2, 2); } else if (sendingChannel == actual_channels) { gen_get_freq(); Thread.Sleep(10); gen_start(); } } else { if (sendingChannel == 2) { send_next(signal_ch2, 2); } else { send_next(signal_ch1, 1); } } break; case Message.MsgRequest.GEN_OK: generating = true; this.Invalidate(); break; case Message.MsgRequest.GEN_FRQ: if(messg.GetMessage().Equals(Commands.CHANNELS_1)){ this.realFreq_ch1 = (double)messg.GetNum() / signal_leng_ch1; } else if (messg.GetMessage().Equals(Commands.CHANNELS_2)) { this.realFreq_ch2 = (double)messg.GetNum() / signal_leng_ch2; } this.Invalidate(); break; } } }
private void Update_GUI(object sender, ElapsedEventArgs e) { if (scope_q.Count > 0) { messg = scope_q.Dequeue(); if (messg == null) { return; } switch (messg.GetRequest()) { case Message.MsgRequest.SCOPE_NEW_DATA: status_text = ""; //meas.calculateMeasurements(device.scopeCfg.samples, device.scopeCfg.ranges[1, selectedRange], device.scopeCfg.ranges[0, selectedRange], device.scopeCfg.actualChannels, device.scopeCfg.sampligFreq, device.scopeCfg.timeBase.Length,device.scopeCfg.actualRes); calcSignal_th = new Thread(() => meas.calculateMeasurements(device.scopeCfg.samples, device.scopeCfg.ranges[1, selectedRange], device.scopeCfg.ranges[0, selectedRange], device.scopeCfg.actualChannels, device.scopeCfg.sampligFreq, device.scopeCfg.timeBase.Length,device.scopeCfg.actualRes)); calcSignal_th.Start(); processSignal_th = new Thread(process_signals); processSignal_th.Start(); processSignal_th.Join(); calcSignal_th.Join(); scopePane.CurveList.Clear(); //process_signals(); paint_signals(); update_Y_axe(); update_X_axe(); paint_markers(); vertical_cursor_update(); paint_cursors(); this.Invalidate(); if (device.scopeCfg.mode == Scope.mode_def.AUTO || device.scopeCfg.mode == Scope.mode_def.NORMAL) { Thread.Sleep(50); device.takeCommsSemaphore(semaphoreTimeout*2 + 108); device.send(Commands.SCOPE + ":" + Commands.SCOPE_NEXT + ";"); device.giveCommsSemaphore(); } break; case Message.MsgRequest.SCOPE_TRIGGERED: status_text = "Trig"; this.Invalidate(); break; case Message.MsgRequest.SCOPE_WAIT: scopePane.CurveList.Clear(); status_text = "Wait"; this.Invalidate(); break; case Message.MsgRequest.SCOPE_FREQ: device.scopeCfg.realSmplFreq = messg.GetNum(); break; } } }