|
From: <Ba...@us...> - 2012-10-06 20:09:08
|
Revision: 4511
http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4511&view=rev
Author: BartEv
Date: 2012-10-06 20:09:02 +0000 (Sat, 06 Oct 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/plugins/VeraControl/DeviceSprinkler.cs
trunk/plugins/VeraControl/VeraBox.cs
trunk/plugins/VeraControl/VeraControl.cs
trunk/plugins/VeraControl/VeraHelper.cs
Modified: trunk/plugins/VeraControl/DeviceSprinkler.cs
===================================================================
--- trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-09-09 20:42:42 UTC (rev 4510)
+++ trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-10-06 20:09:02 UTC (rev 4511)
@@ -56,7 +56,7 @@
public override bool status
{
get { return _status; }
- set {
+ set {
if (id > 0) // Only send when a valid ID is found
{
ReportPendingRequest();
Modified: trunk/plugins/VeraControl/VeraBox.cs
===================================================================
--- trunk/plugins/VeraControl/VeraBox.cs 2012-09-09 20:42:42 UTC (rev 4510)
+++ trunk/plugins/VeraControl/VeraBox.cs 2012-10-06 20:09:02 UTC (rev 4511)
@@ -15,6 +15,7 @@
using System.Threading;
using System.Collections.Generic;
using System.Xml;
+using System.Linq;
namespace VeraControl.Properties
{
@@ -46,122 +47,77 @@
}
public Room GetRoomById(int id)
{
- foreach(Room room in rooms)
+ var room = from r in rooms where r.id == id select r;
+ if (room.Count() > 0)
{
- if (room.id == id)
- {
- return room;
- }
+ return room.First();
}
return new Room(null, 0);
}
public Section GetSectionById(int id)
{
- foreach(Section section in sections)
+ var section = from s in sections where s.id == id select s;
+ if (section.Count() > 0)
{
- if (section.id == id)
- {
- return section;
- }
+ return section.First();
}
return new Section(null, 0);
}
public DeviceGeneric GetDeviceById(int id)
{
- foreach(DeviceGeneric dev in devices)
+ var device = from d in devices where d.id == id select d;
+ if (device.Count() > 0)
{
- if (dev.id == id)
- {
- return dev;
- }
+ return device.First();
}
return new DeviceGeneric(null, 0);
}
public Scene GetSceneById(int id)
{
- foreach(Scene scene in scenes)
+ var scene = from s in scenes where s.id == id select s;
+ if (scene.Count() > 0)
{
- if (scene.id == id)
- {
- return scene;
- }
+ return scene.First();
}
return new Scene(null, 0);
}
public DevCategories GetCategoryById(int id)
{
- foreach(DevCategories cat in categories)
+ var cat = from c in categories where c.id == id select c;
+ if (cat.Count() > 0)
{
- if (cat.id == id)
- {
- return cat;
- }
+ return cat.First();
}
return new DevCategories(null);
}
public bool IsSectionFound(int id)
{
- foreach(Section section in sections)
- {
- if (section.id == id)
- {
- return true;
- }
- }
- return false;
+ return ((from s in sections where s.id == id select s).Count() > 0);
}
public bool IsRoomFound(int id)
{
- foreach(Room room in rooms)
- {
- if (room.id == id)
- {
- return true;
- }
- }
- return false;
+ return ((from r in rooms where r.id == id select r).Count() > 0);
}
public bool IsDeviceFound(int id)
{
- foreach(DeviceGeneric dev in devices)
- {
- if (dev.id == id)
- {
- return true;
- }
- }
- return false;
+ return ((from d in devices where d.id == id select d).Count() > 0);
}
public bool IsSceneFound(int id)
{
- foreach(Scene scene in scenes)
- {
- if (scene.id == id)
- {
- return true;
- }
- }
- return false;
+ return ((from s in scenes where s.id == id select s).Count() > 0);
}
public bool IsCategoryFound(int id)
{
- foreach(DevCategories cat in categories)
- {
- if (cat.id == id)
- {
- return true;
- }
- }
- return false;
+ return ((from c in categories where c.id == id select c).Count() > 0);
}
#endregion
}
@@ -433,6 +389,9 @@
}
}
+ // TODO: Add non standard json devices; http://192.10.1.240:3480/data_request?id=user_data&output_format=xml
+ // Dynamic create controls based on the supplied information
+
// Process Devices
xnList = xmlDoc.SelectNodes("/root/devices/device");
foreach (XmlNode xn in xnList)
Modified: trunk/plugins/VeraControl/VeraControl.cs
===================================================================
--- trunk/plugins/VeraControl/VeraControl.cs 2012-09-09 20:42:42 UTC (rev 4510)
+++ trunk/plugins/VeraControl/VeraControl.cs 2012-10-06 20:09:02 UTC (rev 4511)
@@ -147,7 +147,7 @@
public VeraControl()
{
- // TO DO: remove this sleep
+ // TODO: remove this sleep
// Thread.Sleep(5000);
}
@@ -254,7 +254,7 @@
Player.PlayBackEnded += new Player.EndedHandler(g_Player_PlayBackEnded);
Player.PlayBackStarted += new Player.StartedHandler(g_Player_PlayBackStarted);
Player.PlayBackStopped += new Player.StoppedHandler(g_Player_PlayBackStopped);
-
+
// Handle MP start-up trigger - do this is a different Thread to not block MP-start up
new Thread( () => {
_vera.UpdateStatusOfAllBoxes();
@@ -325,7 +325,14 @@
#region Action Trigger Detection
private void OnNewAction(Action action)
{
-
+ switch(action.wID)
+ { // This switch is for debug purposes (set breakpoint on next switch to debug Actions add ignore mouse/key actions)
+ case Action.ActionType.ACTION_KEY_PRESSED:
+ case Action.ActionType.ACTION_MOUSE_CLICK:
+ case Action.ActionType.ACTION_MOUSE_DOUBLECLICK:
+ case Action.ActionType.ACTION_MOUSE_MOVE:
+ return;
+ }
// Handle global action responders first (Scene triggers need to be handled also when we are not visible)
switch(action.wID)
{
@@ -347,6 +354,25 @@
}
break;
+ // Handle play button in pause mode
+ case Action.ActionType.ACTION_PLAY:
+ case Action.ActionType.ACTION_MUSIC_PLAY:
+ if (Player.IsMusic && _lastAction == Actiontrigger.MUSIC_PAUSED) {
+ HandleActionTriggers(Actiontrigger.MUSIC_PAUSE_RESUMED);
+ } else if (Player.IsRadio && _lastAction == Actiontrigger.RADIO_PAUSED) {
+ HandleActionTriggers(Actiontrigger.RADIO_PAUSE_RESUMED);
+ } else if (Player.IsTVRecording && _lastAction == Actiontrigger.RECORDING_PAUSED) {
+ HandleActionTriggers(Actiontrigger.RECORDING_PAUSE_RESUMED);
+ } else if ((Player.IsTV || Player.IsTimeShifting) && _lastAction == Actiontrigger.TV_PAUSED) {
+ HandleActionTriggers(Actiontrigger.TV_PAUSE_RESUMED);
+ } else if (Player.IsVideo && _lastAction == Actiontrigger.VIDEO_PAUSED) {
+ HandleActionTriggers(Actiontrigger.VIDEO_PAUSE_RESUMED);
+ } else {
+ if (_lastAction == Actiontrigger.UNKNOWN_PAUSED)
+ HandleActionTriggers(Actiontrigger.UNKNOWN_PAUSE_RESUMED);
+ }
+ break;
+
case Action.ActionType.ACTION_EXIT:
HandleActionTriggers(Actiontrigger.MP_EXIT);
break;
Modified: trunk/plugins/VeraControl/VeraHelper.cs
===================================================================
--- trunk/plugins/VeraControl/VeraHelper.cs 2012-09-09 20:42:42 UTC (rev 4510)
+++ trunk/plugins/VeraControl/VeraHelper.cs 2012-10-06 20:09:02 UTC (rev 4511)
@@ -34,7 +34,7 @@
}
private static volatile VeraHelper _instance;
- private static object _syncRoot = new Object();
+ private static object _syncRoot = new Object();
public static VeraHelper Instance
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|