public PhysicalActuator(IConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _hitTime = config.Read <int>("Robot.Actuator.Hit.Time"); _hitDelayAfter = config.Read <int>("Robot.Actuator.Hit.DelayAfter"); var host = config.Read <string>("Robot.Actuator.Host"); var port = config.Read <int>("Robot.Actuator.Port"); var uidMaster = config.Read <string>("Robot.Actuator.UidMaster"); var uidRelay1 = config.Read <string>("Robot.Actuator.UidRelay1"); var uidRelay2 = config.Read <string>("Robot.Actuator.UidRelay2"); _ipcon = new IPConnection(); // Create IP connection _ipcon.Connect(host, port); // Connect to brickd. Don't use device before ipcon is connected var master = new BrickMaster(uidMaster, _ipcon); _or1 = new BrickletIndustrialQuadRelay(uidRelay1, _ipcon); _or2 = new BrickletIndustrialQuadRelay(uidRelay2, _ipcon); // Get current stack voltage (unit is mV) int stackVoltage = master.GetStackVoltage(); _logger.Info($"Stack Voltage: {stackVoltage / 1000.0:F} V"); // Get current stack current (unit is mA) int stackCurrent = master.GetStackCurrent(); _logger.Info($"Stack Current: {stackCurrent / 1000.0:F} A"); }
private static string UID = "XXYYZZ"; // Change XXYYZZ to the UID of your Master Brick #endregion Fields #region Methods static void Main() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickMaster master = new BrickMaster(UID, ipcon); // Create device object ipcon.Connect(HOST, PORT); // Connect to brickd // Don't use device before ipcon is connected // Get current stack voltage (unit is mV) int stackVoltage = master.GetStackVoltage(); Console.WriteLine("Stack Voltage: " + stackVoltage/1000.0 + " V"); // Get current stack current (unit is mA) int stackCurrent = master.GetStackCurrent(); Console.WriteLine("Stack Current: " + stackCurrent/1000.0 + " A"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); ipcon.Disconnect(); }
public void TestConnection() { IPConnection ipcon = new IPConnection(); // Create IP connection BrickMaster master = new BrickMaster(_uidMaster, ipcon); // Create device object BrickletIndustrialQuadRelay or1 = new BrickletIndustrialQuadRelay(_uidRelay1, ipcon); BrickletIndustrialQuadRelay or2 = new BrickletIndustrialQuadRelay(_uidRelay2, ipcon); BrickletTemperatureIR tir = new BrickletTemperatureIR(_uidTemp, ipcon); ipcon.Connect(_host, _port); // Connect to brickd // Don't use device before ipcon is connected // Get current stack voltage (unit is mV) int stackVoltage = master.GetStackVoltage(); Console.WriteLine("Stack Voltage: " + stackVoltage / 1000.0 + " V"); // Get current stack current (unit is mA) int stackCurrent = master.GetStackCurrent(); Console.WriteLine("Stack Current: " + stackCurrent / 1000.0 + " A"); short chipTemp = tir.GetAmbientTemperature(); Console.WriteLine("Chibi master address: " + chipTemp / 10 + "°/C"); int delay = 50; while (true) { ConsoleKeyInfo insertKey = Console.ReadKey(); int result = insertKey.KeyChar; // UP if (result.Equals(32)) { or1.SetValue(1 << 0); Thread.Sleep(delay); or1.SetValue(1 << 0); Thread.Sleep(delay); } // DOWN if (result.Equals(32)) { or1.SetValue(1 << 0); Thread.Sleep(delay); or1.SetValue(1 << 0); Thread.Sleep(delay); } // LEFT if (result.Equals(97)) { or1.SetValue(1 << 0); Thread.Sleep(delay); or1.SetValue(1 << 0); Thread.Sleep(delay); } // RIGHT if (result.Equals(32)) { or1.SetValue(1 << 0); Thread.Sleep(delay); or1.SetValue(1 << 0); Thread.Sleep(delay); } // START if (result.Equals(115)) { or2.SetValue(1); Thread.Sleep(delay); or2.SetValue(0); Thread.Sleep(delay); } // SELECT if (result.Equals(83)) { or2.SetValue(4); Thread.Sleep(delay); or2.SetValue(0); Thread.Sleep(delay); } // A if (result.Equals(97)) { or2.SetValue(2); Thread.Sleep(delay); or2.SetValue(0); Thread.Sleep(delay); } // B if (result.Equals(98)) { or2.SetValue(8); Thread.Sleep(delay); or2.SetValue(0); Thread.Sleep(delay); } Console.WriteLine(result); // ESC for EXIT if (result.Equals(27)) { break; } } ipcon.Disconnect(); }