public Form1() { InitializeComponent(); Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; m_DelegateSetLabelText = new DelegateSetLabelText(this.SetLabelCaption); m_DelegateSetProgressValue = new DelegateSetProgressValue(this.SetProgressValue); Application.ApplicationExit += new EventHandler(Application_ApplicationExit); _cancomms = new ME7Communication(); _cancomms.onCanInfo += new ME7Communication.CanInfo(_comms_onCanInfo); _cancomms.onCanCount += new ME7Communication.CanCount(_cancomms_onCanCount); _cancomms.onWriteProgress += new ME7Communication.WriteProgress(_cancomms_onWriteProgress); _cancomms.onCanBusLoad += new ME7Communication.CanBusLoad(_cancomms_onCanBusLoad); _cancomms.setCANDevice("LAWICEL"); //TODO: Make this selectable _cancomms.onReadProgress += new ME7Communication.ReadProgress(_cancomms_onReadProgress); //_comms = new ME7KLineCommunication(); //_comms.LogFolder = Application.StartupPath; //_comms.EnableLogging = true; //_comms.onStatusChanged += new ICommunication.StatusChanged(_comms_onStatusChanged); //_comms.onECUInfo += new ICommunication.ECUInfo(_comms_onECUInfo); }
void _comms_onCanInfo(object sender, ME7Communication.CanInfoEventArgs e) { if (e.Type == ActivityType.DownloadingFlash) { SetLabelText(label5, e.Info); Application.DoEvents(); } else { AddToLogItem(e.Info); } }
void _cancomms_onWriteProgress(object sender, ME7Communication.WriteProgressEventArgs e) { int percentage = (int)e.Percentage; if (progressBar1.Value != percentage) { progressBar1.Value = percentage; Application.DoEvents(); } }
void _cancomms_onCanCount(object sender, ME7Communication.CanCountEventArgs e) { if (!_holdUpdate) { SetLabelText(lblRxCount, e.RxCount.ToString()); SetLabelText(lblTxCount, e.TxCount.ToString()); SetLabelText(lblErrCount, e.ErrCount.ToString()); _holdUpdate = true; } }
void _cancomms_onCanBusLoad(object sender, ME7Communication.CanbusLoadEventArgs e) { SetProgressBarValue(progressBar2, Convert.ToInt32(e.Load)); SetLabelText(label6, e.Load.ToString("F1") + " %"); }