|
From: <Ba...@us...> - 2012-01-28 20:18:52
|
Revision: 4428
http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4428&view=rev
Author: BartEv
Date: 2012-01-28 20:18:43 +0000 (Sat, 28 Jan 2012)
Log Message:
-----------
Added RC command controls and help screen
Got clear of all the TAB's
Modified Paths:
--------------
trunk/plugins/VeraControl/BaseDevice.cs
trunk/plugins/VeraControl/DevCategories.cs
trunk/plugins/VeraControl/DeviceCam.cs
trunk/plugins/VeraControl/DeviceDimmer.cs
trunk/plugins/VeraControl/DeviceDoorlock.cs
trunk/plugins/VeraControl/DeviceGWeather.cs
trunk/plugins/VeraControl/DeviceGeneric.cs
trunk/plugins/VeraControl/DeviceHumidity.cs
trunk/plugins/VeraControl/DeviceLightSensor.cs
trunk/plugins/VeraControl/DevicePowerMeter.cs
trunk/plugins/VeraControl/DeviceSceneController.cs
trunk/plugins/VeraControl/DeviceSecurity.cs
trunk/plugins/VeraControl/DeviceSprinkler.cs
trunk/plugins/VeraControl/DeviceSwitch.cs
trunk/plugins/VeraControl/DeviceSystem.cs
trunk/plugins/VeraControl/DeviceTemperature.cs
trunk/plugins/VeraControl/DeviceThermostat.cs
trunk/plugins/VeraControl/DeviceWindowCovering.cs
trunk/plugins/VeraControl/DialogActionTrigger.cs
trunk/plugins/VeraControl/DialogDeviceControl.cs
trunk/plugins/VeraControl/DialogSceneControl.cs
trunk/plugins/VeraControl/JSON.cs
trunk/plugins/VeraControl/Room.cs
trunk/plugins/VeraControl/Scene.cs
trunk/plugins/VeraControl/Section.cs
trunk/plugins/VeraControl/VeraCommunication.cs
trunk/plugins/VeraControl/VeraControl.cs
trunk/plugins/VeraControl/VeraHelper.cs
Modified: trunk/plugins/VeraControl/BaseDevice.cs
===================================================================
--- trunk/plugins/VeraControl/BaseDevice.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/BaseDevice.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -18,19 +18,19 @@
/// </summary>
public class BaseDevice
{
- private long _lastUpdate = 0;
- private long _lastPendingUpdate = 0;
+ private long _lastUpdate = 0;
+ private long _lastPendingUpdate = 0;
private bool _screenUpdateRequired = false;
- private string _name = "unknown device";
- private int _id = 0;
- private int _room = 0;
+ private string _name = "unknown device";
+ private int _id = 0;
+ private int _room = 0;
// not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3)
private DevState _dsState = DevState.NONE;
- private string _comment = ""; // red(error), green(success) or blue(pending) - icon/text
+ private string _comment = ""; // red(error), green(success) or blue(pending) - icon/text
- public VeraHelper _helper = VeraHelper.Instance;
- public VeraCommunication _vera = VeraCommunication.Instance;
+ public VeraHelper _helper = VeraHelper.Instance;
+ public VeraCommunication _vera = VeraCommunication.Instance;
public BaseDevice(XmlNode xn)
{
@@ -40,7 +40,7 @@
}
}
- /// <summary>
+ /// <summary>
/// Process Vera update information
/// </summary>
public virtual bool Update(XmlNode xn)
@@ -58,8 +58,8 @@
}
// Set update flag
- screenUpdateRequired = true;
- lastUpdate = DateTime.Now.Ticks;
+ screenUpdateRequired = true;
+ lastUpdate = DateTime.Now.Ticks;
return true;
}
@@ -75,14 +75,14 @@
public int id
{
- get { return _id; }
- set { }
+ get { return _id; }
+ set { }
}
public string name
{
- get { return _name; }
- set { }
+ get { return _name; }
+ set { }
}
public bool InRoom(int id)
@@ -93,19 +93,19 @@
public int room
{
get { return _room; }
- set { _room = value; }
+ set { _room = value; }
}
public DevState commstate
{
get { return _dsState; }
- set { }
+ set { }
}
public string comment
{
get { return (commstate != DevState.NONE ? _comment : ""); }
- set { }
+ set { }
}
public bool screenUpdateRequired
@@ -128,11 +128,11 @@
public void ReportPendingRequest()
{
- _dsState = DevState.PENDING;
- _comment = "Sending command...";
+ _dsState = DevState.PENDING;
+ _comment = "Sending command...";
screenUpdateRequired = true;
lastUpdate = DateTime.Now.Ticks;
- _lastPendingUpdate = lastUpdate;
+ _lastPendingUpdate = lastUpdate;
}
/// <summary>
@@ -140,19 +140,19 @@
/// </summary>
public void ReportRequestError(string message)
{
- _dsState = DevState.COMMAND_ERROR;
- _comment = message;
+ _dsState = DevState.COMMAND_ERROR;
+ _comment = message;
screenUpdateRequired = true;
- lastUpdate = DateTime.Now.Ticks;
+ lastUpdate = DateTime.Now.Ticks;
}
public void ClearCommState()
{
if (_dsState != DevState.NONE)
{
- _dsState = DevState.NONE;
- screenUpdateRequired = true;
- lastUpdate = DateTime.Now.Ticks;
+ _dsState = DevState.NONE;
+ screenUpdateRequired = true;
+ lastUpdate = DateTime.Now.Ticks;
}
}
Modified: trunk/plugins/VeraControl/DevCategories.cs
===================================================================
--- trunk/plugins/VeraControl/DevCategories.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DevCategories.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -13,45 +13,45 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DevCategories.
- /// </summary>
- public class DevCategories
- {
- public DevCategories(XmlNode xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- private string _name = "unknown category";
- private int _id = 0;
- public VeraHelper _helper = VeraHelper.Instance;
-
- public bool Update(XmlNode xn)
- {
- _name = _helper.GetAttrAsString(xn, "name", _name);
- _id = _helper.GetAttrAsInt (xn, "id", _id);
- return true;
- }
-
- public int id
- {
- get { return _id; }
- set { }
- }
-
- public string name
- {
- get { return _name; }
- set { }
- }
+ /// <summary>
+ /// Description of DevCategories.
+ /// </summary>
+ public class DevCategories
+ {
+ public DevCategories(XmlNode xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ }
+ }
+
+ private string _name = "unknown category";
+ private int _id = 0;
+ public VeraHelper _helper = VeraHelper.Instance;
+
+ public bool Update(XmlNode xn)
+ {
+ _name = _helper.GetAttrAsString(xn, "name", _name);
+ _id = _helper.GetAttrAsInt (xn, "id", _id);
+ return true;
+ }
+
+ public int id
+ {
+ get { return _id; }
+ set { }
+ }
+
+ public string name
+ {
+ get { return _name; }
+ set { }
+ }
- public override string ToString()
- {
- return name;
- }
- }
+ public override string ToString()
+ {
+ return name;
+ }
+ }
}
Modified: trunk/plugins/VeraControl/DeviceCam.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceCam.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DeviceCam.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -11,139 +11,145 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DeviceCam.
- /// </summary>
- public class DeviceCam : DeviceGeneric
- {
- private string _ip = "127.0.0.1";
- private string _url = "/";
- private string _stream = "";
- private string _videoUrl = "";
- private int _refreshRate = 2;
- private string _user = "";
- private string _pass = "";
-
- public DeviceCam(XmlNode xn): base (xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- public override bool Update(XmlNode xn)
- {
- _ip = _helper.GetAttrAsString(xn, "ip", _ip);
- _url = _helper.GetAttrAsString(xn, "url", _url);
- _stream = _helper.GetAttrAsString(xn, "streaming", _stream);
- _videoUrl = _helper.GetAttrAsString(xn, "videourls", _videoUrl);
- _user = _helper.GetAttrAsString(xn, "username", "");
- _pass = _helper.GetAttrAsString(xn, "password", "");
-
- return base.Update(xn);
- }
-
- private string passString
- {
- get {
- if (_user == "")
- {
- return "";
- }
- return _user + ":" + _pass + "@";
- }
- set { }
- }
-
- public string imgUrl
- {
- get { return _vera.veraAddress + "/data_request?id=cam_image¶meters=get_video_frame&Device_Num=" + id + "&rand=" + DateTime.Now.Ticks;
- // return "http://" + passString + m_sIp + "/" + m_sUrl.Replace("%2F", "/");
- }
- set { }
- }
-
- public string streamUrl
- {
- get { return "http://" + passString + _ip + "/" + _stream.Replace("%2F", "/"); }
- set { }
- }
-
- public int refreshRate
- {
- get { return _refreshRate; }
- set { _refreshRate = value; }
- }
-
- private bool HasRefreshDelayPassed(long lastcheck)
- {
- return ((_helper.GetSecondsSince1970() - refreshRate) > (lastcheck / TimeSpan.TicksPerSecond));
- }
-
- public override string GetIconName()
- {
- return "Ip_Camera";
- }
-
- public override bool NewScreenUpdateWaitingAndClearFlag( )
- {
- // Invoking this method will clear the update ready flag -> so caller need to handle the update
- // A cam device requires an update every refreshRate seconds
- bool b = screenUpdateRequired || HasRefreshDelayPassed(DateTime.Now.Ticks);
- screenUpdateRequired = false;
- if (b)
- {
- lastUpdate = DateTime.Now.Ticks;
- }
- return b;
- }
-
- public override bool NewUpdateSince(long lTimePreviousCheck)
- {
- bool b = (lTimePreviousCheck <= lastUpdate) || HasRefreshDelayPassed(lastUpdate);
- if (b)
- {
- lastUpdate = DateTime.Now.Ticks;
- }
- return b;
- }
-
- private void Move(string direction)
- {
- if (id == 0)
- {
- _vera.status.system.ReportCommandError("Unknown device");
- screenUpdateRequired = true;
- return;
- }
- string cmd = "?id=lu_action&DeviceNum=" + id + "&serviceId=urn:micasaverde-com:serviceId:PanTiltZoom1&action=" + direction;
- _vera.DoVeraCommandRequest(cmd, ReportRequestError);
- }
-
- public override void MoveUp()
- {
- Move("MoveUp");
- }
- public override void MoveLeft()
- {
- Move("MoveLeft");
- }
- public override void MoveRight()
- {
- Move("MoveRight");
- }
- public override void MoveDown()
- {
- Move("MoveDown");
- }
- public override void ZoomIn()
- {
- Move("ZoomIn");
- }
- public override void ZoomOut()
- {
- Move("ZoomOut");
- }
- }
+ /// <summary>
+ /// Description of DeviceCam.
+ /// </summary>
+ public class DeviceCam : DeviceGeneric
+ {
+ private string _ip = "127.0.0.1";
+ private string _url = "/";
+ private string _stream = "";
+ private string _videoUrl = "";
+ private int _refreshRate = 2;
+ private string _user = "";
+ private string _pass = "";
+
+ public DeviceCam(XmlNode xn): base (xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ }
+ }
+
+ public override bool Update(XmlNode xn)
+ {
+ _ip = _helper.GetAttrAsString(xn, "ip", _ip);
+ _url = _helper.GetAttrAsString(xn, "url", _url);
+ _stream = _helper.GetAttrAsString(xn, "streaming", _stream);
+ _videoUrl = _helper.GetAttrAsString(xn, "videourls", _videoUrl);
+ _user = _helper.GetAttrAsString(xn, "username", "");
+ _pass = _helper.GetAttrAsString(xn, "password", "");
+
+ return base.Update(xn);
+ }
+
+ private string passString
+ {
+ get {
+ if (_user == "")
+ {
+ return "";
+ }
+ return _user + ":" + _pass + "@";
+ }
+ set { }
+ }
+
+ public string imgUrl
+ {
+ get { return _vera.veraAddress + "/data_request?id=cam_image¶meters=get_video_frame&Device_Num=" + id + "&rand=" + DateTime.Now.Ticks;
+ // return "http://" + passString + m_sIp + "/" + m_sUrl.Replace("%2F", "/");
+ }
+ set { }
+ }
+
+ public string streamUrl
+ {
+ get { return "http://" + passString + _ip + "/" + _stream.Replace("%2F", "/"); }
+ set { }
+ }
+
+ public int refreshRate
+ {
+ get { return _refreshRate; }
+ set { _refreshRate = value; }
+ }
+
+ private bool HasRefreshDelayPassed(long lastcheck)
+ {
+ return ((_helper.GetSecondsSince1970() - refreshRate) > (lastcheck / TimeSpan.TicksPerSecond));
+ }
+
+ public override bool isControllable
+ {
+ get { return true; }
+ set { }
+ }
+
+ public override string GetIconName()
+ {
+ return "Ip_Camera";
+ }
+
+ public override bool NewScreenUpdateWaitingAndClearFlag( )
+ {
+ // Invoking this method will clear the update ready flag -> so caller need to handle the update
+ // A cam device requires an update every refreshRate seconds
+ bool b = screenUpdateRequired || HasRefreshDelayPassed(DateTime.Now.Ticks);
+ screenUpdateRequired = false;
+ if (b)
+ {
+ lastUpdate = DateTime.Now.Ticks;
+ }
+ return b;
+ }
+
+ public override bool NewUpdateSince(long lTimePreviousCheck)
+ {
+ bool b = (lTimePreviousCheck <= lastUpdate) || HasRefreshDelayPassed(lastUpdate);
+ if (b)
+ {
+ lastUpdate = DateTime.Now.Ticks;
+ }
+ return b;
+ }
+
+ private void Move(string direction)
+ {
+ if (id == 0)
+ {
+ _vera.status.system.ReportCommandError("Unknown device");
+ screenUpdateRequired = true;
+ return;
+ }
+ string cmd = "?id=lu_action&DeviceNum=" + id + "&serviceId=urn:micasaverde-com:serviceId:PanTiltZoom1&action=" + direction;
+ _vera.DoVeraCommandRequest(cmd, ReportRequestError);
+ }
+
+ public override void MoveUp()
+ {
+ Move("MoveUp");
+ }
+ public override void MoveLeft()
+ {
+ Move("MoveLeft");
+ }
+ public override void MoveRight()
+ {
+ Move("MoveRight");
+ }
+ public override void MoveDown()
+ {
+ Move("MoveDown");
+ }
+ public override void ZoomIn()
+ {
+ Move("ZoomIn");
+ }
+ public override void ZoomOut()
+ {
+ Move("ZoomOut");
+ }
+ }
}
Modified: trunk/plugins/VeraControl/DeviceDimmer.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -13,107 +13,104 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DeviceDimmer.
- /// </summary>
- public class DeviceDimmer : DeviceGeneric
- {
- private int _level = 0;
- private string _watt = "-";
- private string _kwh = "-";
-
- public DeviceDimmer(XmlNode xn): base (xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- public override bool Update(XmlNode xn)
- {
- _level = _helper.GetAttrAsInt (xn, "level", _level);
- _watt = _helper.GetAttrAsString(xn, "watts", _watt);
- _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh);
-
- return base.Update(xn);
- }
-
- public string watts
- {
- get { return _watt; }
- set { }
- }
-
- public override bool status
- {
- get { return (_level > 0); }
- set {
-
- }
- }
-
- public override int level
- {
- get { return _level; }
- set
- {
- int newValue = value;
- if (newValue > 100) {
- newValue = 100;
- } else {
- if (newValue < 0) { newValue = 0; }
- }
- if (id > 0) // Only send when a valid ID is found
- {
- ReportPendingRequest();
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString() +
- "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget" +
- "&newLoadlevelTarget=" + value;
- _vera.DoVeraCommandRequest(cmd, ReportRequestError);
- }
- _level = newValue;
- }
- }
-
- public override int maxLevel
- {
- get { return 100; }
- set { }
- }
-
- public override string ToString()
- {
- return name + " [" + GetStatusText() + "]";
- }
-
- public override bool isControllable
- {
- get { return true; }
- set { }
- }
-
- public override string GetIconName()
- {
- string leveltxt = "0";
- if (level > 0) { leveltxt = "25"; }
- if (level > 25) { leveltxt = "50"; }
- if (level > 50) { leveltxt = "75"; }
- if (level > 75) { leveltxt = "100"; }
-
- return "Dimmable_Light_" + leveltxt;
- }
-
-
- public override string GetExtraText()
- {
- return (_kwh != "" ? _kwh + "kWh" : "");
- }
-
- public override string GetStatusText()
- {
- return (status ? level.ToString() + "%" : "Off");
- }
- }
+ /// <summary>
+ /// Description of DeviceDimmer.
+ /// </summary>
+ public class DeviceDimmer : DeviceGeneric
+ {
+ private int _level = 0;
+ private string _watt = "-";
+ private string _kwh = "-";
+
+ public DeviceDimmer(XmlNode xn): base (xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ }
+ }
+
+ public override bool Update(XmlNode xn)
+ {
+ _level = _helper.GetAttrAsInt (xn, "level", _level);
+ _watt = _helper.GetAttrAsString(xn, "watts", _watt);
+ _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh);
+
+ return base.Update(xn);
+ }
+
+ public string watts
+ {
+ get { return _watt; }
+ set { }
+ }
+
+ public override bool status
+ {
+ get { return (_level > 0); }
+ set { level = (value ? maxLevel : minLevel); }
+ }
+
+ public override int level
+ {
+ get { return _level; }
+ set
+ {
+ int newValue = value;
+ if (newValue > maxLevel) {
+ newValue = maxLevel;
+ } else {
+ if (newValue < minLevel) { newValue = minLevel; }
+ }
+ if (id > 0) // Only send when a valid ID is found
+ {
+ ReportPendingRequest();
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString() +
+ "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget" +
+ "&newLoadlevelTarget=" + value;
+ _vera.DoVeraCommandRequest(cmd, ReportRequestError);
+ }
+ _level = newValue;
+ }
+ }
+
+ public override int maxLevel
+ {
+ get { return 100; }
+ set { }
+ }
+
+ public override string ToString()
+ {
+ return name + " [" + GetStatusText() + "]";
+ }
+
+ public override bool isControllable
+ {
+ get { return true; }
+ set { }
+ }
+
+ public override string GetIconName()
+ {
+ string leveltxt = "0";
+ if (level > 0) { leveltxt = "25"; }
+ if (level > 25) { leveltxt = "50"; }
+ if (level > 50) { leveltxt = "75"; }
+ if (level > 75) { leveltxt = "100"; }
+
+ return "Dimmable_Light_" + leveltxt;
+ }
+
+ public override string GetExtraText()
+ {
+ return (_kwh != "" ? _kwh + "kWh" : "");
+ }
+
+ public override string GetStatusText()
+ {
+ return (status ? level.ToString() + "%" : "Off");
+ }
+ }
}
Modified: trunk/plugins/VeraControl/DeviceDoorlock.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -13,79 +13,78 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DeviceDoorlock.
- /// </summary>
- public class DeviceDoorlock : DeviceGeneric
- {
- private bool _status = false;
-
- public DeviceDoorlock( XmlNode xn ): base (xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- public override bool Update(XmlNode xn)
- {
- _status = _helper.GetAttrAsBool(xn, "status", _status);
-
- return base.Update(xn);
- }
-
- public override bool status
- {
- get { return _status; }
- set {
- if (id > 0) // Only send when a valid ID is found
- {
- ReportPendingRequest();
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
- "&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget" +
- "&newTargetValue="+(value ? "1" : "0");
- _vera.DoVeraCommandRequest(cmd, ReportRequestError);
- }
- }
- }
-
- public override int level
- {
- get { return (_status ? 1 : 0); }
- set
- {
- status = (value > 0);
- }
- }
-
- public override int maxLevel
- {
- get { return 1; }
- set { }
- }
-
- public override string ToString()
- {
- return name + " [" + GetStatusText() + "]";
- }
-
- public override bool isControllable
- {
- get { return true; }
- set { }
- }
-
- public override string GetIconName()
- {
- return "Door_" + (_status ? "LOCKED" : "UNLOCKED");
- }
-
- public override string GetStatusText()
- {
- return (status ? "Locked" : "Unlocked");
- }
-
- }
+ /// <summary>
+ /// Description of DeviceDoorlock.
+ /// </summary>
+ public class DeviceDoorlock : DeviceGeneric
+ {
+ private bool _status = false;
+
+ public DeviceDoorlock( XmlNode xn ): base (xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ }
+ }
+
+ public override bool Update(XmlNode xn)
+ {
+ _status = _helper.GetAttrAsBool(xn, "status", _status);
+
+ return base.Update(xn);
+ }
+
+ public override bool status
+ {
+ get { return _status; }
+ set {
+ if (id > 0) // Only send when a valid ID is found
+ {
+ ReportPendingRequest();
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
+ "&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget" +
+ "&newTargetValue="+(value ? "1" : "0");
+ _vera.DoVeraCommandRequest(cmd, ReportRequestError);
+ }
+ }
+ }
+
+ public override int level
+ {
+ get { return (_status ? 1 : 0); }
+ set
+ {
+ status = (value > 0);
+ }
+ }
+
+ public override int maxLevel
+ {
+ get { return 1; }
+ set { }
+ }
+
+ public override string ToString()
+ {
+ return name + " [" + GetStatusText() + "]";
+ }
+
+ public override bool isControllable
+ {
+ get { return true; }
+ set { }
+ }
+
+ public override string GetIconName()
+ {
+ return "Door_" + (_status ? "LOCKED" : "UNLOCKED");
+ }
+
+ public override string GetStatusText()
+ {
+ return (status ? "Locked" : "Unlocked");
+ }
+ }
}
Modified: trunk/plugins/VeraControl/DeviceGWeather.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceGWeather.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DeviceGWeather.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -13,49 +13,50 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DeviceGWeather.
- /// </summary>
- public class DeviceGWeather : DeviceGeneric
- {
- private string _condition = "-";
- private string _windCondition = "-";
-
- public DeviceGWeather(XmlNode xn): base (xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- public override bool Update(XmlNode xn)
- {
- _condition = _helper.GetAttrAsString(xn, "Condition", _condition); // Google Weather Plugin
- _condition = _helper.GetAttrAsString(xn, "condition", _condition); // World Weather plugin
- _windCondition = _helper.GetAttrAsString(xn, "WindCondition", _windCondition);
- _windCondition = _helper.GetAttrAsString(xn, "windcondition", _windCondition);
-
- return base.Update(xn);
- }
-
- public override string ToString()
- {
- return name + " [" + GetStatusText() + "]";
- }
-
- public override string GetStatusText()
- {
- return _condition.Replace("_", " ");
- }
- public override string GetExtraText()
- {
- return _windCondition;
- }
-
- public override string GetIconName()
- {
- return "location";
- }
- }
+ /// <summary>
+ /// Description of DeviceGWeather.
+ /// </summary>
+ public class DeviceGWeather : DeviceGeneric
+ {
+ private string _condition = "-";
+ private string _windCondition = "-";
+
+ public DeviceGWeather(XmlNode xn): base (xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ }
+ }
+
+ public override bool Update(XmlNode xn)
+ {
+ _condition = _helper.GetAttrAsString(xn, "Condition", _condition); // Google Weather Plugin
+ _condition = _helper.GetAttrAsString(xn, "condition", _condition); // World Weather plugin
+ _windCondition = _helper.GetAttrAsString(xn, "WindCondition", _windCondition);
+ _windCondition = _helper.GetAttrAsString(xn, "windcondition", _windCondition);
+
+ return base.Update(xn);
+ }
+
+ public override string ToString()
+ {
+ return name + " [" + GetStatusText() + "]";
+ }
+
+ public override string GetStatusText()
+ {
+ return _condition.Replace("_", " ");
+ }
+
+ public override string GetExtraText()
+ {
+ return _windCondition;
+ }
+
+ public override string GetIconName()
+ {
+ return "location";
+ }
+ }
}
Modified: trunk/plugins/VeraControl/DeviceGeneric.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -14,132 +14,157 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DeviceGeneric.
- /// </summary>
- public class DeviceGeneric : BaseDevice
- {
- private string _altId = "";
- private int _category = 0;
-
- public DeviceGeneric(XmlNode xn): base (xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- public override bool Update(XmlNode xn)
- {
- _altId = _helper.GetAttrAsString(xn, "altid", _altId);
- _category = _helper.GetAttrAsInt (xn, "category", _category);
-
- bool b = base.Update(xn);
- // Make sure the room exists
- if (room == 0 || !_vera.status.IsRoomFound(room))
- {
- if (!_vera.status.IsRoomFound(0))
- { // create dummy room to attach to
- _vera.rooms.Add(new Room(null));
- }
- room = 0;
- }
+ /// <summary>
+ /// Description of DeviceGeneric.
+ /// </summary>
+ public class DeviceGeneric : BaseDevice
+ {
+ private string _altId = "";
+ private int _category = 0;
+ private int _stepsize = 0;
+
+ public DeviceGeneric(XmlNode xn): base (xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ if (maxLevel > 0 && minLevel >= 0)
+ {
+ _stepsize = (int)Math.Max(1, Math.Round((decimal)((maxLevel - minLevel) / 10)));
+ }
+ }
+ }
+
+ public override bool Update(XmlNode xn)
+ {
+ _altId = _helper.GetAttrAsString(xn, "altid", _altId);
+ _category = _helper.GetAttrAsInt (xn, "category", _category);
+
+ bool b = base.Update(xn);
+ // Make sure the room exists
+ if (room == 0 || !_vera.status.IsRoomFound(room))
+ {
+ if (!_vera.status.IsRoomFound(0))
+ { // create dummy room to attach to
+ _vera.rooms.Add(new Room(null));
+ }
+ room = 0;
+ }
+ return b;
+ }
+
+ public string altid
+ {
+ get { return _altId; }
+ }
+
+ public int category
+ {
+ get { return _category; }
+ }
+
+ public virtual bool isControllable
+ {
+ get { return false; }
+ set { }
+ }
+
+ public virtual bool status
+ {
+ get { return false; }
+ set { }
+ }
+
+ public virtual int level
+ {
+ get { return 0; }
+ set { }
+ }
- return b;
- }
-
- public string altid
- {
- get { return _altId; }
- set { }
- }
-
- public int category
- {
- get { return _category; }
- set { }
- }
-
- public virtual bool isControllable
- {
- get { return false; }
- set { }
- }
-
- public virtual bool status
- {
- get { return false; }
- set { }
- }
-
- public virtual int level
- {
- get { return 0; }
- set { }
- }
-
- public virtual string mode
- {
- get { return ""; }
- set { }
- }
-
- public virtual int maxLevel
- {
- get { return -1; }
- set { }
- }
- public virtual int minLevel
- {
- get { return 0; }
- set { }
- }
-
- public override string GetIconName()
- {
- return "generic_sensor";
- }
-
- public override string GetStatusText()
- {
- return "";
- }
-
- public virtual string GetExtraText()
- {
- return "";
- }
+ public virtual int stepSize
+ {
+ get { return _stepsize; }
+ set { _stepsize = value; }
+ }
- public virtual string [] GetCommands()
- {
- return new string [] {"Off", "On"};
- }
-
- // Overridables for Cam Device
- public virtual void MoveUp()
- {
- // do nothing
- }
- public virtual void MoveLeft()
- {
- // do nothing
- }
- public virtual void MoveRight()
- {
- // do nothing
- }
- public virtual void MoveDown()
- {
- // do nothing
- }
- public virtual void ZoomIn()
- {
- // do nothing
- }
- public virtual void ZoomOut()
- {
- // do nothing
- }
- }
+ public virtual void IncreaseLevel()
+ {
+ if (stepSize > 0)
+ {
+ level += stepSize;
+ }
+ }
+
+ public virtual void DecreaseLevel()
+ {
+ if (stepSize > 0)
+ {
+ level -= stepSize;
+ }
+ }
+
+ public virtual string mode
+ {
+ get { return ""; }
+ set { }
+ }
+
+ public virtual int maxLevel
+ {
+ get { return -1; }
+ set { }
+ }
+
+ public virtual int minLevel
+ {
+ get { return 0; }
+ set { }
+ }
+
+ public override string GetIconName()
+ {
+ return "generic_sensor";
+ }
+
+ public override string GetStatusText()
+ {
+ return "";
+ }
+
+ public virtual string GetExtraText()
+ {
+ return "";
+ }
+
+ public virtual string [] GetCommands()
+ {
+ return new string [] {"Off", "On"};
+ }
+
+ // Overridables for Cam Device
+ public virtual void MoveUp()
+ {
+ // do nothing
+ }
+ public virtual void MoveLeft()
+ {
+ // do nothing
+ }
+ public virtual void MoveRight()
+ {
+ // do nothing
+ }
+ public virtual void MoveDown()
+ {
+ // do nothing
+ }
+ public virtual void ZoomIn()
+ {
+ // do nothing
+ }
+ public virtual void ZoomOut()
+ {
+ // do nothing
+ }
+ }
}
Modified: trunk/plugins/VeraControl/DeviceHumidity.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceHumidity.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DeviceHumidity.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -13,52 +13,52 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DeviceHumidity.
- /// </summary>
- public class DeviceHumidity : DeviceGeneric
- {
- private int _level = 0;
-
- public DeviceHumidity(XmlNode xn): base (xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- public override bool Update(XmlNode xn)
- {
- _level = _helper.GetAttrAsInt(xn, "humidity", _level);
- return base.Update(xn);
- }
-
- public override int level
- {
- get { return _level; }
- set {}
- }
-
- public override int maxLevel
- {
- get { return 100; }
- set { }
- }
-
- public override string ToString()
- {
- return name + " [" + level.ToString() + "%]";
- }
-
- public override string GetIconName()
- {
- return "Humidity_Sensor";
- }
-
- public override string GetStatusText()
- {
- return level + "%";
- }
- }
+ /// <summary>
+ /// Description of DeviceHumidity.
+ /// </summary>
+ public class DeviceHumidity : DeviceGeneric
+ {
+ private int _level = 0;
+
+ public DeviceHumidity(XmlNode xn) : base (xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ }
+ }
+
+ public override bool Update(XmlNode xn)
+ {
+ _level = _helper.GetAttrAsInt(xn, "humidity", _level);
+ return base.Update(xn);
+ }
+
+ public override int level
+ {
+ get { return _level; }
+ set {}
+ }
+
+ public override int maxLevel
+ {
+ get { return 100; }
+ set { }
+ }
+
+ public override string ToString()
+ {
+ return name + " [" + level.ToString() + "%]";
+ }
+
+ public override string GetIconName()
+ {
+ return "Humidity_Sensor";
+ }
+
+ public override string GetStatusText()
+ {
+ return level + "%";
+ }
+ }
}
Modified: trunk/plugins/VeraControl/DeviceLightSensor.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceLightSensor.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DeviceLightSensor.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -13,59 +13,59 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DeviceLightSensor.
- /// </summary>
- public class DeviceLightSensor : DeviceGeneric
- {
- private int _level = 0;
-
- public DeviceLightSensor(XmlNode xn): base (xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- public override bool Update(XmlNode xn)
- {
- _level = _helper.GetAttrAsInt(xn, "level", _level);
- _level = _helper.GetAttrAsInt(xn, "light", _level);
- return base.Update(xn);
- }
-
- public override bool status
- {
- get { return (_level > 0); }
- set { }
- }
-
- public override int level
- {
- get { return _level; }
- set { }
- }
-
- public override int maxLevel
- {
- get { return 100; }
- set { }
- }
+ /// <summary>
+ /// Description of DeviceLightSensor.
+ /// </summary>
+ public class DeviceLightSensor : DeviceGeneric
+ {
+ private int _level = 0;
+
+ public DeviceLightSensor(XmlNode xn) : base (xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ }
+ }
+
+ public override bool Update(XmlNode xn)
+ {
+ _level = _helper.GetAttrAsInt(xn, "level", _level);
+ _level = _helper.GetAttrAsInt(xn, "light", _level);
+ return base.Update(xn);
+ }
+
+ public override bool status
+ {
+ get { return (_level > 0); }
+ set { }
+ }
+
+ public override int level
+ {
+ get { return _level; }
+ set { }
+ }
+
+ public override int maxLevel
+ {
+ get { return 100; }
+ set { }
+ }
- public override string ToString()
- {
- return name + " [" + GetStatusText() + "]";
- }
-
- public override string GetIconName()
- {
- return "Light_Sensor";
- }
-
- public override string GetStatusText()
- {
- return level.ToString() + "%";
- }
- }
+ public override string ToString()
+ {
+ return name + " [" + GetStatusText() + "]";
+ }
+
+ public override string GetIconName()
+ {
+ return "Light_Sensor";
+ }
+
+ public override string GetStatusText()
+ {
+ return level.ToString() + "%";
+ }
+ }
}
Modified: trunk/plugins/VeraControl/DevicePowerMeter.cs
===================================================================
--- trunk/plugins/VeraControl/DevicePowerMeter.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DevicePowerMeter.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -13,71 +13,71 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DevicePowerMeter.
- /// </summary>
- public class DevicePowerMeter : DeviceGeneric
- {
- private int _level = 0;
- private string _kwh = "";
-
- public DevicePowerMeter(XmlNode xn): base (xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- public override bool Update(XmlNode xn)
- {
- _level = _helper.GetAttrAsInt (xn, "watts", _level);
- _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh);
- return base.Update(xn);
- }
-
- public string watts
- {
- get { return _level.ToString(); }
- set { }
- }
-
- public override bool status
- {
- get { return (_level > 0); }
- set { }
- }
-
- public override int level
- {
- get { return _level; }
- set { }
- }
-
- public override int maxLevel
- {
- get { return 1000; }
- set { }
- }
-
- public override string ToString()
- {
- return name + " [" + GetStatusText() + "]";
- }
-
- public override string GetIconName()
- {
- return "Power_Meter";
- }
-
- public override string GetExtraText()
- {
- return (_kwh != "" ? _kwh + "kWh" : "");
- }
-
- public override string GetStatusText()
- {
- return level.ToString() + "W";
- }
- }
+ /// <summary>
+ /// Description of DevicePowerMeter.
+ /// </summary>
+ public class DevicePowerMeter : DeviceGeneric
+ {
+ private int _level = 0;
+ private string _kwh = "";
+
+ public DevicePowerMeter(XmlNode xn) : base (xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ }
+ }
+
+ public override bool Update(XmlNode xn)
+ {
+ _level = _helper.GetAttrAsInt (xn, "watts", _level);
+ _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh);
+ return base.Update(xn);
+ }
+
+ public string watts
+ {
+ get { return _level.ToString(); }
+ set { }
+ }
+
+ public override bool status
+ {
+ get { return (_level > 0); }
+ set { }
+ }
+
+ public override int level
+ {
+ get { return _level; }
+ set { }
+ }
+
+ public override int maxLevel
+ {
+ get { return 1000; }
+ set { }
+ }
+
+ public override string ToString()
+ {
+ return name + " [" + GetStatusText() + "]";
+ }
+
+ public override string GetIconName()
+ {
+ return "Power_Meter";
+ }
+
+ public override string GetExtraText()
+ {
+ return (_kwh != "" ? _kwh + "kWh" : "");
+ }
+
+ public override string GetStatusText()
+ {
+ return level.ToString() + "W";
+ }
+ }
}
Modified: trunk/plugins/VeraControl/DeviceSceneController.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceSceneController.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DeviceSceneController.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -11,60 +11,60 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DeviceSceneController.
- /// </summary>
- public class DeviceSceneController: DeviceGeneric
- {
- private bool _isTripped = false;
-
- public DeviceSceneController( XmlNode xn ): base (xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- public override bool Update(XmlNode xn)
- {
- _isTripped = _helper.GetAttrAsBool(xn, "status", _isTripped);
- _isTripped = _helper.GetAttrAsBool(xn, "tripped", _isTripped);
- return base.Update(xn);
- }
-
- public override bool status
- {
- get { return _isTripped; }
- set { }
- }
-
- public bool isTripped
- {
- get { return _isTripped; }
- set { }
- }
-
- public override int level
- {
- get { return (_isTripped ? 1 : 0); }
- set { }
- }
-
- public override string ToString()
- {
- return name + " [" + GetStatusText() + "]";
- }
-
- public override string GetIconName()
- {
- return "Motion_Sensor_" + (_isTripped ? "100" : "0");
- }
-
- public override string GetStatusText()
- {
- return (status ? "ACTIVE" : "standby");
- }
+ /// <summary>
+ /// Description of DeviceSceneController.
+ /// </summary>
+ public class DeviceSceneController: DeviceGeneric
+ {
+ private bool _isTripped = false;
+
+ public DeviceSceneController( XmlNode xn ) : base (xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ }
+ }
+
+ public override bool Update(XmlNode xn)
+ {
+ _isTripped = _helper.GetAttrAsBool(xn, "status", _isTripped);
+ _isTripped = _helper.GetAttrAsBool(xn, "tripped", _isTripped);
+ return base.Update(xn);
+ }
+
+ public override bool status
+ {
+ get { return _isTripped; }
+ set { }
+ }
+
+ public bool isTripped
+ {
+ get { return _isTripped; }
+ set { }
+ }
+
+ public override int level
+ {
+ get { return (_isTripped ? 1 : 0); }
+ set { }
+ }
+
+ public override string ToString()
+ {
+ return name + " [" + GetStatusText() + "]";
+ }
+
+ public override string GetIconName()
+ {
+ return "Motion_Sensor_" + (_isTripped ? "100" : "0");
+ }
+
+ public override string GetStatusText()
+ {
+ return (status ? "ACTIVE" : "standby");
+ }
- }
+ }
}
Modified: trunk/plugins/VeraControl/DeviceSecurity.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceSecurity.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DeviceSecurity.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -14,85 +14,87 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DeviceSecurity.
- /// </summary>
- public class DeviceSecurity : DeviceGeneric
- {
- private bool _isTripped = false;
- private bool _isArmed = true;
-
- public DeviceSecurity(XmlNode xn): base (xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- public override bool Update(XmlNode xn)
- {
- _isTripped = _helper.GetAttrAsBool(xn, "tripped", _isTripped);
- _isArmed = _helper.GetAttrAsBool(xn, "armed", _isArmed);
- return base.Update(xn);
- }
-
- public override bool status
- {
- get { return _isArmed; }
- set {
- if (id > 0) // Only send when a valid ID is found
- {
- ReportPendingRequest();
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
- "&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&action=SetArmed" +
- "&newArmedValue=" + (value ? "1" : "0");
- _vera.DoVeraCommandRequest(cmd, ReportRequestError);
- }
- }
- }
-
- public bool isTripped
- {
- get { return _isTripped; }
- set { }
- }
-
- public override int level
- {
- get { return (_isArmed ? 1 : 0); }
- set { status = (value > 0); }
- }
-
- public override int maxLevel
- {
- get { return 1; }
- set { }
- }
- public override bool isControllable
- {
- get { return true; }
- set { }
- }
- public override string ToString()
- {
- return name + " [" + GetStatusText() + "]";
- }
-
- public override string GetIconName()
- {
- return "Motion_Sensor_" + (_isTripped ? "100" : "0");
- }
-
- public override string GetStatusText()
- {
- return (status ? ( isTripped ? "TRIPPED" : "standby") : "bypass");
- }
+ /// <summary>
+ /// Description of DeviceSecurity.
+ /// </summary>
+ public class DeviceSecurity : DeviceGeneric
+ {
+ private bool _isTripped = false;
+ private bool _isArmed = true;
+
+ public DeviceSecurity(XmlNode xn) : base (xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ }
+ }
+
+ public override bool Update(XmlNode xn)
+ {
+ _isTripped = _helper.GetAttrAsBool(xn, "tripped", _isTripped);
+ _isArmed = _helper.GetAttrAsBool(xn, "armed", _isArmed);
+ return base.Update(xn);
+ }
+
+ public override bool status
+ {
+ get { return _isArmed; }
+ set {
+ if (id > 0) // Only send when a valid ID is found
+ {
+ ReportPendingRequest();
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
+ "&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&action=SetArmed" +
+ "&newArmedValue=" + (value ? "1" : "0");
+ _vera.DoVeraCommandRequest(cmd, ReportRequestError);
+ }
+ }
+ }
+
+ public bool isTripped
+ {
+ get { return _isTripped; }
+ set { }
+ }
+
+ public override int level
+ {
+ get { return (_isArmed ? 1 : 0); }
+ set { status = (value > 0); }
+ }
+
+ public override int maxLevel
+ {
+ get { return 1; }
+ set { }
+ }
- public override string [] GetCommands()
- {
- return new string [] {"Bypass", "Arm"};
- }
- }
+ public override bool isControllable
+ {
+ get { return true; }
+ set { }
+ }
+
+ public override string ToString()
+ {
+ return name + " [" + GetStatusText() + "]";
+ }
+
+ public override string GetIconName()
+ {
+ return "Motion_Sensor_" + (_isTripped ? "100" : "0");
+ }
+
+ public override string GetStatusText()
+ {
+ return (status ? ( isTripped ? "TRIPPED" : "standby") : "bypass");
+ }
+
+ public override string [] GetCommands()
+ {
+ return new string [] {"Bypass", "Arm"};
+ }
+ }
}
Modified: trunk/plugins/VeraControl/DeviceSprinkler.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -14,108 +14,108 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DeviceSprinkler.
- /// </summary>
- public class DeviceSprinkler : DeviceGeneric
- {
- private bool _status = false;
- private string _mode = "-";
- private string _shortMode = "-";
- private string _operationMode = "-";
- private string _condition = "-";
-
- public DeviceSprinkler(XmlNode xn): base (xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- public override bool Update(XmlNode xn)
- {
- _status = _helper.GetAttrAsBool (xn, "status", _status);
- _mode = _helper.GetAttrAsString(xn, "Mode", _mode);
- _shortMode = _helper.GetAttrAsString(xn, "ShortMode", _shortMode);
- _operationMode = _helper.GetAttrAsString(xn, "OperationMode", _operationMode);
- _condition = _helper.GetAttrAsString(xn, "Condition", _condition);
- return base.Update(xn);
- }
-
- public override bool status
- {
- get { return _status; }
- set {
- if (id > 0) // Only send when a valid ID is found
- {
- ReportPendingRequest();
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
- "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" +
- "&newTargetValue="+(value ? "1" : "0");
- _vera.DoVeraCommandRequest(cmd, ReportRequestError);
- }
- }
- }
-
- public override int level
- {
- get { return (_status ? 1 : 0); }
- set { status = (value > 0); }
- }
+ /// <summary>
+ /// Description of DeviceSprinkler.
+ /// </summary>
+ public class DeviceSprinkler : DeviceGeneric
+ {
+ private bool _status = false;
+ private string _mode = "-";
+ private string _shortMode = "-";
+ private string _operationMode = "-";
+ private string _condition = "-";
+
+ public DeviceSprinkler(XmlNode xn) : base (xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ }
+ }
+
+ public override bool Update(XmlNode xn)
+ {
+ _status = _helper.GetAttrAsBool (xn, "status", _status);
+ _mode = _helper.GetAttrAsString(xn, "Mode", _mode);
+ _shortMode = _helper.GetAttrAsString(xn, "ShortMode", _shortMode);
+ _operationMode = _helper.GetAttrAsString(xn, "OperationMode", _operationMode);
+ _condition = _helper.GetAttrAsString(xn, "Condition", _condition);
+ return base.Update(xn);
+ }
+
+ public override bool status
+ {
+ get { return _status; }
+ set {
+ if (id > 0) // Only send when a valid ID is found
+ {
+ ReportPendingRequest();
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
+ "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" +
+ "&newTargetValue="+(value ? "1" : "0");
+ _vera.DoVeraCommandRequest(cmd, ReportRequestError);
+ }
+ }
+ }
+
+ public override int level
+ {
+ get { return (_status ? 1 : 0); }
+ set { status = (value > 0); }
+ }
- public override string mode
- {
- get { return _mode; }
- set {
- if (id > 0) // Only send when a valid ID is found
- {
- ReportPendingRequest();
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
- "&serviceId=urn:upnp-micasaverde-com:serviceId:Sprinkler1&action=" +
- (value == "Auto" ? "SetModeAuto" : (value == "Block" ? "SetModeBlock" : "SetModeManual"));
- _vera.DoVeraCommandRequest(cmd, ReportRequestError);
- }
- }
- }
-
- public override string ToString()
- {
- return name + " [" + _shortMode + "]";
- }
-
- public override bool isControllable
- {
- get { return true; }
- set { }
- }
-
- public override int maxLevel
- {
- get { return 1; }
- set { }
- }
-
- public override string GetIconName()
- {
- return "Sprinkler";
- }
-
- public override string GetStatusText()
- {
- return _operationMode.Replace("_", " ");
- }
-
- public override string GetExtraText()
- {
- return _condition;
- }
+ public override string mode
+ {
+ get { return _mode; }
+ set {
+ if (id > 0) // Only send when a valid ID is found
+ {
+ ReportPendingRequest();
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
+ "&serviceId=urn:upnp-micasaverde-com:serviceId:Sprinkler1&action=" +
+ (value == "Auto" ? "SetModeAuto" : (value == "Block" ? "SetModeBlock" : "SetModeManual"));
+ _vera.DoVeraCommandRequest(cmd, ReportRequestError);
+ }
+ }
+ }
+
+ public override string ToString()
+ {
+ return name + " [" + _shortMode + "]";
+ }
+
+ public override bool isControllable
+ {
+ get { return true; }
+ set { }
+ }
+
+ public override int maxLevel
+ {
+ get { return 1; }
+ set { }
+ }
+
+ public override string GetIconName()
+ {
+ return "Sprinkler";
+ }
+
+ public override string GetStatusText()
+ {
+ return _operationMode.Replace("_", " ");
+ }
+
+ public override string GetExtraText()
+ {
+ return _condition;
+ }
- public override string [] GetCommands()
- {
- return new string [] {"Off", "On", "Auto", "Block", "Manual"};
- }
- }
+ public override string [] GetCommands()
+ {
+ return new string [] {"Off", "On", "Auto", "Block", "Manual"};
+ }
+ }
}
Modified: trunk/plugins/VeraControl/DeviceSwitch.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceSwitch.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DeviceSwitch.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -13,90 +13,90 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DeviceSwitch.
- /// </summary>
- public class DeviceSwitch : DeviceGeneric
- {
- private bool _status = false;
- private string _watt = "-";
- private string _kwh = "-";
-
- public DeviceSwitch(XmlNode xn): base (xn)
- {
- if (xn != null)
- {
- Update(xn);
- }
- }
-
- public override bool Update(XmlNode xn)
- {
- _status = _helper.GetAttrAsBool (xn, "status", _status);
- _watt = _helper.GetAttrAsString(xn, "watts", _watt);
- _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh);
-
- return base.Update(xn);
- }
-
- public string watts
- {
- get { return _watt; }
- set { }
- }
-
- public override bool status
- {
- get { return _status; }
- set {
- if (id > 0) // Only send when a valid ID is found
- {
- ReportPendingRequest();
- // Do something with vera
- string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
- "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" +
- "&newTargetValue="+(value ? "1" : "0");
- _vera.DoVeraCommandRequest(cmd, ReportRequestError);
- }
- }
- }
-
- public override int level
- {
- get { return (_status ? 1 : 0); }
- set { status = (value > 0); }
- }
-
- public override int maxLevel
- {
- get { return 1; }
- set { }
- }
-
- public override string ToString()
- {
- return name + " [" + GetStatusText()+ "]";
- }
-
- public override bool isControllable
- {
- get { return true; }
- set { }
- }
-
- public override string GetIconName()
- {
- return "Binary_Light_" + (_status ? "100" : "0");
- }
-
- public override string GetExtraText()
- {
- return (_kwh != "" ? _kwh + "kWh" : "");
- }
-
- public override string GetStatusText()
- {
- return (status ? "On" : "Off");
- }
- }
+ /// <summary>
+ /// Description of DeviceSwitch.
+ /// </summary>
+ public class DeviceSwitch : DeviceGeneric
+ {
+ private bool _status = false;
+ private string _watt = "-";
+ private string _kwh = "-";
+
+ public DeviceSwitch(XmlNode xn) : base (xn)
+ {
+ if (xn != null)
+ {
+ Update(xn);
+ }
+ }
+
+ public override bool Update(XmlNode xn)
+ {
+ _status = _helper.GetAttrAsBool (xn, "status", _status);
+ _watt = _helper.GetAttrAsString(xn, "watts", _watt);
+ _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh);
+
+ return base.Update(xn);
+ }
+
+ public string watts
+ {
+ get { return _watt; }
+ set { }
+ }
+
+ public override bool status
+ {
+ get { return _status; }
+ set {
+ if (id > 0) // Only send when a valid ID is found
+ {
+ ReportPendingRequest();
+ // Do something with vera
+ string cmd = "?id=lu_action&DeviceNum="+id.ToString()+
+ "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" +
+ "&newTargetValue="+(value ? "1" : "0");
+ _vera.DoVeraCommandRequest(cmd, ReportRequestError);
+ }
+ }
+ }
+
+ public override int level
+ {
+ get { return (_status ? 1 : 0); }
+ set { status = (value > 0); }
+ }
+
+ public override int maxLevel
+ {
+ get { return 1; }
+ set { }
+ }
+
+ public override string ToString()
+ {
+ return name + " [" + GetStatusText()+ "]";
+ }
+
+ public override bool isControllable
+ {
+ get { return true; }
+ set { }
+ }
+
+ public override string GetIconName()
+ {
+ return "Binary_Light_" + (_status ? "100" : "0");
+ }
+
+ public override string GetExtraText()
+ {
+ return (_kwh != "" ? _kwh + "kWh" : "");
+ }
+
+ public override string GetStatusText()
+ {
+ return (status ? "On" : "Off");
+ }
+ }
}
Modified: trunk/plugins/VeraControl/DeviceSystem.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceSystem.cs 2012-01-28 09:50:54 UTC (rev 4427)
+++ trunk/plugins/VeraControl/DeviceSystem.cs 2012-01-28 20:18:43 UTC (rev 4428)
@@ -12,174 +12,174 @@
namespace VeraControl.Properties
{
- /// <summary>
- /// Description of DeviceSystem.
- /// </summary>
- public class DeviceSystem
- {
- public DeviceSystem()
- {
- }
-
- public VeraHelper _helper = VeraHelper.Instance;
-
- public long _lastUpdate = 0;
- public bool _screenUpdateRequired = false;
- private bool _fullReload = true;
- private string _version = "";
- private string _model = "";
- private bool _zWaveHeal = false;
- private bool _metric = true;
- private string _serial = "";
- private string _fwd1Server = "";
- private string _fwd2Server = "";
- private string _loadTime = "0";
- private string _dataVersion = "0";
- private string _comment = "";
- private DevState _dsVeraState = DevState.NONE;
-
-
- public bool update(XmlNode xn)
- {
- _fullReload = _helper.GetAttrAsBool (xn, "full", _fullReload);
- _version = _helper.GetAttrAsString (xn, "version", _version);
- _model = _helper.GetAttrAsString (xn, "model", _model);
- _zWaveHeal = _helper.GetAttrAsBool (xn, "zwave_heal", _zWaveHeal);
- _serial = _helper.GetAttrAsString (xn, "serial_number", _serial);
- _fwd1Server = _helper.GetAttrAsString (xn, "fwd1", _fwd1Server);
- _fwd2Server = _helper.GetAttrAsString (xn, "fwd2", _fwd2Server);
- _loadTime = _helper.GetAttrAsString (xn, "loadtime", _loadTime);
-
- // Set update flag
- string tempDataversion = _helper.GetAttrAsString (xn, "dataversion", _dataVersion);
- DevState tempVeraState = _helper.ToDevState(_helper.GetAttrAsInt(xn, "state", -1));
- string tempComment = _helper.GetAttrAsString (xn, "comment", "");
-
- if ((_dataVersion != tempDataversion) || _comment != tempComment || _dsVeraState != tempVeraState)
- {
- _screenUpdateRequired = true;
- _lastUpdate = DateTime.Now.Ticks;
- }
- _dataVersion = tempDataversion;
- _dsVeraState = tempVeraState;
- _comment = tempComment;
-
- _dsVeraState = _helper.ToDevState(_helper.GetAttrAsInt(xn, "state", -1));
- _comment = _helper.GetAttrAsString (xn, "comment", "");
- _metric = (_helper.GetAttrAsString(xn, "temperature", "C") == "C");
-
- return true;
- }
-
- public void ClearFullReloadFlag()
- {
- _fullReload = false;
- }
-
- public void SetFullReloadFlag()
- {
- _fullReload = true;
- }
- public bool fullReload
- {
- get { return _fullReload; }
- set { }
- }
-
- public string versionInfo
- {
- get { return _model + " " + _version; }
- set { }
- }
-
- public bool zWaveHeal
- {
- get { return _zWaveHeal; }
- set { }
- }
-
- public string serialno
- {
- get { return _serial; }
- set { }
- }
+ /// <summary>
+ /// Description of DeviceSystem.
+ /// </summary>
+ public class DeviceSystem
+ {
+ public DeviceSystem()
+ {
+ }
+
+ public VeraHelper _helper = VeraHelper.Instance;
+
+ public long _lastUpdate = 0;
+ public bool _screenUpdateRequired = false;
+ private bool _fullReload = true;
+ private string _version = "";
+ private string _model = "";
+ private bool _zWaveHeal = false;
+ private bool _metric = true;
+ private string _serial = "";
+ private string _fwd1Server = "";
+ private string _fwd2Server = "";
+ private string _loadTime = "0";
+ ...
[truncated message content] |