コード例 #1
0
 public int get_load_switch()
 {
     Log.Verbose($"Get load switch");
     byte[] response = get_status_bank();
     if (response != null)
     {
         switch_status = (load_switch)(response[3] & 1);
     }
     return((int)switch_status);
 }
コード例 #2
0
ファイル: kp184.cs プロジェクト: hermitcrabslab/modbus
 public int get_OnOff()
 {
     Log.Verbose($"Get KP184 on or off");
     byte[] message = new byte[8];
     // wacky special read at 0x300 means get them all and the format of the return message is... special
     send_message(command.read_registers, 0x300, 0, ref message);
     delay();
     byte[] response = get_response(23);
     if (response != null)
     {
         switch_status = (load_switch)(response[3] & 1);
     }
     return((int)switch_status);
 }
コード例 #3
0
        //////////////////////////////////////////////////////////////////////
        // get the KP184 status

        public void get_status()
        {
            byte[] response = get_status_bank();
            if (response != null)
            {
                switch_status = (load_switch)(response[3] & 1);
                switch_mode   = (load_mode)((response[3] >> 1) & 3); // TODO (chs): then look this up, the values in the status are wacky
                voltage       = ((uint)response[offset_voltage] << 16) | ((uint)response[offset_voltage + 1] << 8) | response[offset_voltage + 2];
                current       = ((uint)response[offset_current] << 16) | ((uint)response[offset_current + 1] << 8) | response[offset_current + 2];
                Log.Info("Status:");
                Log.Info($"   Switch is {switch_status}");
                Log.Info($"   Mode is {load_mode_as_string(switch_mode)}");
                Log.Info($"   Current is {current}");
                Log.Info($"   Voltage is {voltage}");
            }
        }
コード例 #4
0
ファイル: kp184.cs プロジェクト: hermitcrabslab/modbus
        //////////////////////////////////////////////////////////////////////
        // get the KP184 status

        public void get_status()
        {
            byte[] message = new byte[8];
            // wacky special read at 0x300 means get them all and the format of the return message is... special
            send_message(command.read_registers, 0x300, 0, ref message);
            delay();
            byte[] response = get_response(23);
            if (response != null)
            {
                switch_status = (load_switch)(response[3] & 1);
                switch_mode   = (load_mode)((response[3] >> 1) & 7); // TODO (chs): then look this up, the values in the status are wacky
                voltage       = ((uint)response[5] << 16) | ((uint)response[6] << 8) | response[7];
                current       = ((uint)response[8] << 16) | ((uint)response[9] << 8) | response[10];
                Log.Info("Status:");
                Log.Info($"   Switch is {switch_status}");
                Log.Info($"   Mode is {switch_mode}");
                Log.Info($"   Current is {current}");
                Log.Info($"   Voltage is {voltage}");
            }
        }
コード例 #5
0
ファイル: kp184.cs プロジェクト: hermitcrabslab/modbus
 public void set_load_switch(load_switch on_or_off)
 {
     Log.Verbose($"Set switch {on_or_off}");
     write_register(register.load_switch, (uint)on_or_off);
 }