Skip to content

Commit

Permalink
Almost completed main ZWaveLib rework.
Browse files Browse the repository at this point in the history
Some concerns about the MultiInstance class, this should be tested.
Also MIG ZWave interface "Toggle" command is to be fixed.
  • Loading branch information
genemars committed Feb 15, 2015
1 parent ed6437d commit e6feea7
Show file tree
Hide file tree
Showing 46 changed files with 791 additions and 2,000 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
Thumbs.db
HomeGenie/bin/
MigFiles (copia)/
MigFiles/MIG/bin/
MigFiles/SupportLibraries/NetClientLib/bin/
MigFiles/SupportLibraries/SerialPortLib/bin/
MigFiles/SupportLibraries/W800RF32/bin/
MigFiles/SupportLibraries/XTenLib/bin/
MigFiles/SupportLibraries/ZWaveLib/bin/
2 changes: 1 addition & 1 deletion HomeGenie_Linux/HomeGenie_Linux.sln
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ Global
$19.scope = application/x-sharedlib
$0.StandardHeader = $20
$20.Text = @/*\n This file is part of HomeGenie Project source code.\n\n HomeGenie is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n HomeGenie is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with HomeGenie. If not, see <http://www.gnu.org/licenses/>. \n*/\n\n/*\n * Author: Generoso Martello <gene@homegenie.it>\n * Project Homepage: http://homegenie.it\n */\n\n
$20.IncludeInNewFiles = True
$20.IncludeInNewFiles = False
$0.NameConventionPolicy = $21
$21.Rules = $22
$22.NamingRule = $23
Expand Down
29 changes: 2 additions & 27 deletions HomeGenie_Linux/HomeGenie_Linux.userprefs
Original file line number Diff line number Diff line change
@@ -1,34 +1,9 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="../MigFiles/SupportLibraries/ZWaveLib/Handlers/Association.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="../HISTORY.TXT">
<Files>
<File FileName="../HISTORY.TXT" Line="1" Column="1" />
<File FileName="../README.TXT" Line="1" Column="1" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Devices/ZWaveNode.cs" Line="176" Column="21" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Devices/CommandClass.cs" Line="203" Column="9" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Devices/ProductHandlers/Generic/Switch.cs" Line="139" Column="63" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Devices/ProductHandlers/Generic/Dimmer.cs" Line="1" Column="1" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Devices/ProductHandlers/Generic/Sensor.cs" Line="108" Column="48" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Handlers/Basic.cs" Line="40" Column="1" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Handlers/SwitchBinary.cs" Line="34" Column="106" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Handlers/SwitchMultilevel.cs" Line="38" Column="1" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Handlers/Alarm.cs" Line="38" Column="17" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Handlers/SensorBinary.cs" Line="38" Column="1" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Handlers/SensorAlarm.cs" Line="40" Column="1" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Devices/ProductHandlers/Aeon/MultiSensor.cs" Line="51" Column="48" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Devices/ProductHandlers/Fibaro/MotionSensor.cs" Line="1" Column="1" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Handlers/SensorMultilevel.cs" Line="49" Column="1" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Handlers/SceneActivation.cs" Line="39" Column="1" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Devices/ProductHandlers/Generic/Thermostat.cs" Line="32" Column="72" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Handlers/Thermostat.cs" Line="201" Column="1" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Devices/ProductHandlers/Zwave.Me/ZWaveMeThermostat.cs" Line="30" Column="89" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Devices/ProductHandlers/Generic/Meter.cs" Line="29" Column="52" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Handlers/Meter.cs" Line="39" Column="1" />
<File FileName="../MigFiles/MIG/Interfaces/HomeAutomation/ZWave.cs" Line="511" Column="124" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Devices/Controller.cs" Line="732" Column="3" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Handlers/Configuration.cs" Line="60" Column="1" />
<File FileName="../HomeGenie/Program.cs" Line="139" Column="1" />
<File FileName="../MigFiles/SupportLibraries/ZWaveLib/Handlers/Association.cs" Line="87" Column="23" />
<File FileName="../README.TXT" Line="2" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
Expand Down
59 changes: 27 additions & 32 deletions MigFiles/MIG/Interfaces/HomeAutomation/ZWave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ You should have received a copy of the GNU General Public License
using LibUsbDotNet.Main;

