예제 #1
0
        static void Main(string[] args)
        {
            var portName = System.IO.Ports.SerialPort.GetPortNames().Where(element => element != "COM1").First();

            var controller = new ZWaveController(portName);

            //controller.Channel.Log = Console.Out;

            controller.Open();
            try
            {
                Run(controller).Wait();
            }
            catch (AggregateException ex)
            {
                foreach (var inner in ex.InnerExceptions)
                {
                    LogMessage($"{inner}");
                }
            }
            catch (Exception ex)
            {
                LogMessage($"{ex}");
            }
            finally
            {
                Console.ReadLine();
                controller.Close();
            }
        }
예제 #2
0
        public async Task SensorAlarm()
        {
            // the nodeID of the motion sensor
            byte motionSensorID = 5;

            // create the controller
            var controller = new ZWaveController("COM1");

            // open the controller
            controller.Open();

            // get the included nodes
            var nodes = await controller.GetNodes();

            // get the motionSensor
            var motionSensor = nodes[motionSensorID];

            // get the SensorAlarm commandclass
            var sensorAlarm = motionSensor.GetCommandClass <SensorAlarm>();

            // subscribe to alarm event
            sensorAlarm.Changed += (s, e) => Console.WriteLine("Alarm");

            // wait
            Console.ReadLine();

            // close the controller
            controller.Close();
        }
예제 #3
0
        public static async Task Main(string[] args)
        {
            Logging.Factory.Subscribe((message) => WriteConsole(message));

            var port       = new SerialPort(SerialPort.GetPortNames().Where(element => element != "COM1").First());
            var controller = new ZWaveController(port);

            try
            {
                await controller.Open();

                WriteInfo($"Controller Version: {controller.Version}");
                WriteInfo($"Controller ChipType: {controller.ChipType}");
                WriteInfo($"Controller HomeID: {controller.HomeID:X}");
                WriteInfo($"Controller NodeID: {controller.NodeID}");
                WriteLine();
            }
            catch (Exception ex)
            {
                WriteError(ex);
            }
            finally
            {
                await controller.Close();
            }
            Console.ReadLine();
        }
예제 #4
0
        public async Task TurnWallPlugOn()
        {
            // the nodeID of the wallplug
            byte wallPlugNodeID = 3;

            // create the controller
            var controller = new ZWaveController("COM1");

            // open the controller
            controller.Open();

            // get the included nodes
            var nodes = await controller.GetNodes();

            // get the wallplug
            var wallPlug = nodes[wallPlugNodeID];

            // get the SwitchBinary commandclass
            var switchBinary = wallPlug.GetCommandClass <SwitchBinary>();

            // turn wallplug on
            await switchBinary.Set(true);

            // close the controller
            controller.Close();
        }
예제 #5
0
        public void TestMethod1()
        {
            var controller = new ZWaveController("COM3");

            controller.Open();
            var version = controller.GetVersion().Result;

            controller.Close();
        }
예제 #6
0
 /// <summary>
 /// Invoked when the application is launched normally by the end user.  Other entry points
 /// will be used such as when the application is launched to open a specific file.
 /// </summary>
 /// <param name="e">Details about the launch request and process.</param>
 protected override void OnLaunched(LaunchActivatedEventArgs e)
 {
     Task.Run(() =>
     {
         var controller = new ZWaveController(0x0658, 0x0200);
         controller.Open();
         var version = controller.GetVersion().Result;
         controller.Close();
     });
 }
예제 #7
0
        static void Main(string[] args)
        {
            var portName = System.IO.Ports.SerialPort.GetPortNames().Where(element => element != "COM1").First();

            var controller = new ZWaveController(portName);

            // netsh http add urlacl url=http://+:80/ user=Everyone
            // http://localhost:80/api/v1.0/controller/nodes/19/basic/get/
            var server = new ZWave.Net.ZWaveRestServer(controller);

            server.Log = Console.Out;

            //controller.Channel.Log = Console.Out;

            controller.Open();
            server.Open();
            try
            {
                Run(controller).Wait();
            }
            catch (AggregateException ex)
            {
                foreach (var inner in ex.InnerExceptions)
                {
                    LogMessage($"{inner}");
                }
            }
            catch (Exception ex)
            {
                LogMessage($"{ex}");
            }
            finally
            {
                Console.ReadLine();
                server.Close();
                controller.Close();
            }
        }
예제 #8
0
        static async Task Main(string[] args)
        {
            Logging.Factory.Subscribe((message) =>
            {
                if (message.Level >= LogLevel.Info)
                {
                    WriteLogRecord(message);
                }
            });

            var controller = new ZWaveController(UsbStick.AeotecZStick);

            try
            {
                await controller.Open();

                await Dump(controller);

                WriteLine();

                foreach (var node in controller.Nodes)
                {
                    await Dump(node);

                    WriteLine();
                }
            }
            catch (Exception ex)
            {
                WriteError(ex);
            }
            finally
            {
                Console.ReadLine();
                await controller.Close();
            }
        }
예제 #9
0
 public void Dispose()
 {
     _controller.ChannelClosed -= LogChannelClosed;
     _controller.Error         -= LogError;
     _controller.Close();
 }
예제 #10
0
 public void Dispose()
 {
     controller.Close();
 }