public GaussMeter3000ViewModel(string comPort, string niDeviceAddresss) { try { _sc = new GaussSerialComms(comPort); _sc.StringReceived += _sc_StringReceived; _sc.DeviceStarted += _sc_DeviceStarted; _sc.ChangedChannel += _sc_ChangedChannel; _niInterface = new NiInterface(niDeviceAddresss, Convert.ToInt32(Properties.Settings.Default.SampleFrequency), 2); _niInterface.CompletedSamples += _niInterface_CompletedSamples; _currentChannel = GaussMeterChannelEnum.Unknown; DeviceStarted = Visibility.Hidden; ResetDevice = Visibility.Visible; _syncCtx = SynchronizationContext.Current; Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\KCF Technologies\\Gauss Master"); SampleFrequency = Properties.Settings.Default.SampleFrequency; } catch (Exception ex) { MainWindow.ShowError(ex.Message, true); } }
public bool ChangeChannel(GaussMeterChannelEnum channel) { if (StillSendingText) return false; string text = "channel "; switch (channel) { case GaussMeterChannelEnum.X: text += "x"; break; case GaussMeterChannelEnum.Y: text += "y"; break; case GaussMeterChannelEnum.Z: text += "z"; break; case GaussMeterChannelEnum.M: text += "m"; break; } text += "\r"; StartSendingText(text); return true; }
void _sc_ChangedChannel(object sender, ChangedChannelEventArgs e) { _currentChannel = e.Channel; }
public ChangedChannelEventArgs(GaussMeterChannelEnum channel) { Channel = channel; }