From: <Ba...@us...> - 2012-01-21 12:46:03
|
Revision: 4417 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4417&view=rev Author: BartEv Date: 2012-01-21 12:45:56 +0000 (Sat, 21 Jan 2012) Log Message: ----------- Added WebCam movement control support Modified Paths: -------------- trunk/plugins/VeraControl/DeviceCam.cs trunk/plugins/VeraControl/DeviceGeneric.cs trunk/plugins/VeraControl/DialogDeviceControl.cs trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml Modified: trunk/plugins/VeraControl/DeviceCam.cs =================================================================== --- trunk/plugins/VeraControl/DeviceCam.cs 2012-01-21 10:50:48 UTC (rev 4416) +++ trunk/plugins/VeraControl/DeviceCam.cs 2012-01-21 12:45:56 UTC (rev 4417) @@ -18,11 +18,13 @@ { // TODO: add IP-cam control buttons private string m_sIp = "127.0.0.1"; private string m_sUrl = "/"; - private string m_sStream = ""; + private string m_sStream = ""; private string m_sVideoUrl = ""; - private int m_refresh = 10; + private int m_refresh = 2; + private string m_sUser = ""; + private string m_sPass = ""; - public DeviceCam( XmlNode xn ): base (xn) + public DeviceCam( XmlNode xn ): base (xn) { if (xn != null) { @@ -30,22 +32,44 @@ } } - public override bool update(XmlNode xn) + public override bool update(XmlNode xn) { m_sIp = helper.getAttrAsString(xn, "ip", m_sIp); m_sUrl = helper.getAttrAsString(xn, "url", m_sUrl); m_sStream = helper.getAttrAsString(xn, "streaming", m_sStream); m_sVideoUrl = helper.getAttrAsString(xn, "videourls", m_sVideoUrl); + m_sUser = helper.getAttrAsString(xn, "username", ""); + m_sPass = helper.getAttrAsString(xn, "password", ""); - return base.update(xn); + return base.update(xn); } + private string passString + { + get { + if (m_sUser == "") + { + return ""; + } + return m_sUser + ":" + m_sPass + "@"; + } + set { } + } + public string imgUrl { - get { return "http://" + m_sIp + "/" + m_sUrl.Replace("%2F", "/"); } + get { return "http://" + passString + vera.vera_Address + "/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 + m_sIp + "/" + m_sStream.Replace("%2F", "/"); } + set { } + } + public int refreshRate { get { return m_refresh; } @@ -84,5 +108,42 @@ } return b; } + + private void move(string direction) + { + if (id == 0) + { + vera.status.system.reportCommandError("Unknown device"); + m_bScreenUpdateRequired = 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 moveZoomIn() + { + move("ZoomIn"); + } + public override void moveZoomOut() + { + move("ZoomOut"); + } } } Modified: trunk/plugins/VeraControl/DeviceGeneric.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-21 10:50:48 UTC (rev 4416) +++ trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-21 12:45:56 UTC (rev 4417) @@ -115,5 +115,31 @@ { return new string [] {"Off", "On"}; } + + // Overrides 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 moveZoomIn() + { + // do nothing + } + public virtual void moveZoomOut() + { + // do nothing + } } } Modified: trunk/plugins/VeraControl/DialogDeviceControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-21 10:50:48 UTC (rev 4416) +++ trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-21 12:45:56 UTC (rev 4417) @@ -9,6 +9,7 @@ * E-mail: ba...@ev... */ using System; +using System.Threading; using System.Collections; using MediaPortal; using MediaPortal.Util; @@ -35,15 +36,25 @@ [SkinControlAttribute(7)] protected GUILabelControl label2=null; [SkinControlAttribute(8)] protected GUILabelControl label3=null; - [SkinControl(10)] protected GUIButtonControl btnLeft = null; - [SkinControl(11)] protected GUIButtonControl btnRight = null; - [SkinControl(12)] protected GUIButtonControl btnMode1 = null; - [SkinControl(13)] protected GUIButtonControl btnMode2 = null; - [SkinControl(14)] protected GUIButtonControl btnMode3 = null; - [SkinControl(15)] protected GUISliderControl slider = null; - [SkinControl(20)] protected GUIImage camImage = null; + [SkinControl(10)] protected GUIButtonControl btnLeft = null; + [SkinControl(11)] protected GUIButtonControl btnRight = null; + [SkinControl(12)] protected GUIButtonControl btnMode1 = null; + [SkinControl(13)] protected GUIButtonControl btnMode2 = null; + [SkinControl(14)] protected GUIButtonControl btnMode3 = null; + [SkinControl(15)] protected GUISliderControl slider = null; - [SkinControl(30)] protected GUIImage cmtImage = null; + [SkinControl(20)] protected GUIImage camImage1 = null; + [SkinControl(21)] protected GUIImage camImage2 = null; + [SkinControl(50)] protected GUIButtonControl btnCamUp = null; + [SkinControl(51)] protected GUIButtonControl btnCamLeft = null; + [SkinControl(52)] protected GUIButtonControl btnCamRight = null; + [SkinControl(53)] protected GUIButtonControl btnCamDown = null; + [SkinControl(55)] protected GUIButtonControl btnCamZmMin = null; + [SkinControl(56)] protected GUIButtonControl btnCamZmPlus = null; + [SkinControl(57)] protected GUILabelControl labelLoading = null; + + + [SkinControl(30)] protected GUIImage cmtImage = null; [SkinControlAttribute(31)] protected GUILabelControl comment=null; private VeraHelper helper = new VeraHelper(); @@ -52,6 +63,8 @@ private bool m_bLevelUpdatePending = false; private long m_lLastLevelUpdate = 0; private int m_iDesiredLevel = 0; + private bool m_bKeepUpdating = false; + private int _camUpdateDelay = 2; public DialogDeviceControl() { @@ -79,6 +92,22 @@ } updateStatus(); + + if (myDev.GetType() == typeof(DeviceCam)) + { + btnCamUp.Visibility = System.Windows.Visibility.Visible; + btnCamLeft.Visibility = System.Windows.Visibility.Visible; + btnCamRight.Visibility = System.Windows.Visibility.Visible; + btnCamDown.Visibility = System.Windows.Visibility.Visible; + btnCamZmMin.Visibility = System.Windows.Visibility.Visible; + btnCamZmPlus.Visibility = System.Windows.Visibility.Visible; + + btnClose.NavigateDown = 50; + btnClose.NavigateUp = 56; + + imgLogo.Visibility = System.Windows.Visibility.Hidden; + startCamImageUpdater(((DeviceCam)dev).imgUrl); + } } public void updateStatus() @@ -114,11 +143,6 @@ } else { - if (myDev.GetType() == typeof(DeviceCam)) - { - DeviceCam cam = (DeviceCam) myDev; - SetCamImage(cam.imgUrl); - } SetText(myDev.name, myDev.getStatusText(), myDev.getExtraText()); } // save last update ticks @@ -128,6 +152,7 @@ protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (control == btnClose) { + m_bKeepUpdating = false; PageDestroy(); } else { if (control == btnLeft) { @@ -145,6 +170,25 @@ if (control == btnMode3) { myDev.mode = btnMode3.Label; } + // Cam only commands + if (control == btnCamUp) { + myDev.moveUp(); + } + if (control == btnCamLeft) { + myDev.moveLeft(); + } + if (control == btnCamRight) { + myDev.moveRight(); + } + if (control == btnCamDown) { + myDev.moveDown(); + } + if (control == btnCamZmMin) { + myDev.moveZoomOut(); + } + if (control == btnCamZmPlus) { + myDev.moveZoomIn(); + } if (control == slider) { // Do something with fast repeating level changes.... slow down communications m_bLevelUpdatePending = true; @@ -237,17 +281,55 @@ } } - public void SetCamImage(string url) + public int camUpdateDelay { - - camImage.Dispose(); - camImage.SetFileName(url); - camImage.AllocResources(); - camImage.KeepAspectRatio = true; - camImage.Visibility = System.Windows.Visibility.Visible; - imgLogo.Visibility = System.Windows.Visibility.Hidden; + get { return _camUpdateDelay; } + set { _camUpdateDelay = value; } } + public void startCamImageUpdater(string url) + { + m_bKeepUpdating = true; + labelLoading.Visibility = System.Windows.Visibility.Visible; + new Thread (() => + { + while (m_bKeepUpdating) + { + camImage1.Dispose(); + camImage1.SetFileName(url+"&time="+DateTime.Now.Ticks); + camImage1.AllocResources(); + camImage1.KeepAspectRatio = true; + + while (!camImage1.Allocated) + { + Thread.Sleep(100); + } + camImage1.Visibility = System.Windows.Visibility.Visible; + camImage2.Visibility = System.Windows.Visibility.Hidden; + labelLoading.Visibility = System.Windows.Visibility.Hidden; + + Thread.Sleep(_camUpdateDelay * 1000); + + if (m_bKeepUpdating) + { + camImage2.Dispose(); + camImage2.SetFileName(url+"&time="+DateTime.Now.Ticks); + camImage2.AllocResources(); + camImage2.KeepAspectRatio = true; + while (!camImage2.Allocated) + { + Thread.Sleep(100); + } + camImage2.Visibility = System.Windows.Visibility.Visible; + camImage1.Visibility = System.Windows.Visibility.Hidden; + labelLoading.Visibility = System.Windows.Visibility.Hidden; + + Thread.Sleep(_camUpdateDelay * 1000); + } + } + }).Start(); + } + public void SetImage(string filename) { imgLogo.Dispose(); Modified: trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml 2012-01-21 10:50:48 UTC (rev 4416) +++ trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml 2012-01-21 12:45:56 UTC (rev 4417) @@ -237,15 +237,168 @@ </control> <control> + <description>loading label</description> + <type>label</type> + <id>57</id> + <posX>400</posX> + <posY>240</posY> + <label>Loading image...</label> + <font>font13</font> + <textcolor>90FFFFFF</textcolor> + <visible>no</visible> + </control> + <control> <type>image</type> <id>20</id> - <posX>240</posX> + <posX>340</posX> <posY>160</posY> <width>600</width> <height>240</height> <texture></texture> <visible>no</visible> </control> - + <control> + <type>image</type> + <id>21</id> + <posX>340</posX> + <posY>160</posY> + <width>600</width> + <height>240</height> + <texture></texture> + <visible>no</visible> + </control> + <control> + <description>Cam Up</description> + <type>button</type> + <id>50</id> + <posX>190</posX> + <posY>180</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>80</width> + <height>32</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>up</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>51</onleft> + <onright>52</onright> + <onup>2</onup> + <ondown>53</ondown> + <visible>no</visible> + </control> + <control> + <description>Cam left</description> + <type>button</type> + <id>51</id> + <posX>140</posX> + <posY>220</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>80</width> + <height>32</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>left</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>52</onleft> + <onright>52</onright> + <onup>50</onup> + <ondown>52</ondown> + <visible>no</visible> + </control> + <control> + <description>Cam right</description> + <type>button</type> + <id>52</id> + <posX>240</posX> + <posY>220</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>80</width> + <height>32</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>right</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>51</onleft> + <onright>51</onright> + <onup>50</onup> + <ondown>53</ondown> + <visible>no</visible> + </control> + <control> + <description>Cam down</description> + <type>button</type> + <id>53</id> + <posX>190</posX> + <posY>260</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>80</width> + <height>32</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>down</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>51</onleft> + <onright>52</onright> + <onup>50</onup> + <ondown>55</ondown> + <visible>no</visible> + </control> + <control> + <description>Zoom min</description> + <type>button</type> + <id>55</id> + <posX>140</posX> + <posY>320</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>80</width> + <height>32</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>zoom -</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>56</onleft> + <onright>56</onright> + <onup>53</onup> + <ondown>2</ondown> + <visible>no</visible> + </control> + <control> + <description>Zoom plus</description> + <type>button</type> + <id>56</id> + <posX>240</posX> + <posY>320</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>80</width> + <height>32</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>zoom +</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>55</onleft> + <onright>55</onright> + <onup>53</onup> + <ondown>2</ondown> + <visible>no</visible> + </control> + </controls> </window> Modified: trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml 2012-01-21 10:50:48 UTC (rev 4416) +++ trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml 2012-01-21 12:45:56 UTC (rev 4417) @@ -239,15 +239,169 @@ <animation effect="fade" time="250">windowopen</animation> </control> + <control> + <description>loading label</description> + <type>label</type> + <id>57</id> + <posX>630</posX> + <posY>280</posY> + <label>Loading image...</label> + <font>font13</font> + <textcolor>90FFFFFF</textcolor> + <visible>no</visible> + </control> <control> <type>image</type> <id>20</id> - <posX>450</posX> + <posX>550</posX> <posY>200</posY> <width>600</width> <height>300</height> <texture></texture> <visible>no</visible> + </control> + <control> + <type>image</type> + <id>21</id> + <posX>550</posX> + <posY>200</posY> + <width>600</width> + <height>300</height> + <texture></texture> + <visible>no</visible> </control> + <control> + <description>Cam Up</description> + <type>button</type> + <id>50</id> + <posX>335</posX> + <posY>220</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>130</width> + <height>50</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>up</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>51</onleft> + <onright>52</onright> + <onup>2</onup> + <ondown>53</ondown> + <visible>no</visible> + </control> + <control> + <description>Cam left</description> + <type>button</type> + <id>51</id> + <posX>260</posX> + <posY>275</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>130</width> + <height>50</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>left</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>52</onleft> + <onright>52</onright> + <onup>50</onup> + <ondown>52</ondown> + <visible>no</visible> + </control> + <control> + <description>Cam right</description> + <type>button</type> + <id>52</id> + <posX>400</posX> + <posY>275</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>130</width> + <height>50</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>right</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>51</onleft> + <onright>51</onright> + <onup>50</onup> + <ondown>53</ondown> + <visible>no</visible> + </control> + <control> + <description>Cam down</description> + <type>button</type> + <id>53</id> + <posX>335</posX> + <posY>330</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>130</width> + <height>50</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>down</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>51</onleft> + <onright>52</onright> + <onup>50</onup> + <ondown>55</ondown> + <visible>no</visible> + </control> + <control> + <description>Zoom min</description> + <type>button</type> + <id>55</id> + <posX>260</posX> + <posY>420</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>130</width> + <height>50</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>zoom -</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>56</onleft> + <onright>56</onright> + <onup>53</onup> + <ondown>2</ondown> + <visible>no</visible> + </control> + <control> + <description>Zoom plus</description> + <type>button</type> + <id>56</id> + <posX>400</posX> + <posY>420</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>130</width> + <height>50</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>zoom +</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>55</onleft> + <onright>55</onright> + <onup>53</onup> + <ondown>2</ondown> + <visible>no</visible> + </control> + </controls> </window> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |