Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

Commit

Permalink
Merge pull request #225 from Hyrules/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Hyrules authored Mar 26, 2019
2 parents cd5fd62 + 26b8acb commit 7daeda7
Show file tree
Hide file tree
Showing 336 changed files with 57,569 additions and 26,739 deletions.
22 changes: 20 additions & 2 deletions HueLib2Test/HueLib2Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</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>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto, Version=1.8.4.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
<HintPath>..\packages\BouncyCastle.1.8.4\lib\BouncyCastle.Crypto.dll</HintPath>
Expand All @@ -46,8 +64,8 @@
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Sprache, Version=2.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Sprache.2.2.0\lib\net45\Sprache.dll</HintPath>
<Reference Include="Sprache, Version=2.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Sprache.2.2.1-develop-00025\lib\net45\Sprache.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Windows.Interactivity">
Expand Down
2 changes: 1 addition & 1 deletion HueLib2Test/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.388.0")]
[assembly: AssemblyVersion("1.0.628.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
68 changes: 30 additions & 38 deletions HueLib2Test/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Net;
using System.Net.Security;
Expand All @@ -25,6 +27,8 @@
using Org.BouncyCastle.Utilities;
using WinHue3.Philips_Hue.BridgeObject.Entertainment_API;
using WinHue3.Functions.Animations2;
using WinHue3.Functions.Converters;
using WinHue3.Functions.Rules;

namespace HueLib2Test
{
Expand All @@ -34,11 +38,30 @@ public class UnitTest1
[TestMethod]
public void TestParser()
{
// var result = WinHueAnimationParser.ParseAnimation("SET LIGHT 1 TO BRI:232 SAT:254;");
// Assert.AreEqual(new Light() { Id = "1", state = new State() { bri = 254, sat = 254 }}, result);
// var result = WinHueAnimationParser.ParseAnimation("SET LIGHT 1 TO BRI:232 SAT:254;");
// Assert.AreEqual(new Light() { Id = "1", state = new State() { bri = 254, sat = 254 }}, result);
/*Light l = new Light();
l.Id = 5.ToString();
l.swversion = "12.2334.5";*/
Sensor s = new Sensor();
s.manufacturername = "test";

//string res = JsonConvert.SerializeObject(l, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
string res = Serializer.ModifyJsonObject(s);
//PropertyInfo[] pi = l.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);


}

[TestMethod]
public void TimeSpanTest()
{
TimeSpanToUShortConverter tsc = new TimeSpanToUShortConverter();
TimeSpan ts = (TimeSpan)tsc.Convert((ushort)65535, typeof(TimeSpan),null, CultureInfo.InvariantCulture);
Assert.IsTrue(ts.TotalMilliseconds == 6553500);
ushort us = (ushort) tsc.ConvertBack(new TimeSpan(0, 1, 49, 13, 500), typeof(ushort), null, CultureInfo.InvariantCulture);
Assert.IsTrue(us == 65535);
}


[TestMethod]
Expand All @@ -63,13 +86,13 @@ public void TestRegex()
{
Regex timerRegex = new Regex(@"(R(\d\d)//?)?PT(\d\d:\d\d:\d\d)A?(\d\d:\d\d:\d\d)?");
Match mc = timerRegex.Match("PT00:12:34");

Assert.IsTrue(mc.Length >= 1);
Regex alarmRegex = new Regex(@"(W(\d\d\d)//?)?T(\d\d:\d\d:\d\d)(A(\d\d:\d\d:\d\d))?");
Match mc2 = alarmRegex.Match("W064/T11:22:33");

Assert.IsTrue(mc2.Length >= 1);
Regex scheduleRegex = new Regex(@"(\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d)A?(\d\d:\d\d:\d\d)?");
Match mc3 = scheduleRegex.Match("2013-12-31T00:11:33:55");

Assert.IsTrue(mc3.Length >= 1);
}

[TestMethod]
Expand All @@ -89,12 +112,6 @@ public void TestDTLS()
HueDatagramTransport hdgt = new HueDatagramTransport(socket);
DtlsTransport tr = dtlsClientProtocol.Connect(hdtls, hdgt);







}

public static byte[] HexStringToByteArray(string hex) {
Expand Down Expand Up @@ -152,7 +169,7 @@ public void TestDeserializer()
DataStore ds = JsonConvert.DeserializeObject<DataStore>(test3);
TreeViewItem tvi = TreeViewHelper.BuildPropertiesTreeFromDataStore(ds);

HueObject ho = new HueObject();
//HueObject ho = new HueObject();



Expand Down Expand Up @@ -207,34 +224,9 @@ public void TestSensors()
[TestMethod]
public void TestBuildTree()
{



var tree =TreeViewHelper.BuildPropertiesTree(new Light() {state = new State()}, "/");

//BridgeSettings bs = new BridgeSettings();
// Light l = new Light();
BridgeSettings bs = new BridgeSettings();
// SwUpdate sw = new SwUpdate();
// IHueObject obj = new Light();
// Sensor ts = new Sensor(){config = new ClipGenericFlagSensorConfig(), state = new ClipGenericFlagSensorState()};
// PropertyInfo[] props = bs.GetType().GetHueProperties();
//BuildTree(l.GetType(), "/lights/1", "");

string ssensor =
"{\n \"state\": {\n \"daylight\": true,\n \"lastupdated\": \"2017-08-09T09:56:00\"\n },\n \"config\": {\n \"on\": true,\n \"configured\": true,\n \"sunriseoffset\": 0,\n \"sunsetoffset\": 0\n },\n \"name\": \"Daylight\",\n \"type\": \"Daylight\",\n \"modelid\": \"PHDL00\",\n \"manufacturername\": \"Philips\",\n \"swversion\": \"1.0\"\n}";
Sensor obj = Serializer.DeserializeToObject<Sensor>(ssensor);
PropertyInfo[] props = obj.GetType().GetHueProperties();
ISensorConfigBase cfg = (ISensorConfigBase)props[8].GetValue(obj);
// ISensorConfigBase cfg = props["config"].GetValue(obj);
//string path = "/sensors";
List<TreeViewItem> lrtvi = new List<TreeViewItem>();

foreach (PropertyInfo pi in props)
{
// lrtvi.Add(BuildTree(pi, path, null));


}

}

Expand Down
2 changes: 1 addition & 1 deletion HueLib2Test/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<packages>
<package id="BouncyCastle" version="1.8.4" targetFramework="net452" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net452" />
<package id="Sprache" version="2.2.0" targetFramework="net452" />
<package id="Sprache" version="2.2.1-develop-00025" targetFramework="net452" />
</packages>
11 changes: 5 additions & 6 deletions WinHue3/Addons/CpuTempMon/CpuTempViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Windows.Input;
using OpenHardwareMonitor.Hardware;
using WinHue3.Functions.BridgeManager;
using WinHue3.Philips_Hue.BridgeObject;
using WinHue3.Philips_Hue.HueObjects.Common;
using WinHue3.Philips_Hue.HueObjects.GroupObject;
Expand All @@ -19,7 +20,6 @@ public class CpuTempViewModel : ValidatableBindableBase
private int _UpperTemp;
private int _lowerGradientColor;
private int _upperGradientColor;
private Bridge _bridge;
private CpuTemp _temp;
public bool _canTest;
public string _cpuTemp;
Expand All @@ -44,15 +44,14 @@ public CpuTempViewModel()
_listCpuSensors = new ObservableCollection<ISensor>();
}

public void Initialize(Bridge bridge, CpuTemp temp)
public void Initialize(CpuTemp temp)
{
_bridge = bridge;
_temp = temp;
_temp.OnTempUpdated += _temp_OnTempUpdated;
_temp.OnSensorUpdated += _temp_OnSensorUpdated;
_temp.Start();

List<IHueObject> hr = HueObjectHelper.GetBridgeDataStore(_bridge);
List<IHueObject> hr = BridgeManager.Instance.SelectedBridge.GetAllObjects();

if (hr == null) return;
ListLightGroups.AddRange(hr.Where(x => x is Light));
Expand Down Expand Up @@ -106,11 +105,11 @@ private void _temp_OnTempUpdated(object sender, CpuTempEventArgs e)

if (SelectedObject is Light)
{
_bridge.SetState(new State() { hue = hueTemp, bri = Bri, sat = Sat, @on = true, transitiontime = 9 }, _selectedObject.Id);
BridgeManager.Instance.SelectedBridge.SetState(new State() { hue = hueTemp, bri = Bri, sat = Sat, @on = true, transitiontime = 9 }, _selectedObject.Id);
}
else
{
_bridge.SetState(new Philips_Hue.HueObjects.GroupObject.Action() { hue = hueTemp, bri = Bri, sat = Sat, @on = true, transitiontime = 9 }, _selectedObject.Id);
BridgeManager.Instance.SelectedBridge.SetState(new Philips_Hue.HueObjects.GroupObject.Action() { hue = hueTemp, bri = Bri, sat = Sat, @on = true, transitiontime = 9 }, _selectedObject.Id);
}


Expand Down
2 changes: 1 addition & 1 deletion WinHue3/Addons/CpuTempMon/SettingsForm.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Form_CpuTempMonitorSettings(CpuTemp temp,Bridge bridge)
{
InitializeComponent();
_cpuvm = DataContext as CpuTempViewModel;
_cpuvm.Initialize(bridge, temp);
_cpuvm.Initialize(temp);

}

Expand Down
34 changes: 17 additions & 17 deletions WinHue3/App.config
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="WinHue3.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="WinHue3.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xceed.Wpf.Toolkit" publicKeyToken="3e4669d2f30244f4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
<assemblyIdentity name="Xceed.Wpf.Toolkit" publicKeyToken="3e4669d2f30244f4" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Xceed.Wpf.AvalonDock" publicKeyToken="3e4669d2f30244f4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.0.0" newVersion="2.6.0.0" />
<assemblyIdentity name="Xceed.Wpf.AvalonDock" publicKeyToken="3e4669d2f30244f4" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.6.0.0" newVersion="2.6.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
<assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
<assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.8.2.0" newVersion="1.8.2.0" />
<assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.8.2.0" newVersion="1.8.2.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand All @@ -51,7 +51,7 @@
<value>75</value>
</setting>
<setting name="CPUTemp_ObjectID" serializeAs="String">
<value />
<value/>
</setting>
<setting name="CPUTemp_ObjectType" serializeAs="String">
<value>False</value>
Expand All @@ -66,7 +66,7 @@
<value>5</value>
</setting>
<setting name="CPUTemp_SensorName" serializeAs="String">
<value />
<value/>
</setting>
<setting name="CPUTemp_gradientStartColor" serializeAs="String">
<value>0</value>
Expand Down
Loading

0 comments on commit 7daeda7

Please sign in to comment.