Ejemplo n.º 1
0
 /**
  * Sets the constant current target value.
  *
  * @param device_address The address of the device.
  * @param target_current The the curent you'd like to set the device to.
  * @return none
  */
 public static async Task SetConstantCurrentTarget(IPAddress device_address, double target_current)
 {
     using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
     {
         KEL103Tools.ConfigureClient(device_address, client);
         await SetConstantCurrentTarget(client, target_current);
     }
 }
Ejemplo n.º 2
0
        public static async Task <double> GetMaximumSupportedSystemInputResistance(IPAddress device_address)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                return(await GetMaximumSupportedSystemInputResistance(client));
            }
        }
        public static async Task <string> QueryDynamicMode(IPAddress device_address)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                return(await QueryDynamicMode(client));
            }
        }
Ejemplo n.º 4
0
        public static async Task <double> QueryBatteryTestCapacityCounter(IPAddress device_address)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                return(await QueryBatteryTestCapacityCounter(client));
            }
        }
Ejemplo n.º 5
0
        //recall before querying
        public static async Task <string> QueryBatteryTestModeParameters(IPAddress device_address, int list_index)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                return(await QueryBatteryTestModeParameters(client, list_index));
            }
        }
Ejemplo n.º 6
0
        public static async Task <bool> GetLoadInputSwitchState(IPAddress device_address)  //true is on, false is off
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                return(await GetLoadInputSwitchState(client));
            }
        }
        public static async Task SetDynamicMode(IPAddress device_address, int mode, double low_value, double high_value, double frequency, double duty_cycle)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                await SetDynamicMode(client, mode, low_value, high_value, frequency, duty_cycle);
            }
        }
Ejemplo n.º 8
0
        public static async Task SimulateTrigger(IPAddress device_address)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                await SimulateTrigger(client);
            }
        }
Ejemplo n.º 9
0
        public static async Task RecallToUnit(IPAddress device_address, int location_index)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                await RecallToUnit(client, location_index);
            }
        }
Ejemplo n.º 10
0
        public static async Task <double> MeasurePower(IPAddress device_address)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                return(await MeasurePower(client));
            }
        }
Ejemplo n.º 11
0
        public static async Task SetSystemMode(IPAddress device_address, int mode)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                await SetSystemMode(client, mode);
            }
        }
Ejemplo n.º 12
0
        public static async Task <int> GetSystemMode(IPAddress device_address)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                return(await GetSystemMode(client));
            }
        }
Ejemplo n.º 13
0
        public static async Task <double> GetConstantResistanceTarget(IPAddress device_address)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                return(await GetConstantResistanceTarget(client));
            }
        }
Ejemplo n.º 14
0
        public static async Task SetBatteryTestModeParameters(UdpClient client, int list_index, double current_range,
                                                              double discharge_current, double cutoff_voltage, double cutoff_capacity, double discharge_time)
        {
            var tx_bytes = Encoding.ASCII.GetBytes(":BATT " + list_index + "," + KEL103Tools.FormatString(current_range) +
                                                   "A," + KEL103Tools.FormatString(discharge_current) + "A," + KEL103Tools.FormatString(cutoff_voltage) +
                                                   "V," + KEL103Tools.FormatString(cutoff_capacity) + "AH," + KEL103Tools.FormatString(discharge_time) + "S\n");

            await client.SendAsync(tx_bytes, tx_bytes.Length);
        }