using ZWaveLib;
using ZWaveLib.Devices;

//using System.Management;
using ZWaveLib.Devices.ProductHandlers.Generic;

using MIG.Interfaces.HomeAutomation.Commons;
using ZWaveLib.Handlers;
Expand Down Expand Up @@ -402,16 +398,16 @@ public object InterfaceControl(MIGInterfaceCommand request)
switch (request.GetOption(0))
{
case "Switch.Binary":
node.MultiInstance_GetCount((byte)ZWaveLib.CommandClass.SwitchBinary);
MultiInstance.GetCount(node, (byte)ZWaveLib.CommandClass.SwitchBinary);
break;
case "Switch.MultiLevel":
node.MultiInstance_GetCount((byte)ZWaveLib.CommandClass.SwitchMultilevel);
MultiInstance.GetCount(node, (byte)ZWaveLib.CommandClass.SwitchMultilevel);
break;
case "Sensor.Binary":
node.MultiInstance_GetCount((byte)ZWaveLib.CommandClass.SensorBinary);
MultiInstance.GetCount(node, (byte)ZWaveLib.CommandClass.SensorBinary);
break;
case "Sensor.MultiLevel":
node.MultiInstance_GetCount((byte)ZWaveLib.CommandClass.SensorMultilevel);
MultiInstance.GetCount(node, (byte)ZWaveLib.CommandClass.SensorMultilevel);
break;
}
}
Expand All @@ -423,16 +419,16 @@ public object InterfaceControl(MIGInterfaceCommand request)
switch (request.GetOption(0))
{
case "Switch.Binary":
node.MultiInstance_SwitchBinaryGet(instance);
MultiInstance.SwitchBinaryGet(node, instance);
break;
case "Switch.MultiLevel":
node.MultiInstance_SwitchMultiLevelGet(instance);
MultiInstance.SwitchMultiLevelGet(node, instance);
break;
case "Sensor.Binary":
node.MultiInstance_SensorBinaryGet(instance);
MultiInstance.SensorBinaryGet(node, instance);
break;
case "Sensor.MultiLevel":
node.MultiInstance_SensorMultiLevelGet(instance);
MultiInstance.SensorMultiLevelGet(node, instance);
break;
}
}
Expand All @@ -448,11 +444,11 @@ public object InterfaceControl(MIGInterfaceCommand request)
switch (request.GetOption(0))
{
case "Switch.Binary":
node.MultiInstance_SwitchBinarySet(instance, value);
MultiInstance.SwitchBinarySet(node, instance, value);
//raiseparam = (double.Parse(request.GetOption(2)) / 255).ToString();
break;
case "Switch.MultiLevel":
node.MultiInstance_SwitchMultiLevelSet(instance, value);
MultiInstance.SwitchMultiLevelSet(node, instance, value);
//raiseparam = (double.Parse(request.GetOption(2)) / 100).ToString(); // TODO: should it be 99 ?
break;
}
Expand Down Expand Up @@ -492,7 +488,7 @@ public object InterfaceControl(MIGInterfaceCommand request)
else if (command == Command.BATTERY_GET)
{
var node = controller.GetDevice((byte)int.Parse(nodeId));
node.Battery_Get();
Battery.Get(node);
}
////-----------------------
else if (command == Command.ASSOCIATION_SET)
Expand All @@ -514,7 +510,7 @@ public object InterfaceControl(MIGInterfaceCommand request)
else if (command == Command.MANUFACTURERSPECIFIC_GET)
{
var node = controller.GetDevice((byte)int.Parse(nodeId));
node.ManufacturerSpecific_Get();
ManufacturerSpecific.Get(node);
}
////------------------
else if (command == Command.CONFIG_PARAMETERSET)
Expand All @@ -533,46 +529,42 @@ public object InterfaceControl(MIGInterfaceCommand request)
else if (command == Command.WAKEUP_GET)
{
var node = controller.GetDevice((byte)int.Parse(nodeId));
node.WakeUp_Get();
WakeUp.Get(node);
}
else if (command == Command.WAKEUP_SET)
{
var node = controller.GetDevice((byte)int.Parse(nodeId));
node.WakeUp_Set(uint.Parse(request.GetOption(0)));
WakeUp.Set(node, uint.Parse(request.GetOption(0)));
}
////------------------
else if (command == Command.CONTROL_ON)
{
raisePropertyChanged = true;
raiseParameter = "1";
//
// Basic.Set 0xFF
var node = controller.GetDevice((byte)int.Parse(nodeId));
((Switch)node.DeviceHandler).On();
Basic.Set(node, 0XFF);
}
else if (command == Command.CONTROL_OFF)
{
raisePropertyChanged = true;
raiseParameter = "0";
//
// Basic.Set 0x00
var node = controller.GetDevice((byte)int.Parse(nodeId));
((Switch)node.DeviceHandler).Off();
Basic.Set(node, 0x00);
}
else if (command == Command.CONTROL_LEVEL)
{
raisePropertyChanged = true;
raiseParameter = (double.Parse(request.GetOption(0)) / 100).ToString();
//
// Basic.Set <level>
raiseParameter = Math.Round(double.Parse(request.GetOption(0)) / 100D, 2).ToString(CultureInfo.InvariantCulture);
var node = controller.GetDevice((byte)int.Parse(nodeId));
((Dimmer)node.DeviceHandler).Level = int.Parse(request.GetOption(0));
var level = (Math.Round(double.Parse(request.GetOption(0)) / 100D * 99D, 2));
Basic.Set(node, (int)level);
}
else if (command == Command.CONTROL_TOGGLE)
{
raisePropertyChanged = true;
//
var node = controller.GetDevice((byte)int.Parse(nodeId));
// TODO: should use GetData to store last known level?!?!
/*
if (((Switch)node.DeviceHandler).Level == 0)
{
raiseParameter = "1";
Expand All @@ -585,6 +577,7 @@ public object InterfaceControl(MIGInterfaceCommand request)
// Basic.Set 0x00
((Switch)node.DeviceHandler).Off();
}
*/
}
else if (command == Command.THERMOSTAT_MODEGET)
{
Expand Down Expand Up @@ -989,7 +982,7 @@ private void controller_UpdateNodeParameter(object sender, UpdateNodeParameterEv
path = ModuleParameters.MODPAR_SENSOR_ALARM_FLOOD;
break;
case ParameterEvent.ManufacturerSpecific:
ManufacturerSpecific mf = (ManufacturerSpecific)value;
ManufacturerSpecificInfo mf = (ManufacturerSpecificInfo)value;
path = "ZWaveNode.ManufacturerSpecific";
value = mf.ManufacturerId + ":" + mf.TypeId + ":" + mf.ProductId;
break;
Expand Down Expand Up @@ -1130,6 +1123,7 @@ private void RaisePropertyChanged(InterfacePropertyChangedAction ifaceaction)
}
}

/*
private void UpdateZWaveNodeDeviceHandler(int nodeId)
{
var node = controller.Devices.Find(zn => zn.NodeId == nodeId);
Expand All @@ -1141,10 +1135,11 @@ private void UpdateZWaveNodeDeviceHandler(int nodeId)
Value = node.DeviceHandler.GetType().FullName
});
}

*/
// TODO: deprecate this... in the ZWaveLib.Controller class as well
private void controller_ManufacturerSpecificResponse(object sender, ManufacturerSpecificResponseEventArg args)
{
UpdateZWaveNodeDeviceHandler(args.NodeId);
//UpdateZWaveNodeDeviceHandler(args.NodeId);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ You should have received a copy of the GNU General Public License
*/

using System;
using ZWaveLib.Devices;

namespace ZWaveLib
{
Expand Down
Loading

0 comments on commit e6feea7

Please sign in to comment.