コード例 #1
0
        private async void ChangeIt_ButtonOnClick(object sender, RoutedEventArgs e)
        {
            SIUnits siUnit = (SIUnits)Enum.Parse(typeof(SIUnits), SiUnitComboBox.SelectedItem.ToString());

            SensorData sensorData = new SensorData("_time_", ValueTextBox.Text, siUnit.ToString(), _sensor.Id);
            var        result     = await _apiHandler.ChangeSensorValue(_sensor.Id, sensorData);

            MessageDialog msgDialog = new MessageDialog("Sensor was changed!");

            msgDialog.Commands.Add(new UICommand("OK"));
            if (result.Answer != null)
            {
                var msgDialogResult = await msgDialog.ShowAsync();

                if (msgDialogResult.Label == "OK")
                {
                    Frame.GoBack();
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SIUnitDefinition"/> class.
 /// </summary>
 /// <param name="name">The name of the unit.</param>
 /// <param name="units">The SI units.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="name"/> is <c>null</c>.</exception>
 public SIUnitDefinition(string name, SIUnits units)
 {
     _name = name.ThrowIfNull(nameof(name));
     SI    = units;
 }
コード例 #3
0
        public void CapacitorTest()
        {
            Circuit sim = new Circuit();

            var volt0 = sim.Create <DCVoltageSource>();
            var cap0  = sim.Create <CapacitorElm>(2E-4);
            var res0  = sim.Create <Resistor>();

            var switch0 = sim.Create <SwitchSPDT>();

            /*sim.Connect(volt0, 1, switch0, 1);
             * sim.Connect(switch0, 1, switch0, 1);
             * sim.Connect(switch0, 2, res0, 1);
             * sim.Connect(cap0, 1, res0, 0);
             * sim.Connect(res0, 1, volt0, 0);*/

            // leadNeg 0
            // leadPos 1

            sim.Connect(volt0, 1, switch0, 1);
            sim.Connect(switch0, 0, cap0, 0);
            sim.Connect(cap0, 1, res0, 0);
            sim.Connect(res0, 1, volt0, 0);
            sim.Connect(switch0, 2, volt0, 0);

            switch0.setPosition(0);

            var capScope0 = sim.Watch(cap0);

            for (int x = 1; x <= 28000; x++)
            {
                sim.doTick();
            }

            Debug.LogF("{0} [{1}]", sim.time, SIUnits.Normalize(sim.time, "s"));
            {
                double voltageHigh    = capScope0.Max((f) => f.voltage);
                int    voltageHighNdx = capScope0.FindIndex((f) => f.voltage == voltageHigh);

                Debug.Log("voltageHigh", voltageHigh, voltageHighNdx);

                double voltageLow    = capScope0.Min((f) => f.voltage);
                int    voltageLowNdx = capScope0.FindIndex((f) => f.voltage == voltageLow);

                Debug.Log("voltageLow ", voltageLow, voltageLowNdx);

                double currentHigh    = capScope0.Max((f) => f.current);
                int    currentHighNdx = capScope0.FindIndex((f) => f.current == currentHigh);
                Debug.Log("currentHigh", currentHigh, currentHighNdx);

                double currentLow    = capScope0.Min((f) => f.current);
                int    currentLowNdx = capScope0.FindIndex((f) => f.current == currentLow);

                Debug.Log("currentLow ", currentLow, currentLowNdx);

                Assert.AreEqual(27999, voltageHighNdx);
                Assert.AreEqual(0, voltageLowNdx);

                Assert.AreEqual(0, currentHighNdx);
                Assert.AreEqual(27999, currentLowNdx);
            }

            switch0.setPosition(1);
            sim.analyze();
            capScope0.Clear();

            for (int x = 1; x <= 28000; x++)
            {
                sim.doTick();
            }

            Debug.Log();

            Debug.LogF("{0} [{1}]", sim.time, SIUnits.Normalize(sim.time, "s"));
            {
                double voltageHigh    = capScope0.Max((f) => f.voltage);
                int    voltageHighNdx = capScope0.FindIndex((f) => f.voltage == voltageHigh);

                Debug.Log("voltageHigh ", voltageHigh, voltageHighNdx);

                double voltageLow    = capScope0.Min((f) => f.voltage);
                int    voltageLowNdx = capScope0.FindIndex((f) => f.voltage == voltageLow);

                Debug.Log("voltageLow  ", voltageLow, voltageLowNdx);

                double currentHigh    = capScope0.Max((f) => f.current);
                int    currentHighNdx = capScope0.FindIndex((f) => f.current == currentHigh);
                Debug.Log("currentHigh", currentHigh, currentHighNdx);

                double currentLow    = capScope0.Min((f) => f.current);
                int    currentLowNdx = capScope0.FindIndex((f) => f.current == currentLow);

                Debug.Log("currentLow ", currentLow, currentLowNdx);

                Assert.AreEqual(voltageHighNdx, currentLowNdx);
                Assert.AreEqual(voltageLowNdx, currentHighNdx);

                Assert.AreEqual(0, voltageHighNdx);
                Assert.AreEqual(27999, voltageLowNdx);

                Assert.AreEqual(27999, currentHighNdx);
                Assert.AreEqual(0, currentLowNdx);
            }
        }