|
From: <Ba...@us...> - 2012-02-19 22:21:53
|
Revision: 4457
http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4457&view=rev
Author: BartEv
Date: 2012-02-19 22:21:45 +0000 (Sun, 19 Feb 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/plugins/VeraControl/BaseDevice.cs
trunk/plugins/VeraControl/DevCategories.cs
trunk/plugins/VeraControl/DeviceDimmer.cs
trunk/plugins/VeraControl/DeviceSecurity.cs
trunk/plugins/VeraControl/DeviceThermostat.cs
trunk/plugins/VeraControl/DeviceWindowCovering.cs
trunk/plugins/VeraControl/Properties/AssemblyInfo.cs
trunk/plugins/VeraControl/Room.cs
trunk/plugins/VeraControl/Section.cs
trunk/plugins/VeraControl/VeraCommunication.cs
trunk/plugins/VeraControl/VeraControl.cs
trunk/plugins/VeraControl/VeraSetupForm.Designer.cs
trunk/plugins/VeraControl/VeraSetupForm.cs
trunk/plugins/VeraControl/releases/VeraControl.xmp2
trunk/plugins/VeraControl/skin/Default/VeraControl.xml
trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml
trunk/plugins/VeraControl/skin/Media/Vera/Window_Covering.png
trunk/plugins/VeraControl/skin/Media/Vera/music_audio.png
Added Paths:
-----------
trunk/plugins/VeraControl/VeraBox.cs
trunk/plugins/VeraControl/skin/Media/Vera/Motion_Sensor_bypass.png
trunk/plugins/VeraControl/skin/Media/Vera/Window_Covering_0.png
trunk/plugins/VeraControl/skin/Media/Vera/Window_Covering_100.png
trunk/plugins/VeraControl/skin/Media/Vera/Window_Covering_25.png
trunk/plugins/VeraControl/skin/Media/Vera/Window_Covering_50.png
trunk/plugins/VeraControl/skin/Media/Vera/Window_Covering_75.png
trunk/plugins/VeraControl/skin/Media/Vera/back.png
trunk/plugins/VeraControl/skin/Media/Vera/room.png
Modified: trunk/plugins/VeraControl/BaseDevice.cs
===================================================================
--- trunk/plugins/VeraControl/BaseDevice.cs 2012-02-17 23:12:46 UTC (rev 4456)
+++ trunk/plugins/VeraControl/BaseDevice.cs 2012-02-19 22:21:45 UTC (rev 4457)
@@ -49,7 +49,7 @@
_name = _helper.GetAttrAsString(xn, "name", _name);
_id = _helper.GetAttrAsInt (xn, "id", _id);
_room = _helper.GetAttrAsInt (xn, "room", _room);
- _comment = _helper.GetAttrAsString(xn, "comment", _comment );
+ _comment = _helper.GetAttrAsString(xn, "comment", _comment );
_dsState = _helper.ToDevState (_helper.GetAttrAsInt(xn, "state", -1));
if (_id == 0)
Modified: trunk/plugins/VeraControl/DevCategories.cs
===================================================================
--- trunk/plugins/VeraControl/DevCategories.cs 2012-02-17 23:12:46 UTC (rev 4456)
+++ trunk/plugins/VeraControl/DevCategories.cs 2012-02-19 22:21:45 UTC (rev 4457)
@@ -37,7 +37,7 @@
_name = nm;
}
- private string _name = "unknown category";
+ private string _name = "Generic";
private int _id = 0;
public VeraHelper _helper = VeraHelper.Instance;
@@ -74,8 +74,8 @@
case 3: // Switch
return "Binary_Light_100";
- case 4: // Generic Sensor
- return "generic_sensor";
+ case 4: // Security Sensor
+ return "Motion_Sensor_100";
case 5: // Thermostat
return "Thermostat";
@@ -93,8 +93,8 @@
case 10: // Ir TX
return "IR_Transmitter";
- case 12: // Motion Sensor
- return "Motion_Sensor_100";
+ case 12: // Generic Sensor
+ return "generic_sensor";
case 11: // Generic IO
case 13: // Serial port
Modified: trunk/plugins/VeraControl/DeviceDimmer.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceDimmer.cs 2012-02-17 23:12:46 UTC (rev 4456)
+++ trunk/plugins/VeraControl/DeviceDimmer.cs 2012-02-19 22:21:45 UTC (rev 4457)
@@ -117,7 +117,7 @@
if (level > 0) { strmode = "25%"; }
if (level > 25) { strmode = "50%"; }
if (level > 50) { strmode = "75%"; }
- if (level > 75) { strmode = "0n"; }
+ if (level > 75) { strmode = "On"; }
return strmode;
}
set {
Modified: trunk/plugins/VeraControl/DeviceSecurity.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceSecurity.cs 2012-02-17 23:12:46 UTC (rev 4456)
+++ trunk/plugins/VeraControl/DeviceSecurity.cs 2012-02-19 22:21:45 UTC (rev 4457)
@@ -81,7 +81,7 @@
public override string GetIconName()
{
- return "Motion_Sensor_" + (_isTripped ? "100" : "0");
+ return "Motion_Sensor_" + (status ? (_isTripped ? "100" : "0") : "bypass");
}
public override string GetStatusText()
Modified: trunk/plugins/VeraControl/DeviceThermostat.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceThermostat.cs 2012-02-17 23:12:46 UTC (rev 4456)
+++ trunk/plugins/VeraControl/DeviceThermostat.cs 2012-02-19 22:21:45 UTC (rev 4457)
@@ -63,8 +63,7 @@
// Do something with vera
string cmd = "?id=lu_action&DeviceNum=" + internalId.ToString( )+
"&serviceId=urn:upnp-org:serviceId:HVAC_UserOperatingMode1&action=SetModeTarget" +
- "&NewModeTarget=" + (value == "Off" ? "Off" : (value == "Cool" ? "CoolOn" : (value == "Heat" ? "HeatOn" : "AutoChangeOver"))
- );
+ "&NewModeTarget=" + (value == "Off" ? "Off" : (value == "Cool" ? "CoolOn" : (value == "Heat" ? "HeatOn" : "AutoChangeOver")));
_myVeraBox.DoVeraCommandRequest(cmd, ReportRequestError);
}
}
Modified: trunk/plugins/VeraControl/DeviceWindowCovering.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceWindowCovering.cs 2012-02-17 23:12:46 UTC (rev 4456)
+++ trunk/plugins/VeraControl/DeviceWindowCovering.cs 2012-02-19 22:21:45 UTC (rev 4457)
@@ -4,8 +4,8 @@
* Date: 24-12-2011
* Time: 23:56
*
- * Copyright: 2012 GPL - Bart Eversdijk
- * MediaPort plugin - MicasaVerde (TM) Vera Controller
+ * Copyright: 2012 GPL - Bart Eversdijk
+ * MediaPort plugin - MicasaVerde (TM) Vera Controller
* E-mail: ba...@ev...
*/
using System;
@@ -18,12 +18,65 @@
/// </summary>
public class DeviceWindowCovering : DeviceDimmer
{
- public DeviceWindowCovering(XmlNode xn, int verabox) : base (xn, verabox)
+ public DeviceWindowCovering(XmlNode xn, int verabox) : base (xn, verabox)
{
if (xn != null)
{
Update(xn);
}
}
+
+ 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 "Window_Covering_" + leveltxt;
+ }
+
+ public override string GetStatusText()
+ {
+ return (status ? (level == 100 ? "Closed" : level.ToString() + "%") : "Opened");
+ }
+
+ public override string mode
+ {
+ get {
+ string strmode = "Open";
+ if (level > 0) { strmode = "25%"; }
+ if (level > 25) { strmode = "50%"; }
+ if (level > 50) { strmode = "75%"; }
+ if (level > 75) { strmode = "Close"; }
+ return strmode;
+ }
+ set {
+ switch (value)
+ {
+ case "Open":
+ level = 0;
+ break;
+ case "25%":
+ level = 25;
+ break;
+ case "50%":
+ level = 50;
+ break;
+ case "75%":
+ level = 75;
+ break;
+ case "Close":
+ level = 100;
+ break;
+ }
+ }
+ }
+
+ public override string [] GetCommands()
+ {
+ return new string [] {"Open", "Close", "25%", "75%", "50%"};
+ }
}
}
Modified: trunk/plugins/VeraControl/Properties/AssemblyInfo.cs
===================================================================
--- trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2012-02-17 23:12:46 UTC (rev 4456)
+++ trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2012-02-19 22:21:45 UTC (rev 4457)
@@ -28,4 +28,4 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
-[assembly: AssemblyVersion("0.5.1.0")]
+[assembly: AssemblyVersion("1.0.1.0")]
Modified: trunk/plugins/VeraControl/Room.cs
===================================================================
--- trunk/plugins/VeraControl/Room.cs 2012-02-17 23:12:46 UTC (rev 4456)
+++ trunk/plugins/VeraControl/Room.cs 2012-02-19 22:21:45 UTC (rev 4457)
@@ -61,7 +61,8 @@
public int id
{
- get {
+ get
+ {
if (_myVeraBox == null)
{
return 0;
@@ -82,7 +83,8 @@
public int section
{
- get {
+ get
+ {
if (_myVeraBox == null)
{
return 0;
Modified: trunk/plugins/VeraControl/Section.cs
===================================================================
--- trunk/plugins/VeraControl/Section.cs 2012-02-17 23:12:46 UTC (rev 4456)
+++ trunk/plugins/VeraControl/Section.cs 2012-02-19 22:21:45 UTC (rev 4457)
@@ -42,7 +42,8 @@
public int id
{
- get {
+ get
+ {
if (_myVeraBox == null)
{
return 0;
Added: trunk/plugins/VeraControl/VeraBox.cs
===================================================================
--- trunk/plugins/VeraControl/VeraBox.cs (rev 0)
+++ trunk/plugins/VeraControl/VeraBox.cs 2012-02-19 22:21:45 UTC (rev 4457)
@@ -0,0 +1,728 @@
+/*
+ * Created by SharpDevelop.
+ * User: Bart
+ * Date: 10-2-2012
+ * Time: 16:41
+ *
+ *
+ * Copyright: 2012 GPL - Bart Eversdijk
+ * MediaPort plugin - MicasaVerde (TM) Vera Controller
+ * E-mail: ba...@ev...
+ */
+using System;
+using System.Net;
+using System.IO;
+using System.Threading;
+using System.Collections.Generic;
+using System.Xml;
+
+namespace VeraControl.Properties
+{
+ public enum ConnectionType
+ {
+ RemoteOnly = -1,
+ Auto = 0,
+ LocalOnly = 1
+ }
+
+ public class VeraStatus
+ {
+ public DeviceSystem system = new DeviceSystem();
+ public List<DeviceGeneric> devices = new List<DeviceGeneric>();
+ public List<Scene> scenes = new List<Scene>();
+ public List<Room> rooms = new List<Room>();
+ public List<DevCategories> categories = new List<DevCategories>();
+ public List<Section> sections = new List<Section>();
+
+ #region Vers get by id support functions
+
+ public void ClearAllLists()
+ {
+ devices.Clear();
+ scenes.Clear();
+ rooms.Clear();
+ categories.Clear();
+ sections.Clear();
+ }
+ public Room GetRoomById(int id)
+ {
+ foreach(Room room in rooms)
+ {
+ if (room.id == id)
+ {
+ return room;
+ }
+ }
+ return new Room(null, 0);
+ }
+
+ public Section GetSectionById(int id)
+ {
+ foreach(Section section in sections)
+ {
+ if (section.id == id)
+ {
+ return section;
+ }
+ }
+ return new Section(null, 0);
+ }
+
+ public DeviceGeneric GetDeviceById(int id)
+ {
+ foreach(DeviceGeneric dev in devices)
+ {
+ if (dev.id == id)
+ {
+ return dev;
+ }
+ }
+ return new DeviceGeneric(null, 0);
+ }
+
+ public Scene GetSceneById(int id)
+ {
+ foreach(Scene scene in scenes)
+ {
+ if (scene.id == id)
+ {
+ return scene;
+ }
+ }
+ return new Scene(null, 0);
+ }
+
+ public DevCategories GetCategoryById(int id)
+ {
+ foreach(DevCategories cat in categories)
+ {
+ if (cat.id == id)
+ {
+ return cat;
+ }
+ }
+ return new DevCategories(null);
+ }
+
+ public bool IsSectionFound(int id)
+ {
+ foreach(Section section in sections)
+ {
+ if (section.id == id)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public bool IsRoomFound(int id)
+ {
+ foreach(Room room in rooms)
+ {
+ if (room.id == id)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public bool IsDeviceFound(int id)
+ {
+ foreach(DeviceGeneric dev in devices)
+ {
+ if (dev.id == id)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public bool IsSceneFound(int id)
+ {
+ foreach(Scene scene in scenes)
+ {
+ if (scene.id == id)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public bool IsCategoryFound(int id)
+ {
+ foreach(DevCategories cat in categories)
+ {
+ if (cat.id == id)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ #endregion
+ }
+
+ /// <summary>
+ /// Description of VeraBox.
+ /// </summary>
+ public class VeraBox
+ {
+ private VeraHelper _helper = VeraHelper.Instance;
+
+ // Actual device information
+ private VeraStatus _status = new VeraStatus();
+
+ // Config data
+ public int _maxRefreshDelay; // Maximun delay between 2 status updates in seconds
+ public int _minRefreshDelay = 1000; // Minimun delay between 2 status updates in miliseconds
+ private int _myVeraId = 0;
+ public bool _oldStyleConfig = false; // Read config settings in 0.9.0.3 or previous style
+
+ // Communication status/control
+ private long _lastUpdate = 0;
+ private bool _screenUpdateRequired = false; // Only true when a new update was received AND at least one device(staus) or scene was changed
+ private bool _lastUpdateFailed = false;
+ private string _lastUpdateErrorMessage = "";
+ public WebClient _webUpdateClient = new WebClient();
+ public WebClient _webCommandClient = new WebClient();
+ private Action<string> _webCommandClientErrorReporter = null;
+
+ // Connection information
+ private int _serial = -1;
+ private string _ip = "";
+ private string _name = "";
+ private string _realLocalVeraAddress = null;
+ private string _realRemoteVeraAddress = null;
+ private string _discreteVeraAddress = null;
+ private ConnectionType _connectionType = ConnectionType.Auto;
+ private bool _fallBackConnection = false;
+
+ public VeraBox(int id, int maxRefresh, int minRefresh)
+ {
+ _myVeraId = id;
+ _maxRefreshDelay = maxRefresh;
+ _minRefreshDelay = minRefresh;
+
+ using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings())
+ {
+ // Set DownloadStringCompleted handler
+ _webUpdateClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnCompletedUpdateStatusRequest);
+ _webCommandClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnCompletedCommandRequest);
+ }
+ }
+
+ public void DoVeraCommandRequest(string param, Action<string> errorReporter)
+ {
+ // If a request was pending just cancel the previous request (user is informed about the progress)
+ string url = veraAddress + "/data_request" + param + "&time=" + DateTime.Now.Ticks;
+
+ // Callback thus ASynchronised call (do NOT wait for response)
+ try {
+ _webCommandClientErrorReporter = errorReporter;
+ _webCommandClient.CancelAsync(); // Cancel any current pending Async calls...
+ _webCommandClient.DownloadStringAsync(new Uri(url));
+
+ } catch( Exception e )
+ {
+ _webCommandClientErrorReporter = null;
+ status.system.ReportCommandError(e.Message);
+ setScreenUpdateRequired();
+ }
+ }
+
+ public void OnCompletedCommandRequest(object sender, DownloadStringCompletedEventArgs e)
+ {
+ if (e.Cancelled)
+ {
+ // Communication cancel for some reason, no valid data to be expected
+ if (_webCommandClientErrorReporter != null)
+ {
+ // Send error to dialog message handler
+ _webCommandClientErrorReporter("Request was canceled");
+ }
+ else
+ {
+ // Show eror in MediaPortal Vera-main window
+ status.system.ReportCommandError("Request was canceled");
+ }
+ setScreenUpdateRequired();
+ }
+ else if (e.Error != null)
+ {
+ // Handle error here
+ if (_webCommandClientErrorReporter != null)
+ {
+ // Send error to dialog message handler
+ _webCommandClientErrorReporter(e.Error.Message);
+ }
+ else
+ {
+ // Show eror in MediaPortal Vera-main window
+ status.system.ReportCommandError(e.Error.Message);
+ }
+ setScreenUpdateRequired();
+ }
+ else
+ {
+ // Communication succes full -> no parse Vera response...
+ if (!e.Result.ToUpper().Contains("<OK>OK</OK>") && !e.Result.ToUpper().Contains("<JOBID>"))
+ {
+ if (_webCommandClientErrorReporter != null)
+ {
+ // Send error to dialog message handler
+ _webCommandClientErrorReporter(e.Result);
+ }
+ else
+ {
+ // Show eror in MediaPortal Vera-main window
+ status.system.ReportCommandError(e.Result);
+ }
+ setScreenUpdateRequired();
+ }
+ }
+ // Communication done clear error report handler
+ _webCommandClientErrorReporter = null;
+ }
+
+ public void UpdateCurrentStatus()
+ {
+ /* Keep updating with webClient timeout 180 sec, even when last time did fail or connection was lost....*/
+ if (!_webUpdateClient.IsBusy && (!_lastUpdateFailed || (_lastUpdate + 30 < _helper.GetSecondsSince1970())))
+ {
+ string url = veraAddress + "/data_request" +
+ "?id=lu_sdata&loadtime=" + _status.system.loadtime +
+ "&dataversion=" + _status.system.dataversion +
+ "&minimumdelay=" + _minRefreshDelay +
+ "&timeout=" + _maxRefreshDelay +
+ "&output_format=xml" +
+ "&time=" + DateTime.Now.Ticks;
+
+ // Callback thus ASynchronised call (do NOT wait for response)
+ try {
+ _webUpdateClient.CancelAsync(); // Cancel any current pending Async calls...
+ _webUpdateClient.DownloadStringAsync(new Uri(url));
+ } catch( Exception e )
+ {
+ _lastUpdateFailed = true;
+ _lastUpdateErrorMessage = e.Message;
+ }
+ _lastUpdate = _helper.GetSecondsSince1970();
+ }
+ }
+
+ public void OnCompletedUpdateStatusRequest(object sender, DownloadStringCompletedEventArgs e)
+ {
+ if (!e.Cancelled)
+ {
+ // Communication cancel for some reason, no valid data to be expected
+ if (e.Error != null)
+ {
+ // Handle error here
+ _lastUpdateFailed = true;
+ _lastUpdateErrorMessage = e.Error.Message;
+ setScreenUpdateRequired();
+ }
+ else
+ {
+ ParseUpdateInfo(e.Result);
+ // WebClient wc = new WebClient();
+ // if (_status.system.dataversion == "0")
+ // {
+ // ParseUpdateInfo( wc.DownloadString(@"C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\testdata\text.xml"));
+ // }
+ }
+ }
+
+ // update timer again (took some time to get the data)
+ _lastUpdate = _helper.GetSecondsSince1970();
+ }
+
+ public void ParseUpdateInfo(string veraresponse)
+ {
+ var xmlDoc = new XmlDocument();
+ try {
+ xmlDoc.LoadXml(veraresponse);
+ } catch (Exception)
+ {
+ // Parser failed so incorrect data received (could be an interrupted data transfer)
+ return;
+ }
+ // Parse header
+ XmlNode rootnode = xmlDoc.SelectSingleNode("/root");
+ if (rootnode == null)
+ {
+ // Not a status update, just return
+ return;
+ }
+
+ if (!_screenUpdateRequired)
+ {
+ // Clear flag, only when previous update was already handled (might be some new or remove devices/scenes to be displayed)
+ _status.system.ClearFullReloadFlag();
+ }
+ if (_lastUpdateFailed)
+ {
+ _lastUpdateFailed = false;
+ setScreenUpdateRequired();
+ _status.system.ClearConnectionError();
+ }
+ // Process system status first
+ _status.system.update(rootnode);
+ if (_status.system.fullReload)
+ {
+ // We have a full refresh -> Clear all lists (to get clear of removed devices/scenes/catgories/rooms/etc...)
+ _status.ClearAllLists();
+
+ }
+
+ // Process Sections
+ XmlNodeList xnList = xmlDoc.SelectNodes("/root/sections/section");
+ foreach (XmlNode xn in xnList)
+ {
+ Section sc = _status.GetSectionById( makeId(xn.Attributes["id"].Value) );
+ if (sc.id != 0) {
+ sc.Update(xn);
+ } else {
+ _status.sections.Add(new Section(xn, _myVeraId));
+ }
+ }
+
+ // Process Rooms
+ xnList = xmlDoc.SelectNodes("/root/rooms/room");
+ foreach (XmlNode xn in xnList)
+ {
+ Room room = _status.GetRoomById( makeId(xn.Attributes["id"].Value) );
+ if (room.id != 0) {
+ room.Update(xn);
+ } else {
+ _status.rooms.Add(new Room(xn, _myVeraId));
+ }
+ }
+
+ // Process Scenes
+ xnList = xmlDoc.SelectNodes("/root/scenes/scene");
+ // State update of Scenes are not reported done, so they have to be cleaned manualy
+ // if a message is still valid and/or new message will be reported below
+ foreach (Scene scene in _status.scenes)
+ {
+ scene.ClearCommState();
+ }
+ foreach (XmlNode xn in xnList)
+ {
+ Scene sc = _status.GetSceneById( makeId(xn.Attributes["id"].Value) );
+ if (sc.id != 0) {
+ sc.Update(xn);
+ } else {
+ _status.scenes.Add(new Scene(xn, _myVeraId));
+ }
+ }
+
+ // Process Categories - categories are general not Box specific
+ xnList = xmlDoc.SelectNodes("/root/categories/categorie");
+ foreach (XmlNode xn in xnList)
+ {
+ DevCategories cat = _status.GetCategoryById( int.Parse(xn.Attributes["id"].Value) );
+ if (cat.id != 0) {
+ cat.Update(xn);
+ } else {
+ _status.categories.Add(new DevCategories(xn));
+ }
+ }
+
+ // Process Devices
+ xnList = xmlDoc.SelectNodes("/root/devices/device");
+ foreach (XmlNode xn in xnList)
+ {
+ DeviceGeneric dev = _status.GetDeviceById( makeId(xn.Attributes["id"].Value) );
+ if (dev.id != 0) {
+ // update existing device
+ dev.Update(xn);
+ } else {
+ _status.system.SetFullReloadFlag();
+
+ // catids: http://wiki.micasaverde.com/index.php/Luup_UPNP_Files
+ switch (xn.Attributes["category"].Value)
+ {
+ //case "1": // TODO: Implement interface device ?
+ // m_status.devices.Add(new DeviceInterface(xn));
+ // break;
+
+ case "2":
+ _status.devices.Add(new DeviceDimmer(xn, _myVeraId));
+ break;
+
+ case "3":
+ case "11": // Generic IO
+ _status.devices.Add(new DeviceSwitch(xn, _myVeraId));
+ break;
+
+ case "4": // Generic Sensor
+ case "12": // Motion Sensor
+ _status.devices.Add(new DeviceSecurity(xn, _myVeraId));
+ break;
+
+ case "5":
+ _status.devices.Add(new DeviceThermostat(xn, _myVeraId, _status.system.IsMetric()));
+ break;
+
+ case "6":
+ _status.devices.Add(new DeviceCam(xn, _myVeraId));
+ break;
+
+ case "7":
+ _status.devices.Add(new DeviceDoorlock(xn, _myVeraId));
+ break;
+
+ case "8":
+ _status.devices.Add(new DeviceWindowCovering(xn, _myVeraId));
+ break;
+
+ //case "9":
+ // m_status.devices.Add(new DeviceRemoteControl(xn, veraId));
+ // break;
+
+ //case "10":
+ // m_status.devices.Add(new DeviceIrTx(xn, veraId));
+ // break;
+
+ //case "13":
+ // m_status.devices.Add(new DeviceSerialPort(xn, veraId));
+ // break
+
+ case "14":
+ _status.devices.Add(new DeviceSceneController(xn, _myVeraId));
+ break;
+
+ // case "15":
+ // m_status.devices.Add(new DeviceAV(xn, veraId));
+ // break;
+
+ case "16":
+ _status.devices.Add(new DeviceHumidity(xn, _myVeraId));
+ break;
+
+ case "17":
+ _status.devices.Add(new DeviceTemperature(xn, _myVeraId, _status.system.IsMetric()));
+ break;
+
+ case "18":
+ _status.devices.Add(new DeviceLightSensor(xn, _myVeraId));
+ break;
+
+ //case "19":
+ // m_status.devices.Add(new DeviceZwaveInt(xn, veraId));
+ // break
+ //case "20":
+ // m_status.devices.Add(new DeviceInsteonInt(xn, veraId));
+ // break
+
+ case "21":
+ _status.devices.Add(new DevicePowerMeter(xn, _myVeraId));
+ break;
+
+ case "0":
+ default:
+ // Check for Google Weather Device
+ if (xn.Attributes["WindCondition"] != null || xn.Attributes["windcondition"] != null)
+ {
+ _status.devices.Add(new DeviceGWeather(xn, _myVeraId));
+ break;
+ }
+ // Check for Bart's sprinkler Device
+ if (xn.Attributes["OperationMode"] != null)
+ {
+ _status.devices.Add(new DeviceSprinkler(xn, _myVeraId));
+ break;
+ }
+ _status.devices.Add(new DeviceGeneric(xn, _myVeraId));
+ break;
+ }
+ }
+ }
+ }
+
+ public long SecondsSinceLastUpdate
+ {
+ get { return (_helper.GetSecondsSince1970() - _lastUpdate); }
+ }
+
+ public List<Scene> scenes
+ {
+ get { return _status.scenes; }
+ }
+
+ public List<DeviceGeneric> devices
+ {
+ get { return _status.devices; }
+ }
+
+ public List<Room> rooms
+ {
+ get { return _status.rooms; }
+ }
+
+ public List<DevCategories> categories
+ {
+ get { return _status.categories; }
+ }
+
+ public List<Section> sections
+ {
+ get { return _status.sections; }
+ }
+
+ public bool lastUpdateFailed
+ {
+ get { return _lastUpdateFailed; }
+ set { _lastUpdateFailed = value; }
+ }
+
+ public string lastUpdateError
+ {
+ get { return _lastUpdateErrorMessage; }
+ }
+
+ public string name
+ {
+ get {
+ if (_name == "" || _name == "-")
+ {
+ return (_connectionType == ConnectionType.RemoteOnly ? _serial.ToString() : _ip);
+ }
+ return _name;
+ }
+ }
+
+ /// <summary>
+ /// Invoking this method will clear the update ready flag -> so caller need to handle the screen update
+ /// </summary>
+ /// <returns>When true a screen update shall be preformed by the caller</returns>
+ public bool NewScreenUpdateWaitingAndClearFlag()
+ {
+ bool b = _screenUpdateRequired;
+ _screenUpdateRequired = false;
+ return b;
+ }
+
+ public void setScreenUpdateRequired()
+ {
+ _screenUpdateRequired = true;
+ }
+ /// <summary>
+ /// A request is currently being handled by Vera, this request takes at least _minRefreshDelay msecs, at most _maxRefreshDelay seconds and will be finished the moment Vera detects a change.
+ /// As soon as this function returns false a new update request should be invoked (with UpdateCurrentStatus()), Vera will take care of the Refresh delays (by keeping open the http-connection)
+ /// </summary>
+ public bool updatePending
+ {
+ get { return _webUpdateClient.IsBusy; }
+ }
+
+
+ public VeraStatus status
+ {
+ get { return _status; }
+ }
+
+ public int myId
+ {
+ get { return _myVeraId; }
+ }
+
+ public int zeroId
+ {
+ get { return makeId(0); }
+ }
+
+ public int makeId(int id)
+ {
+ return (_myVeraId * VeraCommunication.IDMASK) + id;
+ }
+
+ public int makeId(string id)
+ {
+ return makeId(int.Parse(id));
+ }
+
+ public ConnectionType connectionType
+ {
+ get { return _connectionType; }
+ }
+
+ public bool inFallback
+ {
+ get { return (_connectionType == ConnectionType.Auto ? _fallBackConnection : true); }
+ set { _fallBackConnection = (_connectionType == ConnectionType.Auto ? value : false); }
+ }
+
+ public string discreteVeraAddress
+ {
+ get {
+ if (_discreteVeraAddress == null)
+ { // Accessing this variable will set the discrete value aswell
+ string dum = veraAddress;
+ }
+ return (_fallBackConnection || _connectionType == ConnectionType.RemoteOnly ? _discreteVeraAddress : _realLocalVeraAddress);
+ }
+ }
+
+ public string veraAddress
+ {
+ get {
+ if (_realLocalVeraAddress == null && _realRemoteVeraAddress == null)
+ {
+ using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings())
+ {
+ string id = "";
+ if (!_oldStyleConfig)
+ {
+ id = "_" + myId.ToString("00");
+ }
+ _ip = xmlreader.GetValueAsString("veracontroller", "ipaddress" + id, "127.0.0.1");
+ string port = xmlreader.GetValueAsString("veracontroller", "portnumber" + id, "3480");
+ string user = xmlreader.GetValueAsString("veracontroller", "miosusername" + id, "");
+ string pass = xmlreader.GetValueAsString("veracontroller", "miospassword" + id, "");
+ _serial = xmlreader.GetValueAsInt ("veracontroller", "serialnumber" + id, -1);
+ _name = xmlreader.GetValueAsString("veracontroller", "name" + id, "");
+
+ if (_oldStyleConfig)
+ {
+ _connectionType = (xmlreader.GetValueAsBool("veracontroller", "remoteConnected", false) ? ConnectionType.RemoteOnly : ConnectionType.LocalOnly);
+ }
+ else
+ {
+ _connectionType = (ConnectionType)xmlreader.GetValueAsInt("veracontroller", "connectiontype" + id, (int)ConnectionType.Auto);
+ if (_connectionType == ConnectionType.Auto && (_serial < 99 || user == "" || pass == ""))
+ {
+ _connectionType = ConnectionType.LocalOnly;
+ }
+ }
+
+ string fwd = "fwd" + ((_serial % 1) == 1 ? "1" : "2");
+ _realLocalVeraAddress = (_connectionType == ConnectionType.RemoteOnly) ? "" : "http://" + _ip + ":" + port;
+ _realRemoteVeraAddress = (_connectionType == ConnectionType.LocalOnly) ? "" : "https://" + fwd + ".mios.com/" + user + "/" + pass + "/" + _serial.ToString();
+ _discreteVeraAddress = (_connectionType == ConnectionType.LocalOnly) ? _realLocalVeraAddress : fwd + ".mios.com/" + user + "/xxxxx/" + _serial.ToString();
+ }
+ }
+ else
+ {
+ // Check if we did receive a different serial number, than was stored by the config file
+ if (!_oldStyleConfig && status.system.serialno != _serial && status.system.serialno != -1)
+ {
+ using (MediaPortal.Profile.Settings xmlWriter = new MediaPortal.Profile.MPSettings())
+ {
+ // Store new serial number....
+ xmlWriter.SetValue("veracontroller", "serialnumber" + "_" + myId.ToString("00"), _serial.ToString());
+ }
+ }
+ }
+
+ return (_fallBackConnection || _connectionType == ConnectionType.RemoteOnly ? _realRemoteVeraAddress :_realLocalVeraAddress);
+ }
+ }
+ }
+}
+
Modified: trunk/plugins/VeraControl/VeraCommunication.cs
===================================================================
--- trunk/plugins/VeraControl/VeraCommunication.cs 2012-02-17 23:12:46 UTC (rev 4456)
+++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-02-19 22:21:45 UTC (rev 4457)
@@ -193,21 +193,37 @@
public Room GetRoomById(int id)
{
+ if (BoxId(id) >= _instance.numOfBoxes)
+ {
+ return new Room(null, 0);
+ }
return boxes[BoxId(id)].status.GetRoomById(id);
}
public Section GetSectionById(int id)
{
+ if (BoxId(id) >= _instance.numOfBoxes)
+ {
+ return new Section(null, 0);
+ }
return boxes[BoxId(id)].status.GetSectionById(id);
}
public DeviceGeneric GetDeviceById(int id)
{
+ if (BoxId(id) >= _instance.numOfBoxes)
+ {
+ return new DeviceGeneric(null, 0);
+ }
return boxes[BoxId(id)].status.GetDeviceById(id);
}
public Scene GetSceneById(int id)
{
+ if (BoxId(id) >= _instance.numOfBoxes)
+ {
+ return new Scene(null, 0);
+ }
return boxes[BoxId(id)].status.GetSceneById(id);
}
@@ -225,6 +241,10 @@
public DevCategories GetCategoryById(int id)
{
+ if (BoxId(id) >= _instance.numOfBoxes)
+ {
+ return new DevCategories(0);
+ }
return boxes[BoxId(id)].status.GetCategoryById(id);
}
@@ -246,26 +266,46 @@
public bool IsSectionFound(int id)
{
+ if (BoxId(id) >= _instance.numOfBoxes)
+ {
+ return false;
+ }
return boxes[BoxId(id)].status.IsSectionFound(id);
}
public bool IsRoomFound(int id)
{
+ if (BoxId(id) >= _instance.numOfBoxes)
+ {
+ return false;
+ }
return boxes[BoxId(id)].status.IsRoomFound(id);
}
public bool IsDeviceFound(int id)
{
+ if (BoxId(id) >= _instance.numOfBoxes)
+ {
+ return false;
+ }
return boxes[BoxId(id)].status.IsDeviceFound(id);
}
public bool IsSceneFound(int id)
{
+ if (BoxId(id) >= _instance.numOfBoxes)
+ {
+ return false;
+ }
return boxes[BoxId(id)].status.IsSceneFound(id);
}
public bool IsCategoryFound(int id)
{
+ if (BoxId(id) >= _instance.numOfBoxes)
+ {
+ return false;
+ }
return boxes[BoxId(id)].status.IsCategoryFound(id);
}
@@ -280,7 +320,6 @@
{
return false;
}
-
return (room.section == sectionid);
}
Modified: trunk/plugins/VeraControl/VeraControl.cs
===================================================================
--- trunk/plugins/VeraControl/VeraControl.cs 2012-02-17 23:12:46 UTC (rev 4456)
+++ trunk/plugins/VeraControl/VeraControl.cs 2012-02-19 22:21:45 UTC (rev 4457)
@@ -27,6 +27,7 @@
using Action = MediaPortal.GUI.Library.Action;
using Player = MediaPortal.Player.g_Player;
using MediaType = MediaPortal.Player.g_Player.MediaType;
+using System.Windows;
using MediaPortal.Common.Utils;
[assembly: CompatibleVersion("1.1.6.27644")]
@@ -83,6 +84,7 @@
[SkinControlAttribute(10)] protected GUILabelControl _title = null;
[SkinControl(20)] protected GUISpinButton _sectionList = null;
[SkinControl(40)] protected GUIListControl _leftList = null;
+ [SkinControl(41)] protected GUICoverFlow _flowList = null;
[SkinControl(50)] protected GUIListControl _rightList = null;
[SkinControl(30)] protected GUIImage _systemStatusImage = null;
@@ -118,6 +120,8 @@
public bool _enableSceneTrigger = false;
private bool _autoSelectRoom = true;
private bool _viewPerCategory = false;
+ private bool _viewListStyle = true;
+ private bool _devicesFlow = false;
private VeraSortStyle _selectedSortOption = VeraSortStyle.NO;
private VeraFilterStyle _selectedFilterOption = VeraFilterStyle.NONE;
@@ -143,8 +147,8 @@
public VeraControl()
{
- // TODO: remove this sleep
- Thread.Sleep(5000);
+ // TO DO: remove this sleep
+ // Thread.Sleep(5000);
}
#region ISetupForm Members
@@ -158,7 +162,7 @@
// Returns the description of the plugin is shown in the plugin menu
public string Description()
{
- return "Micasa Verde Vera 2 controller, let Media Portal control your Z-wave devices";
+ return "Micasa Verde Vera controller, let Media Portal control your Z-wave devices";
}
// Returns the author of the plugin which is shown in the plugin menu
@@ -239,9 +243,10 @@
{
_enableSceneTrigger = xmlreader.GetValueAsBool("veracontroller", "enableSceneTrigger", false);
_autoSelectRoom = xmlreader.GetValueAsBool("veracontroller", "AutoSelectRoom", true);
- _selectedSortOption = (VeraSortStyle) xmlreader.GetValueAsInt("veracontroller", "Sort", 0);
- _selectedFilterOption = (VeraFilterStyle)xmlreader.GetValueAsInt("veracontroller", "Filter", 0);
- _viewPerCategory = xmlreader.GetValueAsBool("veracontroller", "ViewMode", false);
+ _selectedSortOption = (VeraSortStyle) xmlreader.GetValueAsInt("veracontroller", "Sort", 0);
+ _selectedFilterOption = (VeraFilterStyle)xmlreader.GetValueAsInt("veracontroller", "Filter", 0);
+ _viewPerCategory = xmlreader.GetValueAsBool("veracontroller", "ViewMode", false);
+ _viewListStyle = xmlreader.GetValueAsBool("veracontroller", "ViewList", true);
}
GUIWindowManager.OnNewAction += new OnActionHandler(OnNewAction);
@@ -271,11 +276,18 @@
protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
{
if (control == _rightList)
- OnRightlistCrtl((GUIListControl)control, actionType);
+ OnRightlistCrtl(actionType);
if (control == _leftList)
- OnLeftlistCrtl((GUIListControl)control);
-
+ OnLeftlistCrtl();
+
+ if (control == _flowList)
+ {
+ if (_devicesFlow)
+ OnRightlistCrtl(actionType);
+ else
+ OnLeftlistCrtl();
+ }
if (control == _sectionList)
OnSectionList((GUISpinButton)control);
@@ -351,12 +363,16 @@
default:
break;
}
-
+
+
// Now handle 'local' actions (only respond when Vera Controller is visible)
if (GUIWindowManager.ActiveWindow == GetWindowId())
{
switch(action.wID)
{
+ case Action.ActionType.ACTION_PREVIOUS_MENU:
+ break;
+
case Action.ActionType.ACTION_MOUSE_MOVE:
break;
@@ -582,23 +598,44 @@
}
RefreshNow();
- // Auto update right side list
- if (_autoSelectRoom &&
- (!_viewPerCategory && _selectedRoom != _leftList.SelectedListItem.ItemId) ||
- ( _viewPerCategory && _selectedCategory != _leftList.SelectedListItem.ItemId) )
+ // Auto update right side list (only valid when we see lists)
+ if (_autoSelectRoom && _viewListStyle)
{
- OnLeftlistCrtl(_leftList);
+ if ((!_viewPerCategory && _selectedRoom != _leftList.SelectedListItem.ItemId) ||
+ ( _viewPerCategory && _selectedCategory != _leftList.SelectedListItem.ItemId) )
+ {
+ OnLeftlistCrtl();
+ }
}
-
base.Render(timePassed);
}
+ public List<GUIListItem> GetListItems()
+ {
+ if (_viewListStyle)
+ {
+ return _rightList.ListItems;
+ }
+ if (!_devicesFlow)
+ {
+ // No devices return empty list
+ return new List<GUIListItem>();
+ }
+
+ List<GUIListItem> list = new List<GUIListItem>();
+ for (int i = 0; i < _flowList.Count; i++)
+ {
+ list.Add(_flowList.GetCard(i));
+ }
+ return list;
+ }
+
public void RefreshNow()
{
int selectedItem = 0;
- if (_rightList.SelectedListItem != null)
+ if ((_viewListStyle && _rightList.SelectedListItem != null) || (!_viewListStyle && _devicesFlow && _flowList.SelectedListItem != null))
{ // Prevent Eception in case we have an empty room
- selectedItem = _rightList.SelectedListItem.ItemId;
+ selectedItem = (_viewListStyle ? _rightList.SelectedListItem.ItemId : _flowList.SelectedListItem.ItemId);
}
else if (_lastSelectedItemId != 0)
{
@@ -611,28 +648,32 @@
if (_vera.NewScreenUpdateWaitingAndClearFlag() || newSelectedItem)
{
// if full reload has been found rebuild lists
- if (_vera.FullReloadWaitingAndClearFlag() ) {
+ if (_vera.FullReloadWaitingAndClearFlag() )
+ {
FillLists(false);
}
else
{
// update device status
- foreach (GUIListItem item in _rightList.ListItems)
+ foreach (GUIListItem item in GetListItems())
{
- if (item.ItemId > 0)
- { // ItemId > 0 so we have a device
- DeviceGeneric dev = _vera.GetDeviceById(item.ItemId);
- if (dev.NewScreenUpdateWaitingAndClearFlag() || (newSelectedItem && _lastSelectedItemId == item.ItemId))
- {
- FillinDeviceInfo(item, dev);
+ if (item.ItemId != ALL)
+ {
+ if (item.ItemId > 0)
+ { // ItemId > 0 so we have a device
+ DeviceGeneric dev = _vera.GetDeviceById(item.ItemId);
+ if (dev.NewScreenUpdateWaitingAndClearFlag() || (newSelectedItem && _lastSelectedItemId == item.ItemId))
+ {
+ FillinDeviceInfo(item, dev);
+ }
}
- }
- else
- { // ItemId < 0 so we have a scene
- Scene scene = _vera.GetSceneById((item.ItemId * -1));
- if (scene.NewScreenUpdateWaitingAndClearFlag() || (newSelectedItem && _lastSelectedItemId == item.ItemId))
- {
- FillinSceneInfo(item, scene);
+ else
+ { // ItemId < 0 so we have a scene
+ Scene scene = _vera.GetSceneById((item.ItemId * -1));
+ if (scene.NewScreenUpdateWaitingAndClearFlag() || (newSelectedItem && _lastSelectedItemId == item.ItemId))
+ {
+ FillinSceneInfo(item, scene);
+ }
}
}
}
@@ -660,7 +701,7 @@
_actionAutoRoomButton.Selected = _autoSelectRoom;
_actionSortButton.Label = "Sort: " + _sortOptions[(int)_selectedSortOption].shorttext;
_actionFilterButton.Label = "Filter: " + _filterOptions[(int)_selectedFilterOption].shorttext;
- _actionViewButton.Label = "View: " + (_viewPerCategory ? "Category" : "Room");;
+ _actionViewButton.Label = "View: " + (_viewPerCategory ? "Category" : "Room") + (_viewListStyle ? " (list)" : " (flow)");
// Set selected box information - get availabiliy information here (not earlier, on init() not all boxes did have the change to response)
using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings())
@@ -694,23 +735,97 @@
{
ListSections();
}
- if (_viewPerCategory)
+ if (_viewListStyle)
{
- ListCategories(_selectedCategory);
- if (_selectedCategory == ALL) {
- ListScenes(ALL, _selectedSection);
- } else {
- ListDevicesPerCategory(_selectedCategory);
+ _rightList.Visibility = Visibility.Visible;
+ _leftList.Visibility = Visibility.Visible;
+ _flowList.Visibility = Visibility.Hidden;
+
+ _sectionList.NavigateUp = _leftList.GetID;
+ _sectionList.NavigateDown = _leftList.GetID;
+ _sectionList.NavigateRight = _rightList.GetID;
+
+ _actionVeraSelectButton.NavigateRight = _leftList.GetID;
+ _actionTriggerButton.NavigateRight = _leftList.GetID;
+ _actionSceneEditButton.NavigateRight = _leftList.GetID;
+ _actionFilterButton.NavigateRight = _leftList.GetID;
+ _actionSortButton.NavigateRight = _leftList.GetID;
+ _actionAutoRoomButton.NavigateRight = _leftList.GetID;
+ _actionViewButton.NavigateRight = _leftList.GetID;
+
+ if (_viewPerCategory)
+ {
+ ListCategories(_selectedCategory);
+ if (_selectedCategory == ALL) {
+ ListScenes(ALL, _selectedSection);
+ } else {
+ ListDevicesPerCategory(_selectedCategory);
+ }
}
+ else
+ {
+ ListRooms(_selectedSection, _selectedRoom);
+ if (_selectedRoom == ALL) {
+ ListScenes(ALL, _selectedSection);
+ } else {
+ ListDevicesPerRoom(_selectedRoom);
+ }
+ }
}
else
{
- ListRooms(_selectedSection, _selectedRoom);
- if (_selectedRoom == ALL) {
- ListScenes(ALL, _selectedSection);
- } else {
- ListDevicesPerRoom(_selectedRoom);
+ _rightList.Visibility = Visibility.Hidden;
+ _leftList.Visibility = Visibility.Hidden;
+ _flowList.Visibility = Visibility.Visible;
+
+ _sectionList.NavigateUp = _flowList.GetID;
+ _sectionList.NavigateDown = _flowList.GetID;
+ _sectionList.NavigateRight = _flowList.GetID;
+
+ _actionVeraSelectButton.NavigateRight = _flowList.GetID;
+ _actionTriggerButton.NavigateRight = _flowList.GetID;
+ _actionSceneEditButton.NavigateRight = _flowList.GetID;
+ _actionFilterButton.NavigateRight = _flowList.GetID;
+ _actionSortButton.NavigateRight = _flowList.GetID;
+ _actionAutoRoomButton.NavigateRight = _flowList.GetID;
+ _actionViewButton.NavigateRight = _flowList.GetID;
+
+ if (_viewPerCategory)
+ {
+ if (_devicesFlow)
+ {
+ if (_selectedCategory == ALL)
+ {
+ ListScenes(ALL, _selectedSection);
+ }
+ else
+ {
+ ListDevicesPerCategory(_selectedCategory);
+ }
+ }
+ else
+ {
+ ListCategories(_selectedCategory);
+ }
}
+ else
+ {
+ if (_devicesFlow)
+ {
+ if (_selectedCategory == ALL)
+ {
+ ListScenes(ALL, _selectedSection);
+ }
+ else
+ {
+ ListDevicesPerRoom(_selectedCategory);
+ }
+ }
+ else
+ {
+ ListRooms(_selectedSection, _selectedRoom);
+ }
+ }
}
}
@@ -797,7 +912,7 @@
int cnt = 0;
int selected = 0;
// --- fill in left lisft with rooms and scene item
- GUIControl.ClearControl(GetID, _leftList.GetID);
+ GUIControl.ClearControl(GetID, (_viewListStyle ? _leftList.GetID : _flowList.GetID));
GUIListItem sceneitem = new GUIListItem("Scenes");
sceneitem.ItemId = ALL;
@@ -806,23 +921,49 @@
sceneitem.ThumbnailImage = "Vera\\Scenes.png";
Utils.SetDefaultIcons(sceneitem);
- _leftList.Add(sceneitem);
-
+ if (_viewListStyle)
+ {
+ _leftList.Add(sceneitem);
+ }
+ else
+ {
+ sceneitem.IsFolder = true;
+ _flowList.Add(sceneitem);
+ }
foreach(Room room in _vera.GetSortedRooms(_selectedBox, _selectedSortOption))
{
if (showSection == ALL || room.section == showSection)
{
GUIListItem item = new GUIListItem(room.name);
+
+ string sectioname = _vera.GetSectionById(room.section).name;
item.Label2 = _vera.GetSectionById(room.section).name;
-
item.ItemId = room.id;
- item.IconImage = @"Vera\OpenList.png";
- item.IconImageBig = @"Vera\OpenList.png";
- item.ThumbnailImage = @"Vera\OpenList.png";
-
- Utils.SetDefaultIcons(item);
- _leftList.Add(item);
-
+ if (_viewListStyle)
+ {
+ item.IconImage = @"Vera\OpenList.png";
+ item.IconImageBig = @"Vera\OpenList.png";
+ item.ThumbnailImage = @"Vera\OpenList.png";
+
+ Utils.SetDefaultIcons(item);
+
+ _leftList.Add(item);
+ }
+ else
+ {
+ item.IconImage = @"Vera\room.png";
+ item.IconImageBig = @"Vera\room.png";
+ item.ThumbnailImage = @"Vera\room.png";
+
+ Utils.SetDefaultIcons(item);
+
+ item.IsFolder = true;
+ if (sectioname != "")
+ {
+ item.Label = sectioname + ": " + room.name;
+ }
+ _flowList.Add(item);
+ }
cnt++;
if (selectedRoom == room.id)
{
@@ -831,7 +972,11 @@
}
}
// Set Current Selected Item
- _leftList.SelectedListItemIndex = selected;
+ if (_viewListStyle) {
+ _leftList.SelectedListItemIndex = selected;
+ } else {
+ _flowList.SelectedListItemIndex = selected;
+ }
}
private void ListCategories(int selectedCategory)
@@ -839,7 +984,8 @@
int cnt = 0;
int selected = 0;
// --- fill in left lisft with rooms and scene item
- GUIControl.ClearControl(GetID, _leftList.GetID);
+ GUIControl.ClearControl(GetID, (_viewListStyle ? _leftList.GetID : _flowList.GetID));
+
GUIListItem sceneitem = new GUIListItem("Scenes");
sceneitem.ItemId = ALL;
@@ -848,8 +994,15 @@
sceneitem.ThumbnailImage = "Vera\\Scenes.png";
Utils.SetDefaultIcons(sceneitem);
- _leftList.Add(sceneitem);
-
+ if (_viewListStyle)
+ {
+ _leftList.Add(sceneitem);
+ }
+ else
+ {
+ sceneitem.IsFolder = true;
+ _flowList.Add(sceneitem);
+ }
foreach(DevCategories category in (_selectedBox == ALL ? _vera.categories : _vera.boxes[_selectedBox].categories))
{
if (_vera.ContainsSectionThisCategoyy(category.id, _selectedSection, _selectedFilterOption))
@@ -861,8 +1014,15 @@
item.ThumbnailImage = @"Vera\" + category.GetIconName() + ".png";
Utils.SetDefaultIcons(item);
- _leftList.Add(item);
-
+ if (_viewListStyle)
+ {
+ _leftList.Add(item);
+ }
+ else
+ {
+ item.IsFolder = true;
+ _flowList.Add(item);
+ }
cnt++;
if (selectedCategory == category.id)
{
@@ -871,27 +1031,54 @@
}
}
// Set Current Selected Item
- _leftList.SelectedListItemIndex = selected;
+ if (_viewListStyle) {
+ _leftList.SelectedListItemIndex = selected;
+ } else {
+ _flowList.SelectedListItemIndex = selected;
+ }
}
private void ListScenes(int selectedRoom, int selectedSection)
{
- GUIControl.ClearControl(GetID, _rightList.GetID);
+ GUIControl.ClearControl(GetID, (_viewListStyle ? _rightList.GetID : _flowList.GetID));
+ if (!_viewListStyle)
+ {
+ // --- fill in flowlist a return icon
+ GUIListItem backitem = new GUIListItem("back");
+ backitem.ItemId = ALL;
+
+ backitem.IconImage = "Vera\\back.png";
+ backitem.IconImageBig = "Vera\\back.png";
+ backitem.ThumbnailImage = "Vera\\back.png";
+
+ Utils.SetDefaultIcons(backitem);
+ backitem.IsFolder = true;
+ _flowList.Add(backitem);
+ }
+
foreach(Scene scene in _vera.GetSortedScenes(_selectedBox, _selectedSortOption))
{
if ((selectedRoom == ALL || scene.InRoom(selectedRoom)) && _vera.IsRoomInSection(scene.room, selectedSection))
{
GUIListItem item = new GUIListItem(scene.name);
FillinSceneInfo(item, scene);
- _rightList.Add(item);
+ if (_viewListStyle) {
+ _rightList.Add(item);
+ } else {
+ item.IsFolder = true;
+ _flowList.Add(item);
+ }
}
}
GUIControl.FocusControl(GetID, _leftList.GetID);
// Set Current Selected Item
- _rightList.SelectedListItemIndex = 0;
-
+ if (_viewListStyle) {
+ _rightList.SelectedListItemIndex = 0;
+ } else {
+ _flowList.SelectedListItemIndex = 0;
+ }
_title.Label = _titleTxt + " - Scenes";
}
@@ -923,7 +1110,12 @@
{
GUIListItem item = new GUIListItem(dev.name);
FillinDeviceInfo(item, dev);
- _rightList.Add(item);
+ if (_viewListStyle) {
+ _rightList.Add(item);
+ } else {
+ item.IsFolder = true;
+ _flowList.Add(item);
+ }
}
}
_title.Label = _titleTxt + " - " + _vera.GetRoomById(selectedRoom).name;
@@ -931,8 +1123,23 @@
private void ListDevicesPerCategory(int selectedCategory)
{
- GUIControl.ClearControl(GetID, _rightList.GetID);
+ GUIControl.ClearControl(GetID, (_viewListStyle ? _rightList.GetID : _flowList.GetID));
+ if (!_viewListStyle)
+ {
+ // --- fill in flowlist a return icon
+ GUIListItem backitem = new GUIListItem("back");
+ backitem.ItemId = ALL;
+
+ backitem.IconImage = "Vera\\back.png";
+ backitem.IconImageBig = "Vera\\back.png";
+ backitem.ThumbnailImage = "Vera\\back.png";
+
+ Utils.SetDefaultIcons(backitem);
+ backitem.IsFolder = true;
+ _flowList.Add(backitem);
+ }
+
foreach(DeviceGeneric dev in _vera.GetSortedDevices(_selectedBox, _selectedSortOption))
{
if (dev.InCategory(selectedCategory) && dev.PassesFilter(_selectedFilterOption))
@@ -941,7 +1148,11 @@
{
GUIListItem item = new GUIListItem(dev.name);
FillinDeviceInfo(item, dev);
- _rightList.Add(item);
+ if (_viewListStyle) {
+ _rightList.Add(item);
+ } else {
+ _flowList.Add(item);
+ }
}
}
}
@@ -960,17 +1171,23 @@
Utils.SetDefaultIcons(item);
+ if (!_viewListStyle)
+ {
+ item.Label = dev.name + (dev.GetStatusText() != "" ? " [" + dev.GetStatusText() +"]" : "");
+ item.IsFolder = true;
+ }
+
if (_lastSelectedItemId == dev.id)
{
SetDeviceStatus(dev.commstate, dev.comment);
}
}
- private void OnLeftlistCrtl(GUIListControl control)
+ private void OnLeftlistCrtl()
{
- int id = control.SelectedListItem.ItemId;
+ int id = (_viewListStyle ? _leftList.SelectedListItem.ItemId : _flowList.SelectedListItem.ItemId);
- GUIAnimation.HideControl(GetID, _rightList.GetID);
+ _devicesFlow = true;
if (_viewPerCategory)
{
_selectedCategory = id;
@@ -996,8 +1213,6 @@
ListDevicesPerRoom(id);
}
}
-
- GUIAnimation.ShowControl(GetID, _rightList.GetID);
}
private void OnSectionList(GUISpinButton control)
@@ -1005,13 +1220,12 @@
if (control.SpinValue > 0)
{
_selectedSection = _vera.GetSections(_selectedBox)[control.SpinValue-1].id;;
- //_selectedSection = _vera.sections[control.SpinValue-1].id;
}
else
{
_selectedSection = ALL;
}
- if (_selectedSection == 0 )
+ if (_selectedSection == 0)
{
_selectedSection = ALL;
}
@@ -1023,11 +1237,18 @@
FillLists(false);
}
- private void OnRightlistCrtl(GUIListControl control, Action.ActionType actionType)
+ private void OnRightlistCrtl(Action.ActionType actionType)
{
- if (control.SelectedListItem.ItemId < 0)
+ int itemId = (_viewListStyle ? _rightList.SelectedListItem.ItemId : _flowList.SelectedListItem.ItemId);
+ if (itemId == ALL)
+ {
+ _devicesFlow = false;
+ FillLists(false);
+ return;
+ }
+ if (itemId < 0)
{ // We have a scene as selected item (id <= 0)
- Scene scene = _vera.GetSceneById((control.SelectedListItem.ItemId * -1));
+ Scene scene = _vera.GetSceneById((itemId * -1));
if (scene != null)
{
@@ -1047,7 +1268,7 @@
}
else
{ // We have a device as selected item
- DeviceGeneric dev = _vera.GetDeviceById(control.SelectedListItem.ItemId);
+ DeviceGeneric dev = _vera.GetDeviceById(itemId);
switch (actionType)
{
@@ -1122,6 +1343,7 @@
}
// Update lists to reflect choice
+ _devicesFlow = false;
FillLists(true);
RefreshNow();
}
@@ -1155,6 +1377,7 @@
}
// Update lists to reflect choice
+ _devicesFlow = false;
FillLists(true);
RefreshNow();
}
@@ -1169,24 +1392,30 @@
dlgMenu.Reset();
dlgMenu.SetHeading("Select viewing mode");
- dlgMenu.Add("View per room");
- dlgMenu.Add("View per category");
+ dlgMenu.Add("View lists per room");
+ dlgMenu.Add("View list per category");
+ dlgMenu.Add("View flowstyle per room");
+ dlgMenu.Add("View flowstyle per category");
dlgMenu.DoModal(GUIWindowManager.ActiveWindow);
if (dlgMenu.SelectedLabel != -1)
{
// Something was selected
- _viewPerCategory = (dlgMenu.SelectedId == 2);
- control.Label = "View: " + (_viewPerCategory ? "Category" : "Room");
+ _viewPerCategory = (dlgMenu.SelectedId == 2) || (dlgMenu.SelectedId == 4);
+ _viewListStyle = (dlgMenu.SelectedId <= 2);
+ control.Label = "...
[truncated message content] |