Simple C# 'NETIO PowerBOX 4Kx' Json demo application.
Features
Uses Json for data read/write Get device info Get all output status Read output status Monitor voltage, current and power data
NOTE! This application is tested with NETIO PowerBOX 4KF, minor changes may be needed to be run on other devices. To keep demo simple and short, data validation and error handling is reduced to a minimum.
Getting started
- Enable read/write in web config M2M API Protocols -> JSON API -> Enable JSON API -> Enable READ-WRITE
- Enter username and password (default is netio).
- Click Save Changes.
- Note current NETIO IP address.
- Build and run this application.
- Enter IP address, user and password.
- Click Connect button.
- If successful, Info field is populated with current NETIO data (if not, check above settings).
- Set selected outputs to ON/OFF using the Control buttons.
- Click Status button to read current NETIO putput status.
- Every second voltage, current and power values are read and updated.
Run standalone
- Create a new C#/WPF project.
- Add NetIoDriver.cs to your project.
- Include it: using NetIo;
- Depending on your settings, one or more namespaces may have to be included (see using's below).
- Init driver: netIoDriver = new NetIoDriver("192.168.11.250", netio, netio); // init driver
- Test connection: var agent = netIoDriver.GetAgent(); // get current device info
- Read data: var model = agent.Model; // reads out all agent info var root = netIoDriver.GetRoot(); // get all data
- Set output: var isOutput2Set = netIoDriver.SetState(NetIoDriver.OutputName.Output_2, NetIoDriver.Action.On); // turn on output 2
- Read output: var output4 = netIoDriver.GetOutput(NetIoDriver.OutputName.Output_4); // read output 4
- Enjoy!