protected override void OnStart(string[] args) { //Создание логгера XmlSerializer formatter = new XmlSerializer(typeof(Properties)); // десериализация try { FileStream fs = new FileStream("C:\\microclimate\\Properties.xml", FileMode.Open); properties = (Properties)formatter.Deserialize(fs); log.Write("Полученны настройки службы", "Info"); } catch { log.Write("Не удалось получить настройки службы", "Fatal"); return; } foreach (string str in properties.DisplayLevels) { log.LevelLogger[str] = true; } DeviceReader.SetGlobalParams(log, properties.TimeOut, properties.NumberOfRetries, connection); connection = new SqlConnection( string.Format(@"Data Source={0};Initial Catalog={1};Integrated Security=True", properties.SourseToDataBase, properties.NameToDataBase)); mainThread = new Thread(new ThreadStart(Loop)); mainThread.Name = "Main"; mainThread.Start(); }
public BackgroundWorker(DeviceReader leftDeviceReader, DeviceReader rightDeviceReader, VJoyDevice vJoyDevice, LinkedList <Axis> axesList) { this.leftDeviceReader = leftDeviceReader; this.rightDeviceReader = rightDeviceReader; this.vJoyDevice = vJoyDevice; this.axesList = axesList; }
public void delete_null_test() { var console = new Mock <IConsole>(); var reader = new DeviceReader(console.Object); Assert.ThrowsException <NullReferenceException>(() => reader.delete()); }
public void set_parser_valid_test() { var console = new Mock <IConsole>(); var parser = new Mock <ICommandLineParser>(); var reader = new DeviceReader(console.Object); reader.set_parser(parser.Object); }
public Axis(DeviceReader leftDeviceReader, DeviceReader rightDeviceReader, VJoyDevice vJoyDevice, AxisName axisInput, AxisName axisOutput, bool centered) { this.leftDeviceReader = leftDeviceReader; this.rightDeviceReader = rightDeviceReader; this.vJoyDevice = vJoyDevice; this.axisInput = axisInput; this.axisOutput = axisOutput; this.centered = centered; }
public Class1( DeviceReader deviceReader, GatewayReader gatewayReader, DeviceConfigurationReader deviceConfigurationReader) { DeviceReader = deviceReader; GatewayReader = gatewayReader; DeviceConfigurationReader = deviceConfigurationReader; }
public VirtualRudder(DeviceReader leftDeviceReader, DeviceReader rightDeviceReader) : base(leftDeviceReader, rightDeviceReader) { vJoyDevice = new VJoyRudder(); init(); addAxis((AxisName)Properties.Settings.Default.axisLeftToeAxis, AxisName.X, (AxisMethod)Properties.Settings.Default.axisLeftToeMethod, Properties.Settings.Default.axisLeftToeChange, Properties.Settings.Default.axisLeftToeCentered); addAxis((AxisName)Properties.Settings.Default.axisRightToeAxis, AxisName.Y, (AxisMethod)Properties.Settings.Default.axisRightToeMethod, Properties.Settings.Default.axisRightToeChange, Properties.Settings.Default.axisRightToeCentered); addAxis((AxisName)Properties.Settings.Default.axisRudderAxis, AxisName.RotationZ, (AxisMethod)Properties.Settings.Default.axisRudderMethod, Properties.Settings.Default.axisRudderChange, Properties.Settings.Default.axisRudderCentered); }
public AxisWeightedSum(DeviceReader leftDeviceReader, DeviceReader rightDeviceReader, VJoyDevice vJoyDevice, AxisName axisInput, AxisName axisOutput, bool centered) : base(leftDeviceReader, rightDeviceReader, vJoyDevice, axisInput, axisOutput, centered) { modesWeights = new byte[3]; modesWeights[0] = Properties.Settings.Default.mode1Weight; modesWeights[1] = Properties.Settings.Default.mode2Weight; modesWeights[2] = Properties.Settings.Default.mode3Weight; modesButtons = new byte[3]; modesButtons[0] = Properties.Settings.Default.mode1Button; modesButtons[1] = Properties.Settings.Default.mode2Button; modesButtons[2] = Properties.Settings.Default.mode3Button; }
public VirtualJoystick(DeviceReader leftDeviceReader, DeviceReader rightDeviceReader) : base(leftDeviceReader, rightDeviceReader) { vJoyDevice = new VJoyJoystick(); init(); addAxis((AxisName)Properties.Settings.Default.axisXAxis, AxisName.X, (AxisMethod)Properties.Settings.Default.axisXMethod, Properties.Settings.Default.axisXChange, Properties.Settings.Default.axisXCentered); addAxis((AxisName)Properties.Settings.Default.axisYAxis, AxisName.Y, (AxisMethod)Properties.Settings.Default.axisYMethod, Properties.Settings.Default.axisYChange, Properties.Settings.Default.axisYCentered); addAxis((AxisName)Properties.Settings.Default.axisTwistAxis, AxisName.RotationZ, (AxisMethod)Properties.Settings.Default.axisTwistMethod, Properties.Settings.Default.axisTwistChange, Properties.Settings.Default.axisTwistCentered); addAxis((AxisName)Properties.Settings.Default.axisThrottleAxis, AxisName.Z, (AxisMethod)Properties.Settings.Default.axisThrottleMethod, Properties.Settings.Default.axisThrottleChange, Properties.Settings.Default.axisThrottleCentered); addAxis((AxisName)Properties.Settings.Default.axisRotary1Axis, AxisName.RotationX, (AxisMethod)Properties.Settings.Default.axisRotary1Method, Properties.Settings.Default.axisRotary1Change, Properties.Settings.Default.axisRotary1Centered); addAxis((AxisName)Properties.Settings.Default.axisRotary2Axis, AxisName.RotationY, (AxisMethod)Properties.Settings.Default.axisRotary2Method, Properties.Settings.Default.axisRotary2Change, Properties.Settings.Default.axisRotary2Centered); addAxis((AxisName)Properties.Settings.Default.axisSliderAxis, AxisName.Slider, (AxisMethod)Properties.Settings.Default.axisSliderMethod, Properties.Settings.Default.axisSliderChange, Properties.Settings.Default.axisSliderCentered); }
static private void Loop() { while (!onStop) { foreach (string portName in SerialPort.GetPortNames()) { if (!DeviceReader.ActivePorts.Contains(portName)) { DeviceReader reader = new DeviceReader(portName); Thread thread = new Thread(new ThreadStart(reader.DeviceReaderRun)); thread.Start(); } } Thread.Sleep(properties.IntervalInspections * 1000); } }
public void print_structure_simple_test() { var parser = new Mock <ICommandLineParser>(); var console = new Mock <IConsole>(); var reader = new DeviceReader(console.Object); reader.set_parser(parser.Object); console.Setup(fun => fun.Clear()); console.Setup(fun => fun.WriteLine("Device Structure: (Any Key to continue)")); console.Setup(fun => fun.ReadLine()).Returns(""); reader.print_structure(); console.VerifyAll(); }
private void updateMode(DeviceReader device, short side) { if (device.GetType() == typeof(JoystickReader)) { for (byte i = 0; i < 3; i++) { if (device.getButtonState(modesButtons[i])) { switch (side) { case 1: leftMode = i; break; case 2: rightMode = i; break; } break; } } } }
public AxisMaximum(DeviceReader leftDeviceReader, DeviceReader rightDeviceReader, VJoyDevice vJoyDevice, AxisName axisInput, AxisName axisOutput, bool centered) : base(leftDeviceReader, rightDeviceReader, vJoyDevice, axisInput, axisOutput, centered) { }
public VirtualDevice(DeviceReader leftDeviceReader, DeviceReader rightDeviceReader) { axesList = new LinkedList <Axis>(); this.leftDeviceReader = leftDeviceReader; this.rightDeviceReader = rightDeviceReader; }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { _reader = new DeviceReader(); _reader.Start("COM3", 9600, BatchSize); _reader.OnLineRead += (r, ir, g, m, dt) => { if (ChartValuesIR.Count > BatchSize) { ChartValuesIR.RemoveAt(0); ChartValuesRed.RemoveAt(0); ChartValuesHeart.RemoveAt(0); } ChartValuesRed.Add(new MeasureModel { Time = dt, Value = r, //r.Next(-8, 10) }); ChartValuesIR.Add(new MeasureModel { Time = dt, Value = ir, //r.Next(-8, 10) }); ChartValuesHeart.Add(new MeasureModel { Time = dt, Value = g, }); Bpm.Add(new MeasureModel { Value = m, Time = dt, }); if (Bpm.Count > 500) { Bpm.RemoveAt(0); } SetAxisLimits(dt); }; _reader.OnEveryLine += (r, ir, g, m, t) => { }; _reader.OnBatchCompleted += (r, ir, g, m) => { //SignalProcessor.Mean(ref r, ref ir); //SignalProcessor.LineLeveling(ref ir, ref r); SignalProcessor.Mean(ref g); SignalProcessor.LineLeveling(ref g); List <MeasureModel> smoothed = null; double myBpm = SignalProcessor.ComputeBpm(g, out smoothed); double spo2 = 0, bpm = 0, xyRatio = 0; if (Interop.Compute(ir.Select(n => n.Value).ToArray(), r.Select(n => n.Value).ToArray(), ref spo2, ref bpm, ref xyRatio) && myBpm > 0) { Dispatcher.Invoke(() => { SpO2Label.Content = $"SPO2: {(int)Math.Round(spo2)}, BPM: {(int)Math.Round(myBpm)}, Ratio: {xyRatio}"; }); //Spo2.Add(new MeasureModel //{ // Value = spo2, // Time = m.Last().Time, //}); //Bpm.Add(new MeasureModel //{ // Value = myBpm, // Time = r.Last().Time, //}); if (Spo2.Count > 2000) { Spo2.RemoveAt(0); Bpm.RemoveAt(0); } } return; }; }
public AxisChange(DeviceReader leftDeviceReader, DeviceReader rightDeviceReader, VJoyDevice vJoyDevice, AxisName axisInput, AxisName axisOutput, bool centered, byte change) : base(leftDeviceReader, rightDeviceReader, vJoyDevice, axisInput, axisOutput, centered) { this.change = change; this.changeInterval = Properties.Settings.Default.changeInterval; }