|
From: <Ba...@us...> - 2012-01-08 22:16:54
|
Revision: 4398
http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4398&view=rev
Author: BartEv
Date: 2012-01-08 22:16:47 +0000 (Sun, 08 Jan 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/plugins/VeraControl/VeraCommunication.cs
trunk/plugins/VeraControl/VeraControl.cs
trunk/plugins/VeraControl/VeraSetupForm.Designer.cs
trunk/plugins/VeraControl/VeraSetupForm.cs
Modified: trunk/plugins/VeraControl/VeraCommunication.cs
===================================================================
--- trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-08 21:54:57 UTC (rev 4397)
+++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-08 22:16:47 UTC (rev 4398)
@@ -204,10 +204,10 @@
using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings())
{
m_sVeraIPAddress = xmlreader.GetValueAsString("veracontroller", "ipaddress", "127.0.0.1");
- m_sVeraTCPIPPort = xmlreader.GetValueAsString("veracontroller", "portnumber", "49451");
- m_sVeraIPAddress = "192.10.1.240";
+ m_sVeraTCPIPPort = xmlreader.GetValueAsString("veracontroller", "portnumber", "3480");
+ //m_sVeraIPAddress = "192.10.1.240";
// m_sVeraIPAddress = "demo.mios.com";
- m_sVeraTCPIPPort = "3480";
+ // m_sVeraTCPIPPort = "3480";
// Fill action table (config settings)
for (Actiontrigger i = 0; i < Actiontrigger.LAST_ACTIONTRIGGER; i++)
@@ -397,9 +397,15 @@
return response;
}
+ public bool isVeraAlive(string ip, string port)
+ {
+ string response = retrieveURL("http://" + ip + ":" + port + "/data_request?id=lu_alive&time="+DateTime.Now.Ticks);
+
+ return (response == "OK");
+ }
+
public string doVeraRequest( string param )
{
-
return retrieveURL("http://" + vera_Address + "/data_request" + param + "&time="+DateTime.Now.Ticks);
}
@@ -425,7 +431,7 @@
return response;
}
- private long getSecondsSince1970()
+ public long getSecondsSince1970()
{
return (DateTime.Now.Ticks / 10000000);
}
@@ -480,7 +486,7 @@
public string vera_Address
{
- get { return m_sVeraIPAddress + " : " +m_sVeraTCPIPPort; }
+ get { return m_sVeraIPAddress + ":" +m_sVeraTCPIPPort; }
set { }
}
}
Modified: trunk/plugins/VeraControl/VeraControl.cs
===================================================================
--- trunk/plugins/VeraControl/VeraControl.cs 2012-01-08 21:54:57 UTC (rev 4397)
+++ trunk/plugins/VeraControl/VeraControl.cs 2012-01-08 22:16:47 UTC (rev 4398)
@@ -31,6 +31,10 @@
[assembly: UsesSubsystem("MP.SkinEngine")]
[assembly: UsesSubsystem("MP.Config")]
+// TODO: support multiple Vera Box
+// TODO: get all boxes for a specific user (http://sta1.mios.com/locator_json.php?username=<user>)
+// TODO: support remote vera Boxes (http://fwd1.mios.com/<name>/<pass>/<serial>/data_request?...)
+
namespace VeraControl
{
public enum Actiontrigger
Modified: trunk/plugins/VeraControl/VeraSetupForm.Designer.cs
===================================================================
--- trunk/plugins/VeraControl/VeraSetupForm.Designer.cs 2012-01-08 21:54:57 UTC (rev 4397)
+++ trunk/plugins/VeraControl/VeraSetupForm.Designer.cs 2012-01-08 22:16:47 UTC (rev 4398)
@@ -33,6 +33,8 @@
this.labelIPaddress = new System.Windows.Forms.Label();
this.IPaddress = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.ConnectionResponse = new System.Windows.Forms.Label();
+ this.CheckConnection = new System.Windows.Forms.Button();
this.labelPortNumber = new System.Windows.Forms.Label();
this.portnumber = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
@@ -46,7 +48,7 @@
// btnOK
//
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.btnOK.Location = new System.Drawing.Point(31, 194);
+ this.btnOK.Location = new System.Drawing.Point(31, 236);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 3;
@@ -58,7 +60,7 @@
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.btnCancel.Location = new System.Drawing.Point(231, 194);
+ this.btnCancel.Location = new System.Drawing.Point(231, 236);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 4;
@@ -88,17 +90,36 @@
//
// groupBox1
//
+ this.groupBox1.Controls.Add(this.ConnectionResponse);
+ this.groupBox1.Controls.Add(this.CheckConnection);
this.groupBox1.Controls.Add(this.labelPortNumber);
this.groupBox1.Controls.Add(this.portnumber);
this.groupBox1.Controls.Add(this.labelIPaddress);
this.groupBox1.Controls.Add(this.IPaddress);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(311, 78);
+ this.groupBox1.Size = new System.Drawing.Size(311, 121);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Vera Box -setting";
//
+ // ConnectionResponse
+ //
+ this.ConnectionResponse.Location = new System.Drawing.Point(168, 88);
+ this.ConnectionResponse.Name = "ConnectionResponse";
+ this.ConnectionResponse.Size = new System.Drawing.Size(123, 19);
+ this.ConnectionResponse.TabIndex = 7;
+ //
+ // CheckConnection
+ //
+ this.CheckConnection.Location = new System.Drawing.Point(19, 84);
+ this.CheckConnection.Name = "CheckConnection";
+ this.CheckConnection.Size = new System.Drawing.Size(136, 23);
+ this.CheckConnection.TabIndex = 6;
+ this.CheckConnection.Text = "Check Connection";
+ this.CheckConnection.UseVisualStyleBackColor = true;
+ this.CheckConnection.Click += new System.EventHandler(this.CheckConnection_Click);
+ //
// labelPortNumber
//
this.labelPortNumber.AutoSize = true;
@@ -118,7 +139,7 @@
this.portnumber.Name = "portnumber";
this.portnumber.Size = new System.Drawing.Size(205, 20);
this.portnumber.TabIndex = 2;
- this.portnumber.Text = "49451";
+ this.portnumber.Text = "3480";
//
// label1
//
@@ -146,7 +167,7 @@
this.groupBox2.Controls.Add(this.enableSceneTrigger);
this.groupBox2.Controls.Add(this.refreshdelay);
this.groupBox2.Controls.Add(this.label1);
- this.groupBox2.Location = new System.Drawing.Point(14, 96);
+ this.groupBox2.Location = new System.Drawing.Point(11, 139);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(309, 82);
this.groupBox2.TabIndex = 8;
@@ -168,7 +189,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
- this.ClientSize = new System.Drawing.Size(332, 229);
+ this.ClientSize = new System.Drawing.Size(332, 271);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.btnCancel);
@@ -183,6 +204,8 @@
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
}
+ private System.Windows.Forms.Label ConnectionResponse;
+ private System.Windows.Forms.Button CheckConnection;
private System.Windows.Forms.CheckBox enableSceneTrigger;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TextBox refreshdelay;
Modified: trunk/plugins/VeraControl/VeraSetupForm.cs
===================================================================
--- trunk/plugins/VeraControl/VeraSetupForm.cs 2012-01-08 21:54:57 UTC (rev 4397)
+++ trunk/plugins/VeraControl/VeraSetupForm.cs 2012-01-08 22:16:47 UTC (rev 4398)
@@ -25,6 +25,8 @@
using MediaPortal.Configuration;
using MediaPortal.UserInterface.Controls;
using MediaPortal.Profile;
+using VeraControl.Properties;
+using System.Net;
namespace MediaPortal.GUI.VeraSetupForm
{
@@ -70,5 +72,49 @@
Close();
}
+
+ void CheckConnection_Click(object sender, EventArgs e)
+ {
+ ConnectionResponse.Text = "testing";
+ ConnectionResponse.Update();
+
+ try {
+ WebClient webClient = new WebClient();
+
+ Uri url = new Uri("http://" + IPaddress.Text + ":" + portnumber.Text + "/data_request?id=lu_alive&time="+DateTime.Now.Ticks);
+ webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnAsyncCompletedEventArgs);
+ webClient.DownloadStringAsync(url);
+
+ int cnt = 0;
+ long time = VeraCommunication.Instance.getSecondsSince1970();
+ while (webClient.IsBusy)
+ {
+ if (time != VeraCommunication.Instance.getSecondsSince1970())
+ {
+ cnt++;
+ time = VeraCommunication.Instance.getSecondsSince1970();
+ ConnectionResponse.Text = "testing" + new string('.', cnt % 10);
+ ConnectionResponse.Update();
+ }
+ }
+ }
+ catch
+ {
+ ConnectionResponse.Text = "Bad response";
+ }
+ }
+
+ void OnAsyncCompletedEventArgs(Object sender, DownloadStringCompletedEventArgs e)
+ {
+ //if (VeraCommunication.Instance.isVeraAlive(IPaddress.Text, portnumber.Text))
+ if (!e.Cancelled && e.Error == null && (string)e.Result == "OK")
+ {
+ ConnectionResponse.Text = "- Ok -";
+ }
+ else
+ {
+ ConnectionResponse.Text = "ERR: Time out";
+ }
+ }
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|