Now using the TelldusCore api.
This commit is contained in:
parent
79f44a4b9e
commit
b1df94e99c
8 changed files with 68 additions and 43 deletions
|
@ -11,23 +11,29 @@ namespace DeviceHandler
|
||||||
|
|
||||||
|
|
||||||
#region Unmanaged Code
|
#region Unmanaged Code
|
||||||
[DllImport("TellUsbD101.dll")]
|
[DllImport("TelldusCore.dll")]
|
||||||
private static extern bool devTurnOn(int value);
|
private static extern bool tdTurnOn(int value);
|
||||||
|
|
||||||
[DllImport("TellUsbD101.dll")]
|
[DllImport("TelldusCore.dll")]
|
||||||
private static extern bool devTurnOff(int value);
|
private static extern bool tdTurnOff(int value);
|
||||||
|
|
||||||
[DllImport("TellUsbD101.dll")]
|
[DllImport("TelldusCore.dll")]
|
||||||
private static extern int devGetDeviceId(int value);
|
private static extern bool tdBell(int value);
|
||||||
|
|
||||||
[DllImport("TellUsbD101.dll")]
|
[DllImport("TelldusCore.dll")]
|
||||||
private static extern string devGetName(int value);
|
private static extern int tdGetDeviceId(int value);
|
||||||
|
|
||||||
[DllImport("TellUsbD101.dll")]
|
[DllImport("TelldusCore.dll")]
|
||||||
private static extern string devGetVendor(int value);
|
private static extern string tdGetName(int value);
|
||||||
|
|
||||||
[DllImport("TellUsbD101.dll")]
|
[DllImport("TelldusCore.dll")]
|
||||||
private static extern int devGetNumberOfDevices();
|
private static extern string tdGetProtocol(int value);
|
||||||
|
|
||||||
|
[DllImport("TelldusCore.dll")]
|
||||||
|
private static extern int tdGetNumberOfDevices();
|
||||||
|
|
||||||
|
[DllImport("TelldusCore.dll")]
|
||||||
|
private static extern int tdClose();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private List<Device> m_Devices = new List<Device>();
|
private List<Device> m_Devices = new List<Device>();
|
||||||
|
@ -50,12 +56,12 @@ namespace DeviceHandler
|
||||||
/// <returns>True if the command was successfull and false if not.</returns>
|
/// <returns>True if the command was successfull and false if not.</returns>
|
||||||
public bool TurnOff(Device item)
|
public bool TurnOff(Device item)
|
||||||
{
|
{
|
||||||
return devTurnOff(item.ID);
|
return tdTurnOff(item.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TurnOffWithDelay(Device item)
|
public bool TurnOffWithDelay(Device item)
|
||||||
{
|
{
|
||||||
bool result = devTurnOff(item.ID);
|
bool result = tdTurnOff(item.ID);
|
||||||
System.Threading.Thread.Sleep(1000);
|
System.Threading.Thread.Sleep(1000);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -67,14 +73,33 @@ namespace DeviceHandler
|
||||||
/// <returns>True if the command was successfull.</returns>
|
/// <returns>True if the command was successfull.</returns>
|
||||||
public bool TurnOn(Device item)
|
public bool TurnOn(Device item)
|
||||||
{
|
{
|
||||||
return devTurnOn(item.ID);
|
return tdTurnOn(item.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool TurnOnWithDelay(Device item)
|
public bool TurnOnWithDelay(Device item)
|
||||||
{
|
{
|
||||||
//Makesure that we halt for 1 second so that the Telldus stick have time to send the signal.
|
//Makesure that we halt for 1 second so that the Telldus stick have time to send the signal.
|
||||||
bool result = devTurnOn(item.ID);
|
bool result = tdTurnOn(item.ID);
|
||||||
|
System.Threading.Thread.Sleep(1000);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the bell signal.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The device in question.</param>
|
||||||
|
/// <returns>True if the command was successfull.</returns>
|
||||||
|
public bool Bell(Device item)
|
||||||
|
{
|
||||||
|
return tdBell(item.ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool BellWithDelay(Device item)
|
||||||
|
{
|
||||||
|
//Makesure that we halt for 1 second so that the Telldus stick have time to send the signal.
|
||||||
|
bool result = tdBell(item.ID);
|
||||||
System.Threading.Thread.Sleep(1000);
|
System.Threading.Thread.Sleep(1000);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -89,15 +114,15 @@ namespace DeviceHandler
|
||||||
{
|
{
|
||||||
m_Devices.Clear();
|
m_Devices.Clear();
|
||||||
|
|
||||||
int count = devGetNumberOfDevices() - 1;
|
int count = tdGetNumberOfDevices() - 1;
|
||||||
for (int i = 0; i <= count; i++)
|
for (int i = 0; i <= count; i++)
|
||||||
{
|
{
|
||||||
//Collect information from the driver.
|
//Collect information from the driver.
|
||||||
int deviceID = devGetDeviceId(i);
|
int deviceID = tdGetDeviceId(i);
|
||||||
string deviceName = devGetName(deviceID);
|
string deviceName = tdGetName(deviceID);
|
||||||
string deviceVendor = devGetVendor(deviceID);
|
string deviceProtocol = tdGetProtocol(deviceID);
|
||||||
|
|
||||||
m_Devices.Add(new Device(deviceID, deviceName, deviceVendor));
|
m_Devices.Add(new Device(deviceID, deviceName, deviceProtocol));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -127,18 +152,18 @@ namespace DeviceHandler
|
||||||
{
|
{
|
||||||
private int m_ID = -1;
|
private int m_ID = -1;
|
||||||
private string m_Name = "";
|
private string m_Name = "";
|
||||||
private string m_Vendor = "";
|
private string m_Protocol = "";
|
||||||
|
|
||||||
public Device(SerializationInfo info,StreamingContext cntx)
|
public Device(SerializationInfo info,StreamingContext cntx)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Device(int id, string name,string vendor)
|
public Device(int id, string name,string protocol)
|
||||||
{
|
{
|
||||||
m_ID = id;
|
m_ID = id;
|
||||||
m_Name = name;
|
m_Name = name;
|
||||||
m_Vendor = vendor;
|
m_Protocol = protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ID
|
public int ID
|
||||||
|
@ -153,10 +178,10 @@ namespace DeviceHandler
|
||||||
set { m_Name = value; }
|
set { m_Name = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Vendor
|
public string Protocol
|
||||||
{
|
{
|
||||||
get { return m_Vendor; }
|
get { return m_Protocol; }
|
||||||
set { m_Vendor = value; }
|
set { m_Protocol = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Telldus Technologies")]
|
[assembly: AssemblyCompany("Telldus Technologies")]
|
||||||
[assembly: AssemblyProduct("DeviceHandler")]
|
[assembly: AssemblyProduct("DeviceHandler")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Telldus Technologies 2007")]
|
[assembly: AssemblyCopyright("Copyright © Telldus Technologies 2009")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||||
//
|
//
|
||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("2007.1.1.2")]
|
[assembly: AssemblyVersion("2009.2.0.0")]
|
||||||
[assembly: AssemblyFileVersion("2007.1.1.2")]
|
[assembly: AssemblyFileVersion("2009.2.0.0")]
|
||||||
|
|
|
@ -16,6 +16,9 @@
|
||||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||||
<UpgradeBackupLocation>
|
<UpgradeBackupLocation>
|
||||||
</UpgradeBackupLocation>
|
</UpgradeBackupLocation>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<TargetFrameworkSubset>
|
||||||
|
</TargetFrameworkSubset>
|
||||||
<PublishUrl>publish\</PublishUrl>
|
<PublishUrl>publish\</PublishUrl>
|
||||||
<Install>true</Install>
|
<Install>true</Install>
|
||||||
<InstallFrom>Disk</InstallFrom>
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
@ -28,11 +31,8 @@
|
||||||
<MapFileExtensions>true</MapFileExtensions>
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
<ApplicationRevision>0</ApplicationRevision>
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
<TargetFrameworkSubset>
|
|
||||||
</TargetFrameworkSubset>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Telldus Technologies")]
|
[assembly: AssemblyCompany("Telldus Technologies")]
|
||||||
[assembly: AssemblyProduct("DeviceScheduler")]
|
[assembly: AssemblyProduct("DeviceScheduler")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Telldus Technologies 2007")]
|
[assembly: AssemblyCopyright("Copyright © Telldus Technologies 2009")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("2007.1.1.2")]
|
[assembly: AssemblyVersion("2009.2.0.0")]
|
||||||
[assembly: AssemblyFileVersion("2007.1.1.2")]
|
[assembly: AssemblyFileVersion("2009.2.0.0")]
|
||||||
|
|
|
@ -158,7 +158,7 @@ namespace DeviceScheduler
|
||||||
{
|
{
|
||||||
ListViewItem item = lvwCommon.Items.Add(dev.Name,2);
|
ListViewItem item = lvwCommon.Items.Add(dev.Name,2);
|
||||||
item.SubItems.Add(dev.ID.ToString());
|
item.SubItems.Add(dev.ID.ToString());
|
||||||
item.SubItems.Add(dev.Vendor);
|
item.SubItems.Add(dev.Protocol);
|
||||||
item.Tag = dev;
|
item.Tag = dev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ namespace DeviceScheduler
|
||||||
Cursor = Cursors.WaitCursor;
|
Cursor = Cursors.WaitCursor;
|
||||||
|
|
||||||
System.Diagnostics.Process proc = new System.Diagnostics.Process();
|
System.Diagnostics.Process proc = new System.Diagnostics.Process();
|
||||||
string filename = System.IO.Path.Combine(path, "TelldusSetup.exe");
|
string filename = System.IO.Path.Combine(path, "TelldusCenter.exe");
|
||||||
proc.StartInfo.FileName = filename;
|
proc.StartInfo.FileName = filename;
|
||||||
proc.StartInfo.WorkingDirectory = path;
|
proc.StartInfo.WorkingDirectory = path;
|
||||||
proc.Start();
|
proc.Start();
|
||||||
|
|
|
@ -345,7 +345,7 @@
|
||||||
<value>Name</value>
|
<value>Name</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="columnHeader3.Text" xml:space="preserve">
|
<data name="columnHeader3.Text" xml:space="preserve">
|
||||||
<value>Manufacturer</value>
|
<value>Protocol</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="cmdTurnOn.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="cmdTurnOn.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
|
|
|
@ -3713,7 +3713,7 @@
|
||||||
<value>47, 20</value>
|
<value>47, 20</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="columnHeader3.Text" xml:space="preserve">
|
<data name="columnHeader3.Text" xml:space="preserve">
|
||||||
<value>Tillverkare</value>
|
<value>Protokoll</value>
|
||||||
</data>
|
</data>
|
||||||
<data name=">>label5.ZOrder" xml:space="preserve">
|
<data name=">>label5.ZOrder" xml:space="preserve">
|
||||||
<value>1</value>
|
<value>1</value>
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Telldus Technologies")]
|
[assembly: AssemblyCompany("Telldus Technologies")]
|
||||||
[assembly: AssemblyProduct("DeviceSchedulerAgent")]
|
[assembly: AssemblyProduct("DeviceSchedulerAgent")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Telldus Technologies 2007")]
|
[assembly: AssemblyCopyright("Copyright © Telldus Technologies 2009")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||||
// Build Number
|
// Build Number
|
||||||
// Revision
|
// Revision
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("2007.1.1.2")]
|
[assembly: AssemblyVersion("2009.2.0.0")]
|
||||||
[assembly: AssemblyFileVersion("2007.1.1.2")]
|
[assembly: AssemblyFileVersion("2009.2.0.0")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue