Move project TellStick.NET into 3rdparty

This commit is contained in:
Micke Prag 2011-11-11 12:01:41 +01:00
parent 3cbb48aa6b
commit 00cb9d9057
3 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TellStick.NET")]
[assembly: AssemblyDescription("A managed .NET wrapper class library for the TellStick native DLL")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Eyedealistic / Levén Labs (http://labs.leven.se)")]
[assembly: AssemblyProduct("TellStick.NET")]
[assembly: AssemblyCopyright("Created by Mikael Levén in 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("24411992-c766-4eb8-b7ac-c002f0d7d5ad")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.1.0.*")]
[assembly: AssemblyFileVersion("0.1.0.0")]

View file

@ -0,0 +1,102 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{700E41E9-ADB6-4D5A-B9EB-B6560C1C0D3F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TellStick</RootNamespace>
<AssemblyName>TellStick.NET</AssemblyName>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoStdLib>false</NoStdLib>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleAssemblies>C:\Program Files (x86)\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>none</DebugType>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleAssemblies>C:\Program Files (x86)\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<DocumentationFile>bin\x86\Release\TellStick.NET.XML</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisRuleAssemblies>C:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>none</DebugType>
<PlatformTarget>x64</PlatformTarget>
<CodeAnalysisRuleAssemblies>C:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\\rules</CodeAnalysisRuleAssemblies>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
<DocumentationFile>bin\x64\Release\TellStick.NET.XML</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="TellStick.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

318
3rdparty/tellstick.net/TellStick.cs vendored Normal file
View file

@ -0,0 +1,318 @@
/* -------------------------------------------------------------------------------
* TellStick.NET
* -------------------------------------------------------------------------------
* Created by Mikael Levén (http://labs.leven.se)
*
* This piece of code is licensed as open source and can be freely used and
* redistributed in any type of project, both commercial and non-commercial,
* as long as this licensing policy is not altered. This means that any alterations
* of this code must also be licensed as open source and therefore cannot be
* protected or patented in any way. However, any software based on this code may
* still be copyrighted (and/or patented) and sold as propritary software as long as
* this code (and any alterations of it) can be freely used and modified by others.
*
* Altough the code is licensed as open source you don't need to republish any
* changes made back to the community (it will be much appreciated tough).
*
* The code comes without any kind of warrantys and the author cannot be held
* responsible for any kind of damage this software may (or may not) cause, no matter
* if it's direct or indirect damage.
*
* Please note:
* All TellStick core functionality is developed by Telldus Technologies
* and as of now (2007-12-14) that code is also licensed as open source. This may
* however change in the future and I suggest that you check there website
* to make sure the licensing terms are still the same: http://www.telldus.se/
* The documentation and example code for Tellstic is available at their Wiki:
* http://www.telldus.se/wiki/
*
* -------------------------------------------------------------------------------
* Description:
* TellStick.NET is a Microsoft .NET wrapper for the native TellStick DLL.
* The wrapper also adds some functionality to make it easier to work with
* TellStick devices.
*
* Author: Mikael Levén
* Created: 2007-12-14
*
* Dependencies:
* This library depends on the native DLL for TellStick. To be able to actually
* switch lights on and off you also need the driver to be installed as well
* as an TellStick USB device.
*
* Revisions:
-------------------------------------------------------------------------------
*/
using System.Collections.Generic;
using System.Runtime.InteropServices;
/// <summary>
/// TellStick.NET is a Microsoft .NET wrapper for the native TellStick DLL.
/// The wrapper also adds some functionality to make it easier to work with TellStick devices.
/// </summary>
public sealed class TellStick
{
private TellStick()
{ }
#region TellStick native DLL imports class
public sealed class Native
{
private Native()
{ }
[DllImport("TellUsbD101.dll")]
public static extern int devAddDevice();
[DllImport("TellUsbD101.dll")]
public static extern bool devTurnOn(int intDeviceId);
[DllImport("TellUsbD101.dll")]
public static extern bool devTurnOff(int intDeviceId);
[DllImport("TellUsbD101.dll")]
public static extern int devGetNumberOfDevices();
[DllImport("TellUsbD101.dll")]
public static extern string devGetName(int intDeviceId);
[DllImport("TellUsbD101.dll")]
public static extern bool devSetName(int intDeviceId, string chNewName);
[DllImport("TellUsbD101.dll")]
public static extern string devGetVendor(int intDeviceId);
[DllImport("TellUsbD101.dll")]
public static extern bool devSetVendor(int intDeviceId, string chNewName);
[DllImport("TellUsbD101.dll")]
public static extern string devGetModel(int intDeviceId);
[DllImport("TellUsbD101.dll")]
public static extern bool devSetModel(int intDeviceId, string chNewName);
[DllImport("TellUsbD101.dll")]
public static extern int[] devGetArguments(int intDeviceId);
[DllImport("TellUsbD101.dll")]
public static extern bool devSetArguments(int intDeviceId, int[] intArguments, int intNumberOfArguments);
[DllImport("TellUsbD101.dll")]
public static extern int devAddDeviceWithArguments(string strVendor, int[] intArguments, int intNumberOfArguments);
[DllImport("TellUsbD101.dll")]
public static extern bool devRemoveDevice(int intDeviceId);
[DllImport("TellUsbD101.dll")]
public static extern int devGetDeviceId(int intDeviceIndex);
}
#endregion
/// <summary>
/// Gets the number of devices registered
/// </summary>
/// <returns>Returns the number of devices as an integer</returns>
/// <remarks>The native DLL is required for this methods to run. If it's missing a ModuleNotFoundException exception will be thrown.</remarks>
public static int GetNumberOfDevices()
{
try
{
return Native.devGetNumberOfDevices();
}
catch (System.DllNotFoundException ex)
{
throw new ModuleNotFoundException("Could not find TellStick software. Please make sure it's installed before you run this application!", ex);
}
catch (System.Exception)
{
throw;
}
}
/// <summary>
/// Gets the unique idetifier of the device
/// </summary>
/// <param name="deviceIndex">Index number of the device to get ID for</param>
/// <returns>Returns the unique identifier as an integer</returns>
/// <remarks>The native DLL is required for this methods to run. If it's missing a ModuleNotFoundException exception will be thrown.</remarks>
public static int GetDeviceId(int deviceIndex)
{
// Retrieve and return the device unqiue identifier from the native method
try
{
return Native.devGetDeviceId(deviceIndex);
}
catch (System.DllNotFoundException ex)
{
throw new ModuleNotFoundException("Could not find TellStick software. Please make sure it's installed before you run this application!", ex);
}
catch (System.Exception)
{
throw;
}
}
/// <summary>
/// Gets the user defined name of the device
/// </summary>
/// <param name="deviceId">Device unqiue identification</param>
/// <returns>Returns the user defined device name as a string</returns>
/// <remarks>The native DLL is required for this methods to run. If it's missing a ModuleNotFoundException exception will be thrown.</remarks>
public static string GetName(int deviceId)
{
// Retrieve and return the device name from the native method
try
{
return Native.devGetName(deviceId);
}
catch (System.DllNotFoundException ex)
{
throw new ModuleNotFoundException("Could not find TellStick software. Please make sure it's installed before you run this application!", ex);
}
catch (System.Exception)
{
throw;
}
}
/// <summary>
/// Turns on the selected device
/// </summary>
/// <param name="deviceId">Device unqiue identification</param>
/// <returns>Returns true if the device was succesfully turned on</returns>
/// <remarks>The native DLL is required for this methods to run. If it's missing a ModuleNotFoundException exception will be thrown.</remarks>
public static bool TurnOn(int deviceId)
{
// Send "on" signal
try
{
return Native.devTurnOn(deviceId);
}
catch (System.DllNotFoundException ex)
{
throw new ModuleNotFoundException("Could not find TellStick software. Please make sure it's installed before you run this application!", ex);
}
catch (System.Exception)
{
throw;
}
}
/// <summary>
/// Turns off the selected device
/// </summary>
/// <param name="deviceId">Device unqiue identification</param>
/// <returns>Returns true if the device was succesfully turned off</returns>
/// <remarks>The native DLL is required for this methods to run. If it's missing a ModuleNotFoundException exception will be thrown.</remarks>
public static bool TurnOff(int deviceId)
{
// Send "off" signal
try
{
return Native.devTurnOff(deviceId);
}
catch (System.DllNotFoundException ex)
{
throw new ModuleNotFoundException("Could not find TellStick software. Please make sure it's installed before you run this application!", ex);
}
catch (System.Exception)
{
throw;
}
}
/// <summary>
/// Gets the vendors name
/// </summary>
/// <param name="deviceId"></param>
/// <returns></returns>
/// <remarks>The native DLL is required for this methods to run. If it's missing a ModuleNotFoundException exception will be thrown.</remarks>
public static string GetVendor(int deviceId)
{
// Retrieve and return the vendor from the native method
try
{
return Native.devGetVendor(deviceId);
}
catch (System.DllNotFoundException ex)
{
throw new ModuleNotFoundException("Could not find TellStick software. Please make sure it's installed before you run this application!", ex);
}
catch (System.Exception)
{
throw;
}
}
#region "Support classes"
public abstract class TellStickException : System.Exception
{
public TellStickException() : base()
{
}
public TellStickException(string message)
: base(message)
{
}
public TellStickException(string message, System.Exception innerException)
: base(message, innerException)
{
}
}
public class UnmanagedException : TellStickException
{
public UnmanagedException() : base()
{
}
public UnmanagedException(string message)
: base(message)
{
}
public UnmanagedException(string message, System.Exception innerException)
: base(message, innerException)
{
}
}
public class ModuleNotFoundException : TellStickException
{
public ModuleNotFoundException()
: base("Could not find TellStick software. Please make sure it's installed before you run this application!")
{
}
public ModuleNotFoundException(string message)
: base(message)
{
}
public ModuleNotFoundException(string message, System.Exception innerException)
: base(message, innerException)
{
}
}
#endregion
}