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
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
private static extern bool devTurnOn(int value);
|
||||
[DllImport("TelldusCore.dll")]
|
||||
private static extern bool tdTurnOn(int value);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
private static extern bool devTurnOff(int value);
|
||||
[DllImport("TelldusCore.dll")]
|
||||
private static extern bool tdTurnOff(int value);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
private static extern int devGetDeviceId(int value);
|
||||
[DllImport("TelldusCore.dll")]
|
||||
private static extern bool tdBell(int value);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
private static extern string devGetName(int value);
|
||||
[DllImport("TelldusCore.dll")]
|
||||
private static extern int tdGetDeviceId(int value);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
private static extern string devGetVendor(int value);
|
||||
[DllImport("TelldusCore.dll")]
|
||||
private static extern string tdGetName(int value);
|
||||
|
||||
[DllImport("TellUsbD101.dll")]
|
||||
private static extern int devGetNumberOfDevices();
|
||||
[DllImport("TelldusCore.dll")]
|
||||
private static extern string tdGetProtocol(int value);
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
private static extern int tdGetNumberOfDevices();
|
||||
|
||||
[DllImport("TelldusCore.dll")]
|
||||
private static extern int tdClose();
|
||||
#endregion
|
||||
|
||||
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>
|
||||
public bool TurnOff(Device item)
|
||||
{
|
||||
return devTurnOff(item.ID);
|
||||
return tdTurnOff(item.ID);
|
||||
}
|
||||
|
||||
public bool TurnOffWithDelay(Device item)
|
||||
{
|
||||
bool result = devTurnOff(item.ID);
|
||||
bool result = tdTurnOff(item.ID);
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
return result;
|
||||
}
|
||||
|
@ -67,14 +73,33 @@ namespace DeviceHandler
|
|||
/// <returns>True if the command was successfull.</returns>
|
||||
public bool TurnOn(Device item)
|
||||
{
|
||||
return devTurnOn(item.ID);
|
||||
return tdTurnOn(item.ID);
|
||||
}
|
||||
|
||||
|
||||
public bool TurnOnWithDelay(Device item)
|
||||
{
|
||||
//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);
|
||||
return result;
|
||||
}
|
||||
|
@ -89,15 +114,15 @@ namespace DeviceHandler
|
|||
{
|
||||
m_Devices.Clear();
|
||||
|
||||
int count = devGetNumberOfDevices() - 1;
|
||||
int count = tdGetNumberOfDevices() - 1;
|
||||
for (int i = 0; i <= count; i++)
|
||||
{
|
||||
//Collect information from the driver.
|
||||
int deviceID = devGetDeviceId(i);
|
||||
string deviceName = devGetName(deviceID);
|
||||
string deviceVendor = devGetVendor(deviceID);
|
||||
int deviceID = tdGetDeviceId(i);
|
||||
string deviceName = tdGetName(deviceID);
|
||||
string deviceProtocol = tdGetProtocol(deviceID);
|
||||
|
||||
m_Devices.Add(new Device(deviceID, deviceName, deviceVendor));
|
||||
m_Devices.Add(new Device(deviceID, deviceName, deviceProtocol));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -127,18 +152,18 @@ namespace DeviceHandler
|
|||
{
|
||||
private int m_ID = -1;
|
||||
private string m_Name = "";
|
||||
private string m_Vendor = "";
|
||||
private string m_Protocol = "";
|
||||
|
||||
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_Name = name;
|
||||
m_Vendor = vendor;
|
||||
m_Protocol = protocol;
|
||||
}
|
||||
|
||||
public int ID
|
||||
|
@ -153,10 +178,10 @@ namespace DeviceHandler
|
|||
set { m_Name = value; }
|
||||
}
|
||||
|
||||
public string Vendor
|
||||
public string Protocol
|
||||
{
|
||||
get { return m_Vendor; }
|
||||
set { m_Vendor = value; }
|
||||
get { return m_Protocol; }
|
||||
set { m_Protocol = value; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Telldus Technologies")]
|
||||
[assembly: AssemblyProduct("DeviceHandler")]
|
||||
[assembly: AssemblyCopyright("Copyright © Telldus Technologies 2007")]
|
||||
[assembly: AssemblyCopyright("Copyright © Telldus Technologies 2009")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[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
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("2007.1.1.2")]
|
||||
[assembly: AssemblyFileVersion("2007.1.1.2")]
|
||||
[assembly: AssemblyVersion("2009.2.0.0")]
|
||||
[assembly: AssemblyFileVersion("2009.2.0.0")]
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<TargetFrameworkSubset>
|
||||
</TargetFrameworkSubset>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
|
@ -28,11 +31,8 @@
|
|||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkSubset>
|
||||
</TargetFrameworkSubset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Telldus Technologies")]
|
||||
[assembly: AssemblyProduct("DeviceScheduler")]
|
||||
[assembly: AssemblyCopyright("Copyright © Telldus Technologies 2007")]
|
||||
[assembly: AssemblyCopyright("Copyright © Telldus Technologies 2009")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2007.1.1.2")]
|
||||
[assembly: AssemblyFileVersion("2007.1.1.2")]
|
||||
[assembly: AssemblyVersion("2009.2.0.0")]
|
||||
[assembly: AssemblyFileVersion("2009.2.0.0")]
|
||||
|
|
|
@ -158,7 +158,7 @@ namespace DeviceScheduler
|
|||
{
|
||||
ListViewItem item = lvwCommon.Items.Add(dev.Name,2);
|
||||
item.SubItems.Add(dev.ID.ToString());
|
||||
item.SubItems.Add(dev.Vendor);
|
||||
item.SubItems.Add(dev.Protocol);
|
||||
item.Tag = dev;
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ namespace DeviceScheduler
|
|||
Cursor = Cursors.WaitCursor;
|
||||
|
||||
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.WorkingDirectory = path;
|
||||
proc.Start();
|
||||
|
|
|
@ -345,7 +345,7 @@
|
|||
<value>Name</value>
|
||||
</data>
|
||||
<data name="columnHeader3.Text" xml:space="preserve">
|
||||
<value>Manufacturer</value>
|
||||
<value>Protocol</value>
|
||||
</data>
|
||||
<data name="cmdTurnOn.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
|
|
|
@ -3713,7 +3713,7 @@
|
|||
<value>47, 20</value>
|
||||
</data>
|
||||
<data name="columnHeader3.Text" xml:space="preserve">
|
||||
<value>Tillverkare</value>
|
||||
<value>Protokoll</value>
|
||||
</data>
|
||||
<data name=">>label5.ZOrder" xml:space="preserve">
|
||||
<value>1</value>
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Telldus Technologies")]
|
||||
[assembly: AssemblyProduct("DeviceSchedulerAgent")]
|
||||
[assembly: AssemblyCopyright("Copyright © Telldus Technologies 2007")]
|
||||
[assembly: AssemblyCopyright("Copyright © Telldus Technologies 2009")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
|||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2007.1.1.2")]
|
||||
[assembly: AssemblyFileVersion("2007.1.1.2")]
|
||||
[assembly: AssemblyVersion("2009.2.0.0")]
|
||||
[assembly: AssemblyFileVersion("2009.2.0.0")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue