-
Notifications
You must be signed in to change notification settings - Fork 1
Monitor complete
using System;
using System.Linq;
using System.Threading.Tasks;
using XSockets.Core.Common.Socket.Event.Attributes;
using XSockets.Core.XSocket;
using XSockets.Core.XSocket.Helpers;
/// <summary>
/// Controller that monitoring client will use
///
/// - The clients can set an individual temp-limit since we have state
/// - The clients can enable/disable sensors by using "EnableTemp/DisableTemp"
///
/// </summary>
public class Monitor : XSocketController
{
#region Individual TempLimit for each monitoring client
[NoEvent]
public double TempLimit { get; set; }
/// <summary>
/// Set an individual templimit... Se SensorController and the method "IrTempChange" to see usage
/// </summary>
/// <param name="tempLimit"></param>
public void SetTempLimit(double tempLimit)
{
this.TempLimit = tempLimit;
this.Invoke(this.TempLimit, "newtemplimit");
}
#endregion
/// <summary>
/// When the controller is openend by the client it sends back information about all the connected sensors.
/// </summary>
public override async Task OnOpened()
{
this.TempLimit = 10;
//Find all sensors and get latest known value and name
var data =
this.FindOn<Sensor>()
.Select(p => new {id = p.ConnectionId, p.LastValue.obj, p.LastValue.amb, name = p.Name});
//Send back sensor information
await this.Invoke(data,"sensors");
}
#region ENABLE / DISABLE SENSORTAG IR-TEMP
public void DisableIrTemp(Guid connectionId)
{
this.InvokeTo<Sensor>(p => p.ConnectionId == connectionId,"disableIrTemp");
}
public void EnableIrTemp(Guid connectionId)
{
this.InvokeTo<Sensor>(p => p.ConnectionId == connectionId, "enableIrTemp");
}
#endregion
}
Home
##Pre-Req
Software
Hardware
##Protocols
XMPP
AMQP
MQTT
WebSockets
Custom
##Raspberry Pi
Connecting
Configuration
WiFi
Update
###BLE
About
Support
GAP
Broadcast Topology
Connected Topology
GATT
Install
Configure
Connect
Read/Write
###NODEJS
Install
Install
Test
##XSockets
###Hosting
Self-hosted
Configuration
Azure worker role
###Let's build a location based chat
Chat controller
Add name & location
Target specific clients
Install
Test
###Sensor Controller
Basic
Adding state
Broadcast to all
Target specific clients
Confirm enable/disable
Complete
###Monitor Controller
Basic
OnOpened
Adding state
Turn sensor on/off
Complete
###Testing With Putty
Custom protocol
Connecting
Impersonate sensor
Impersonate monitor
###Scale Out
Azure Service Bus
##Suggested Clients
Overview
Web JavaScript
Putty
C-Sharp
TCP-IP
###MQTT
client
publish
##Azure
Hosting & scaling
##Links/Resources
Adafruit
Wikipedia