Ejemplo n.º 15
0
        public static async Task SetBatteryTestModeParameters(IPAddress device_address, int list_index, double current_range,
                                                              double discharge_current, double cutoff_voltage, double cutoff_capacity, double discharge_time)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                await SetBatteryTestModeParameters(client, list_index, current_range, discharge_current, cutoff_voltage, cutoff_capacity, discharge_time);
            }
        }
        public static async Task SetDynamicMode_Flip(IPAddress device_address, double low_slope, double high_slope, double low_current,
                                                     double high_current)
        {
            using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
            {
                KEL103Tools.ConfigureClient(device_address, client);

                await SetDynamicMode_Flip(client, low_slope, high_slope, low_current, high_current);
            }
        }
        public static async Task SetDynamicMode(UdpClient client, int mode, double low_value, double high_value, double frequency, double duty_cycle)
        {
            string mode_string = mode + "," + KEL103Tools.FormatString(low_value) + dynamic_mode_suffix_strings[mode - 1] + "," +
                                 KEL103Tools.FormatString(high_value) + dynamic_mode_suffix_strings[mode - 1] + "," + KEL103Tools.FormatString(frequency) + "HZ," +
                                 KEL103Tools.FormatString(duty_cycle) + "%";

            var tx_bytes = Encoding.ASCII.GetBytes(":DYN " + mode_string + "\n");

            await client.SendAsync(tx_bytes, tx_bytes.Length);
        }
        //these work but don't seem to do anything
        public static async Task SetDynamicMode_Pulse(UdpClient client, double low_slope, double high_slope, double low_current,
                                                      double high_current, double time)
        {
            string mode_string = 5 + "," + KEL103Tools.FormatString(low_slope) + "A/uS," +
                                 KEL103Tools.FormatString(high_slope) + "A/uS," + KEL103Tools.FormatString(low_current) + "A," +
                                 KEL103Tools.FormatString(high_current) + "A," + KEL103Tools.FormatString(time) + "S";

            var tx_bytes = Encoding.ASCII.GetBytes(":DYN " + mode_string + "\n");

            await client.SendAsync(tx_bytes, tx_bytes.Length);
        }
Ejemplo n.º 19
0
        private static Task GenerateTrackerTask()
        {
            return(new Task(async() =>
            {
                tracker_active = true;

                while (tracker_active)
                {
                    try
                    {
                        address = await KEL103Tools.FindLoadAddress();

                        tracker_init_complete = true;

                        //do work
                        using (UdpClient client = new UdpClient(KEL103Persistance.Configuration.CommandPort))
                        {
                            KEL103Tools.ConfigureClient(address, client);

                            KEL103StateTracker.client = client;

                            while (tracker_active)
                            {
                                Stopwatch q = new Stopwatch();
                                q.Start();

                                CheckoutClient();

                                var kel_state = new KEL103State();

                                var voltage = await KEL103Command.MeasureVoltage(client);
                                var current = await KEL103Command.MeasureCurrent(client);
                                var power = await KEL103Command.MeasurePower(client);

                                var input_state = await KEL103Command.GetLoadInputSwitchState(client);

                                var time_stame = DateTime.Now;

                                CheckinClient();

                                q.Stop();

                                var retreval_span = TimeSpan.FromTicks(q.ElapsedTicks);

                                kel_state.Voltage = voltage;
                                kel_state.Current = current;
                                kel_state.Power = power;
                                kel_state.TimeStamp = time_stame;
                                kel_state.InputState = input_state;
                                kel_state.ValueAquisitionTimespan = retreval_span;

                                NewKEL103StateAvailable(kel_state);

                                //await Task.Delay(10);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }));
        }
Ejemplo n.º 20
0
        public static async Task SetConstantPowerTarget(UdpClient client, double target_power)
        {
            var tx_bytes = Encoding.ASCII.GetBytes(":POW " + KEL103Tools.FormatString(target_power) + "W\n");

            await client.SendAsync(tx_bytes, tx_bytes.Length);
        }
Ejemplo n.º 21
0
        public static async Task SetConstantVoltageTarget(UdpClient client, double target_voltage)
        {
            var tx_bytes = Encoding.ASCII.GetBytes(":VOLT " + KEL103Tools.FormatString(target_voltage) + "V\n");

            await client.SendAsync(tx_bytes, tx_bytes.Length);
        }
Ejemplo n.º 22
0
        public static async Task SetConstantCurrentTarget(UdpClient client, double target_current)
        {
            var tx_bytes = Encoding.ASCII.GetBytes(":CURR " + KEL103Tools.FormatString(target_current) + "A\n");

            await client.SendAsync(tx_bytes, tx_bytes.Length);
        }
Ejemplo n.º 23
0
        public static async Task SetConstantResistanceTarget(UdpClient client, double target_resistance)
        {
            var tx_bytes = Encoding.ASCII.GetBytes(":RES " + KEL103Tools.FormatString(target_resistance) + "OHM\n");

            await client.SendAsync(tx_bytes, tx_bytes.Length);
        }