From: <Ba...@us...> - 2012-01-05 12:53:31
|
Revision: 4375 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4375&view=rev Author: BartEv Date: 2012-01-05 12:53:23 +0000 (Thu, 05 Jan 2012) Log Message: ----------- Added Paths: ----------- trunk/plugins/VeraControl/releases/ trunk/plugins/VeraControl/releases/VeraControl.xmp2 trunk/plugins/VeraControl/releases/VeraControl_v0.5.0.0.mpe1 trunk/plugins/VeraControl/releases/update.xml Added: trunk/plugins/VeraControl/releases/VeraControl.xmp2 =================================================================== --- trunk/plugins/VeraControl/releases/VeraControl.xmp2 (rev 0) +++ trunk/plugins/VeraControl/releases/VeraControl.xmp2 2012-01-05 12:53:23 UTC (rev 4375) @@ -0,0 +1,917 @@ +<?xml version="1.0" encoding="utf-8"?> +<PackageClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Version>2.0</Version> + <Groups> + <Items> + <GroupItem Name="Default"> + <ParentGroup /> + <DisplayName>Default</DisplayName> + <DefaulChecked>true</DefaulChecked> + <Description>Default</Description> + <Files> + <Items> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\bin\Debug\VeraControl.dll</LocalFileName> + <ZipFileName>Installer{CopyFile}\{7313a25a-e5a1-46e7-af14-613b3d1294df}-VeraControl.dll</ZipFileName> + <DestinationFilename>%Plugins%\Windows\VeraControl.dll</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Default\VeraControl.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{028d1570-2f3e-4ddb-9721-36f94cca1de5}-VeraControl.xml</ZipFileName> + <DestinationFilename>%Skin%\Default\VeraControl.xml</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Default\VeraDialogActionTrigger.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{09937fdb-eda7-4fb5-a0c6-b94788cacdb6}-VeraDialogActionTrigger.xml</ZipFileName> + <DestinationFilename>%Skin%\Default\VeraDialogActionTrigger.xml</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Default\VeraDialogDeviceControl.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{507aff1a-15af-493d-b9b4-40ef11cfc4cd}-VeraDialogDeviceControl.xml</ZipFileName> + <DestinationFilename>%Skin%\Default\VeraDialogDeviceControl.xml</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\DefaultWide\VeraControl.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{85789702-644a-4d04-b55c-8d1b76947ba4}-VeraControl.xml</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\VeraControl.xml</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\DefaultWide\VeraDialogActionTrigger.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{34942e3c-61c3-4475-809b-89fb17f84fbb}-VeraDialogActionTrigger.xml</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\VeraDialogActionTrigger.xml</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\DefaultWide\VeraDialogDeviceControl.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{81cf93f1-6f6f-46de-9370-e4c75596ca9d}-VeraDialogDeviceControl.xml</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\VeraDialogDeviceControl.xml</DestinationFilename> + </FileItem> + </Items> + </Files> + </GroupItem> + <GroupItem Name="IconsDefault"> + <DisplayName>Icons-default</DisplayName> + <DefaulChecked>true</DefaulChecked> + <Description>IconsDefault</Description> + <Files> + <Items> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Binary_Light_0.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{89116eb0-9f8f-4115-8585-47c31626e2f2}-Binary_Light_0.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Binary_Light_0.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Binary_Light_100.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{6bb2f991-9a12-485d-b619-127cf337a8e6}-Binary_Light_100.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Binary_Light_100.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\default_panel.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{e50d693c-667a-4bca-9b98-94a88d9a26f3}-default_panel.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\default_panel.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_0.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{c4930324-5849-4cfb-b4cb-366999094a0d}-Dimmable_Light_0.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Dimmable_Light_0.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_100.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{fb44ba6e-e418-469b-8ba4-3fe1a064bb6e}-Dimmable_Light_100.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Dimmable_Light_100.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_25.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{7b289b0b-bae4-4636-a12e-ba59429f0cf3}-Dimmable_Light_25.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Dimmable_Light_25.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_50.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{f75631ed-96fe-4349-9be5-d278daff8cba}-Dimmable_Light_50.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Dimmable_Light_50.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_75.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{efb6ef6a-7cdf-48bf-b675-d45378f156e4}-Dimmable_Light_75.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Dimmable_Light_75.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Door_Lock.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{df1a20d3-936c-4b7b-89c5-fb509a998cf2}-Door_Lock.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Door_Lock.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Door_Lock_0.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{b1eaf501-4274-4a7f-9e7a-fbcf5cccf440}-Door_Lock_0.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Door_Lock_0.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Door_Lock_100.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{f9f6e928-f0fb-4212-8994-c88ae2981829}-Door_Lock_100.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Door_Lock_100.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\energy.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{53f9d0bd-c18e-40ee-8c54-d319744bc032}-energy.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\energy.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\findvera.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{d66f0720-f31a-494f-8f48-d573342f04bb}-findvera.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\findvera.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Generic_IO.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{5c67f3ea-9e86-4b21-adcf-5a8cb00e94c0}-Generic_IO.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Generic_IO.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\generic_sensor.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{48c7aff1-ff51-4c34-873a-9bb717a11eb1}-generic_sensor.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\generic_sensor.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Humidity_Sensor.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{eee55fd4-330f-40a8-b3e1-c728e9ae40cc}-Humidity_Sensor.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Humidity_Sensor.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Insteon.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{7316caa2-a4c9-43e9-9a11-4491aa20e358}-Insteon.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Insteon.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Light_Sensor.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{cfb228c8-c039-41b3-8388-e1292b40d568}-Light_Sensor.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Light_Sensor.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Motion_Sensor_0.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{4c0ff3e4-6770-4f74-9baf-92e3fefc783b}-Motion_Sensor_0.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Motion_Sensor_0.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Motion_Sensor_100.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{f84bc452-70f3-4bbf-ae56-00fc3182a8f3}-Motion_Sensor_100.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Motion_Sensor_100.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Power_Meter.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{968b6884-21e9-4357-99d5-b4368901d7b4}-Power_Meter.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Power_Meter.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Scenes.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{d4724f5a-6a6e-4702-b122-58d48b4d6822}-Scenes.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Scenes.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Temperature_Sensor.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{cd6d14cf-c7d2-4258-a8b4-4ac0c02ac1da}-Temperature_Sensor.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Temperature_Sensor.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Thermostat.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{6e4a50f0-98dd-4752-af25-7d260e6c4387}-Thermostat.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Thermostat.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Window_Covering.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{81d4d577-b083-4b25-ad60-86ae9f624f8b}-Window_Covering.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Window_Covering.png</DestinationFilename> + </FileItem> + </Items> + </Files> + </GroupItem> + <GroupItem Name="IconsDefaultWide"> + <DisplayName>IconsDefaultWide</DisplayName> + <DefaulChecked>true</DefaulChecked> + <Description>IconsDefaultWide</Description> + <Files> + <Items> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Binary_Light_0.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{6b52dea7-10b3-47f0-b501-fb4066d4401f}-Binary_Light_0.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Binary_Light_0.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Binary_Light_100.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{038b63d1-5117-45d2-aabd-e71be925cd82}-Binary_Light_100.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Binary_Light_100.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\default_panel.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{b73ea654-f982-4b56-9545-6b37eedbe50d}-default_panel.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\default_panel.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_0.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{f7b771b8-1e81-4b03-aa0e-e543828ebae6}-Dimmable_Light_0.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Dimmable_Light_0.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_100.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{94401be2-c4ff-4ffb-b5cc-467a2a56ce09}-Dimmable_Light_100.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Dimmable_Light_100.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_25.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{573a2fa0-792d-4f96-8b6f-77c132b401d9}-Dimmable_Light_25.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Dimmable_Light_25.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_50.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{a22acfc5-030e-46b9-b3f2-a3d7715c686e}-Dimmable_Light_50.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Dimmable_Light_50.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_75.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{00f2700c-279b-4f65-80a4-c6bf492bfedc}-Dimmable_Light_75.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Dimmable_Light_75.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Door_Lock.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{8c082e30-634c-4522-b8c6-21ed2f1da157}-Door_Lock.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Door_Lock.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Door_Lock_0.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{f4995882-0621-4a4b-b872-5dc4dd375874}-Door_Lock_0.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Door_Lock_0.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Door_Lock_100.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{056c0d53-e453-4c10-aa53-7cc9e2feeeec}-Door_Lock_100.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Door_Lock_100.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\energy.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{1b31597a-7ee0-431f-ac40-2c6f4ef900a1}-energy.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\energy.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\findvera.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{cca1d9fa-0a0c-4e82-8640-335e965f0944}-findvera.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\findvera.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Generic_IO.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{b5124f9f-e8bb-4c30-813c-ff06b9064f2b}-Generic_IO.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Generic_IO.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\generic_sensor.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{9dac2abb-b92b-4f34-987b-89befad576e4}-generic_sensor.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\generic_sensor.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Humidity_Sensor.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{a4e8847b-7b39-4a7b-b2d3-4f3be63991f6}-Humidity_Sensor.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Humidity_Sensor.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Insteon.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{d3df16fc-e295-4af2-8757-37b245cc6522}-Insteon.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Insteon.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Light_Sensor.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{7f28ddf2-f66b-4726-bd27-53062fa65451}-Light_Sensor.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Light_Sensor.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Motion_Sensor_0.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{11842716-9e2a-4226-8af5-57240474673c}-Motion_Sensor_0.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Motion_Sensor_0.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Motion_Sensor_100.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{490ebe21-fa83-4cab-bd25-62d09902bc52}-Motion_Sensor_100.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Motion_Sensor_100.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Power_Meter.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{c7e21c80-2566-4ae8-a656-24f36c0dee24}-Power_Meter.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Power_Meter.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Scenes.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{6a32f914-e28c-4bb5-b6bd-633c527f26fe}-Scenes.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Scenes.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Temperature_Sensor.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{40cc3e24-e58d-49d5-8747-0e7c8421e57d}-Temperature_Sensor.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Temperature_Sensor.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Thermostat.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{26667211-641d-4524-88ac-8d8a07998da6}-Thermostat.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Thermostat.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Window_Covering.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{10317a0b-8169-4b3c-acff-db60a3118d2e}-Window_Covering.png</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera\Window_Covering.png</DestinationFilename> + </FileItem> + </Items> + </Files> + </GroupItem> + </Items> + </Groups> + <Sections> + <Items> + <SectionItem Guid="f47c168b-0a86-4bee-ac91-76cc8511b6da" Name="Welcome Screen" ConditionGroup="Default"> + <Params> + <Items> + <SectionParam Name="Header text"> + <Value>Welcome to the Extension Installer for [Name]</Value> + <ValueType>String</ValueType> + <Description /> + </SectionParam> + <SectionParam Name="Description"> + <Value>This will install [Name] version [Version] on your computer. +It is recommended that you close all other applications before continuing. +Click Next to continue or Cancel to exit Setup.</Value> + <ValueType>String</ValueType> + <Description /> + </SectionParam> + <SectionParam Name="Left part image"> + <Value /> + <ValueType>File</ValueType> + <Description /> + </SectionParam> + <SectionParam Name="Header image"> + <Value /> + <ValueType>File</ValueType> + <Description>Image in upper right part</Description> + </SectionParam> + </Items> + </Params> + <Actions> + <Items /> + </Actions> + <IncludedGroups /> + <PanelName>Welcome Screen</PanelName> + <WizardButtonsEnum>NextCancel</WizardButtonsEnum> + </SectionItem> + <SectionItem Guid="7719bf74-822b-47a6-be0f-cd876c40bcae" Name="Install Section" ConditionGroup=""> + <Params> + <Items> + <SectionParam Name="Header Title"> + <Value>Do not forget config this plugin, after installation!!!</Value> + <ValueType>String</ValueType> + <Description>Header title</Description> + </SectionParam> + <SectionParam Name="Header description"> + <Value>- Run MediaPortal configuration-tool to enable VeraContoller +- Hit also the config button and set Vera's IP-address</Value> + <ValueType>String</ValueType> + <Description>Description of section, shown in under section title</Description> + </SectionParam> + <SectionParam Name="Header image"> + <Value /> + <ValueType>File</ValueType> + <Description>Image in upper right part</Description> + </SectionParam> + </Items> + </Params> + <Actions> + <Items> + <ActionItem Name="InstallFiles" ActionType="InstallFiles" ConditionGroup=""> + <Params> + <Items /> + </Params> + <ExecuteLocation>AfterPanelShow</ExecuteLocation> + </ActionItem> + </Items> + </Actions> + <IncludedGroups> + <string>Default</string> + <string>IconsDefault</string> + <string>IconsDefaultWide</string> + </IncludedGroups> + <PanelName>Install Section</PanelName> + <WizardButtonsEnum>Next</WizardButtonsEnum> + </SectionItem> + <SectionItem Guid="50a84c38-e290-4043-9691-d1410eed9968" Name="Setup Complete" ConditionGroup="Default"> + <Params> + <Items> + <SectionParam Name="Header text"> + <Value>The Extension Installer Wizard has successfully installed [Name]. + +Do not forget to configure the Vera Control plug in. + +</Value> + <ValueType>String</ValueType> + <Description /> + </SectionParam> + <SectionParam Name="Left part image"> + <Value /> + <ValueType>File</ValueType> + <Description /> + </SectionParam> + <SectionParam Name="Show radio buttons"> + <Value>NO</Value> + <ValueType>Bool</ValueType> + <Description>Use radiobutton in place of combobox</Description> + </SectionParam> + <SectionParam Name="Header image"> + <Value /> + <ValueType>File</ValueType> + <Description>Image in upper right part</Description> + </SectionParam> + </Items> + </Params> + <Actions> + <Items /> + </Actions> + <IncludedGroups /> + <PanelName>Setup Complete</PanelName> + <WizardButtonsEnum>Finish</WizardButtonsEnum> + </SectionItem> + </Items> + </Sections> + <Dependencies> + <Items> + <DependencyItem> + <Type>MediaPortal</Type> + <Id /> + <MinVersion> + <Major>1</Major> + <Minor>1</Minor> + <Build>6</Build> + <Revision>27644</Revision> + </MinVersion> + <MaxVersion> + <Major>1</Major> + <Minor>1</Minor> + <Build>6</Build> + <Revision>27644</Revision> + </MaxVersion> + <WarnOnly>false</WarnOnly> + <Message>requires MediaPortal version 1.1.6.27644 to 1.1.6.27644.</Message> + <Name>MediaPortal</Name> + </DependencyItem> + </Items> + </Dependencies> + <PluginDependencies> + <Items> + <PluginDependencyItem AssemblyName="VeraControl.dll"> + <CompatibleVersion> + <Items> + <CompatibleVersionItem> + <MinRequiredVersion>1.1.6.27644</MinRequiredVersion> + <DesignedForVersion>1.1.6.27644</DesignedForVersion> + </CompatibleVersionItem> + </Items> + </CompatibleVersion> + <SubSystemsUsed> + <Items> + <SubSystemItem Name="MP.SkinEngine" /> + <SubSystemItem Name="MP.Config" /> + </Items> + </SubSystemsUsed> + </PluginDependencyItem> + </Items> + </PluginDependencies> + <GeneralInfo> + <Name>Vera Controller</Name> + <Id>ebb6b1af-6fb9-44e5-a859-9d32ffe20a9e</Id> + <Author>Bart Eversdijk</Author> + <HomePage>http://www.team-mediaportal.com/extensions/micasaverde-vera-controller</HomePage> + <ForumPage>http://forum.team-mediaportal.com/mediaportal-plugins-47/plugin-micasaverde-vera-controller-104337/</ForumPage> + <UpdateUrl /> + <Version> + <Major>0</Major> + <Minor>5</Minor> + <Build>0</Build> + <Revision>0</Revision> + </Version> + <ExtensionDescription>Control you Vera controller from MediaPortal. + + + +Supports Scene triggers for starting, hibernating and exiting MediaPortal; Also starting, pausing and stopping media streams. + + + +So dim your lights and close the curtain autmatically when MediaPortal starts a movie... + + + +Vera is a Z-wave home automation controller from MicasaVerde. This version is tested with Vera 2 UI4 v.1.1.1267 + +</ExtensionDescription> + <VersionDescription>First version - for beta testing only</VersionDescription> + <DevelopmentStatus>Beta</DevelopmentStatus> + <OnlineLocation /> + <ReleaseDate>2012-01-04T22:51:05.585629+01:00</ReleaseDate> + <Tags>home automation +z-wave +micasavera +vera</Tags> + <Location>C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\MP-Website\VeraControl.mpe1</Location> + <Params> + <Items> + <SectionParam Name="Icon"> + <Value /> + <ValueType>File</ValueType> + <Description>The icon file of the package (jpg,png,bmp)</Description> + </SectionParam> + <SectionParam Name="Online Icon"> + <Value /> + <ValueType>String</ValueType> + <Description>The icon file of the package stored online (jpg,png,bmp)</Description> + </SectionParam> + <SectionParam Name="Configuration file"> + <Value /> + <ValueType>Template</ValueType> + <Description>The file used to configure the extension. + If have .exe extension the will be executed + If have .dll extension used like MP plugin configuration</Description> + </SectionParam> + <SectionParam Name="Online Screenshots"> + <Value /> + <ValueType>String</ValueType> + <Description>Online stored screenshot urls separated by ; </Description> + </SectionParam> + <SectionParam Name="Force to uninstall on update"> + <Value>yes</Value> + <ValueType>Bool</ValueType> + <Description>Show dialog and force to uninstall previous version when updating an extension. Should only be disabled if you are using an NSIS/MSI installer.</Description> + </SectionParam> + </Items> + </Params> + </GeneralInfo> + <UniqueFileList> + <Items> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\bin\Debug\VeraControl.dll</LocalFileName> + <ZipFileName>Installer{CopyFile}\{7313a25a-e5a1-46e7-af14-613b3d1294df}-VeraControl.dll</ZipFileName> + <DestinationFilename>%Plugins%\Windows\VeraControl.dll</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Default\VeraControl.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{028d1570-2f3e-4ddb-9721-36f94cca1de5}-VeraControl.xml</ZipFileName> + <DestinationFilename>%Skin%\Default\VeraControl.xml</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Default\VeraDialogActionTrigger.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{09937fdb-eda7-4fb5-a0c6-b94788cacdb6}-VeraDialogActionTrigger.xml</ZipFileName> + <DestinationFilename>%Skin%\Default\VeraDialogActionTrigger.xml</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Default\VeraDialogDeviceControl.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{507aff1a-15af-493d-b9b4-40ef11cfc4cd}-VeraDialogDeviceControl.xml</ZipFileName> + <DestinationFilename>%Skin%\Default\VeraDialogDeviceControl.xml</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\DefaultWide\VeraControl.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{85789702-644a-4d04-b55c-8d1b76947ba4}-VeraControl.xml</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\VeraControl.xml</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\DefaultWide\VeraDialogActionTrigger.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{34942e3c-61c3-4475-809b-89fb17f84fbb}-VeraDialogActionTrigger.xml</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\VeraDialogActionTrigger.xml</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\DefaultWide\VeraDialogDeviceControl.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{81cf93f1-6f6f-46de-9370-e4c75596ca9d}-VeraDialogDeviceControl.xml</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\VeraDialogDeviceControl.xml</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Binary_Light_0.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{89116eb0-9f8f-4115-8585-47c31626e2f2}-Binary_Light_0.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Binary_Light_0.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Binary_Light_100.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{6bb2f991-9a12-485d-b619-127cf337a8e6}-Binary_Light_100.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Binary_Light_100.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\default_panel.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{e50d693c-667a-4bca-9b98-94a88d9a26f3}-default_panel.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\default_panel.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_0.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{c4930324-5849-4cfb-b4cb-366999094a0d}-Dimmable_Light_0.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Dimmable_Light_0.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_100.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{fb44ba6e-e418-469b-8ba4-3fe1a064bb6e}-Dimmable_Light_100.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Dimmable_Light_100.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_25.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{7b289b0b-bae4-4636-a12e-ba59429f0cf3}-Dimmable_Light_25.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Dimmable_Light_25.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_50.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{f75631ed-96fe-4349-9be5-d278daff8cba}-Dimmable_Light_50.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Dimmable_Light_50.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Dimmable_Light_75.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{efb6ef6a-7cdf-48bf-b675-d45378f156e4}-Dimmable_Light_75.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Dimmable_Light_75.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Door_Lock.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{df1a20d3-936c-4b7b-89c5-fb509a998cf2}-Door_Lock.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Door_Lock.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Door_Lock_0.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{b1eaf501-4274-4a7f-9e7a-fbcf5cccf440}-Door_Lock_0.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Door_Lock_0.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Door_Lock_100.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{f9f6e928-f0fb-4212-8994-c88ae2981829}-Door_Lock_100.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Door_Lock_100.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\energy.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{53f9d0bd-c18e-40ee-8c54-d319744bc032}-energy.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\energy.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\findvera.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{d66f0720-f31a-494f-8f48-d573342f04bb}-findvera.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\findvera.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Generic_IO.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{5c67f3ea-9e86-4b21-adcf-5a8cb00e94c0}-Generic_IO.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Generic_IO.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\generic_sensor.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{48c7aff1-ff51-4c34-873a-9bb717a11eb1}-generic_sensor.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\generic_sensor.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Humidity_Sensor.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{eee55fd4-330f-40a8-b3e1-c728e9ae40cc}-Humidity_Sensor.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Humidity_Sensor.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Insteon.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{7316caa2-a4c9-43e9-9a11-4491aa20e358}-Insteon.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Insteon.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Light_Sensor.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{cfb228c8-c039-41b3-8388-e1292b40d568}-Light_Sensor.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Light_Sensor.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Motion_Sensor_0.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{4c0ff3e4-6770-4f74-9baf-92e3fefc783b}-Motion_Sensor_0.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Motion_Sensor_0.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Motion_Sensor_100.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{f84bc452-70f3-4bbf-ae56-00fc3182a8f3}-Motion_Sensor_100.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Motion_Sensor_100.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Power_Meter.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{968b6884-21e9-4357-99d5-b4368901d7b4}-Power_Meter.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Power_Meter.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Scenes.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{d4724f5a-6a6e-4702-b122-58d48b4d6822}-Scenes.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Scenes.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Temperature_Sensor.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{cd6d14cf-c7d2-4258-a8b4-4ac0c02ac1da}-Temperature_Sensor.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Temperature_Sensor.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Thermostat.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{6e4a50f0-98dd-4752-af25-7d260e6c4387}-Thermostat.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Thermostat.png</DestinationFilename> + </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Media\Vera\Window_Covering.png</LocalFileName> + <ZipFileName>Installer{CopyFile}\{81d4d577-b083-4b25-ad60-86ae9f624f8b}-Window_Covering.png</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera\Window_Covering.png</DestinationFilename> + </FileItem> + </Items> + </UniqueFileList> + <ProjectSettings> + <FolderGroups> + <FolderGroup InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName /> + <ZipFileName>Installer{CopyFile}\{73fd586f-091a-4183-a08b-ab1188766f84}-</ZipFileName> + <DestinationFilename>%Skin%\Default\media\Vera</DestinationFilename> + <Folder>..\skin\Media\Vera</Folder> + <Group>IconsDefault</Group> + <Recursive>true</Recursive> + </FolderGroup> + <FolderGroup InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName /> + <ZipFileName>Installer{CopyFile}\{1450eebe-7f65-4ae9-bfce-d5a499a4fbd3}-</ZipFileName> + <DestinationFilename>%Skin%\DefaultWide\media\Vera</DestinationFilename> + <Folder>..\skin\Media\Vera</Folder> + <Group>IconsDefaultWide</Group> + <Recursive>true</Recursive> + </FolderGroup> + </FolderGroups> + <ProjectFilename>VeraControl.xmp2</ProjectFilename> + <UpdatePath1 /> + <UpdatePath2 /> + <UpdatePath3 /> + </ProjectSettings> + <IsSkin>false</IsSkin> +</PackageClass> \ No newline at end of file Added: trunk/plugins/VeraControl/releases/VeraControl_v0.5.0.0.mpe1 =================================================================== (Binary files differ) Property changes on: trunk/plugins/VeraControl/releases/VeraControl_v0.5.0.0.mpe1 ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/VeraControl/releases/update.xml =================================================================== --- trunk/plugins/VeraControl/releases/update.xml (rev 0) +++ trunk/plugins/VeraControl/releases/update.xml 2012-01-05 12:53:23 UTC (rev 4375) @@ -0,0 +1,153 @@ +<?xml version="1.0" encoding="utf-8"?> +<ExtensionCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <Items> + <PackageClass> + <Version>2.0</Version> + <Groups> + <Items> + <GroupItem Name="Default"> + <DisplayName>Default</DisplayName> + <DefaulChecked>true</DefaulChecked> + <Description>Default</Description> + <Files> + <Items /> + </Files> + </GroupItem> + <GroupItem Name="IconsDefault"> + <DisplayName>IconsDefault</DisplayName> + <DefaulChecked>true</DefaulChecked> + <Description>IconsDefault</Description> + <Files> + <Items /> + </Files> + </GroupItem> + <GroupItem Name="IconsDefaultWide"> + <DisplayName>IconsDefaultWide</DisplayName> + <DefaulChecked>true</DefaulChecked> + <Description>IconsDefaultWide</Description> + <Files> + <Items /> + </Files> + </GroupItem> + </Items> + </Groups> + <Sections> + <Items /> + </Sections> + <Dependencies> + <Items> + <DependencyItem> + <Type>MediaPortal</Type> + <Id /> + <MinVersion> + <Major>1</Major> + <Minor>1</Minor> + <Build>6</Build> + <Revision>27644</Revision> + </MinVersion> + <MaxVersion> + <Major>1</Major> + <Minor>1</Minor> + <Build>6</Build> + <Revision>27644</Revision> + </MaxVersion> + <WarnOnly>false</WarnOnly> + <Message>requires MediaPortal version 1.1.6.27644 to 1.1.6.27644.</Message> + <Name>MediaPortal</Name> + </DependencyItem> + </Items> + </Dependencies> + <PluginDependencies> + <Items> + <PluginDependencyItem AssemblyName="VeraControl.dll"> + <CompatibleVersion> + <Items> + <CompatibleVersionItem> + <MinRequiredVersion>1.1.6.27644</MinRequiredVersion> + <DesignedForVersion>1.1.6.27644</DesignedForVersion> + </CompatibleVersionItem> + </Items> + </CompatibleVersion> + <SubSystemsUsed> + <Items> + <SubSystemItem Name="MP.SkinEngine" /> + <SubSystemItem Name="MP.Config" /> + </Items> + </SubSystemsUsed> + </PluginDependencyItem> + </Items> + </PluginDependencies> + <GeneralInfo> + <Name>Vera Controller</Name> + <Id>ebb6b1af-6fb9-44e5-a859-9d32ffe20a9e</Id> + <Author>Bart Eversdijk</Author> + <HomePage>http://www.team-mediaportal.com/extensions/micasaverde-vera-controller</HomePage> + <ForumPage>http://forum.team-mediaportal.com/mediaportal-plugins-47/plugin-micasaverde-vera-controller-104337/</ForumPage> + <UpdateUrl /> + <Version> + <Major>0</Major> + <Minor>5</Minor> + <Build>0</Build> + <Revision>0</Revision> + </Version> + <ExtensionDescription>Control you Vera controller from MediaPortal. + + + +Supports Scene triggers for starting, hibernating and exiting MediaPortal; Also starting, pausing and stopping media streams. + + + +So dim your lights and close the curtain autmatically when MediaPortal starts a movie... + + + +Vera is a Z-wave home automation controller from MicasaVerde. This version is tested with Vera 2 UI4 v.1.1.1267 + +</ExtensionDescription> + <VersionDescription>First version - for beta testing only</VersionDescription> + <DevelopmentStatus>Beta</DevelopmentStatus> + <OnlineLocation /> + <ReleaseDate>2012-01-04T22:51:05.585629+01:00</ReleaseDate> + <Tags>home automation +z-wave +micasavera +vera</Tags> + <Location>C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\MP-Website\VeraControl.mpe1</Location> + <Params> + <Items> + <SectionParam Name="Online Icon"> + <Value /> + <ValueType>String</ValueType> + <Description>The icon file of the package stored online (jpg,png,bmp)</Description> + </SectionParam> + <SectionParam Name="Configuration file"> + <Value /> + <ValueType>Template</ValueType> + <Description>The file used to configure the extension. + If have .exe extension the will be executed + If have .dll extension used like MP plugin configuration</Description> + </SectionParam> + <SectionParam Name="Online Screenshots"> + <Value /> + <ValueType>String</ValueType> + <Description>Online stored screenshot urls separated by ; </Description> + </SectionParam> + <SectionParam Name="Force to uninstall on update"> + <Value>yes</Value> + <ValueType>Bool</Val... [truncated message content] |
From: <Ba...@us...> - 2012-01-05 14:48:53
|
Revision: 4381 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4381&view=rev Author: BartEv Date: 2012-01-05 14:48:47 +0000 (Thu, 05 Jan 2012) Log Message: ----------- Modified Paths: -------------- trunk/plugins/VeraControl/Properties/AssemblyInfo.cs trunk/plugins/VeraControl/releases/VeraControl.xmp2 trunk/plugins/VeraControl/releases/update.xml Added Paths: ----------- trunk/plugins/VeraControl/releases/VeraControl_v0.5.0.1.mpe1 Modified: trunk/plugins/VeraControl/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2012-01-05 14:37:36 UTC (rev 4380) +++ trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2012-01-05 14:48:47 UTC (rev 4381) @@ -28,4 +28,4 @@ // // You can specify all the values or you can use the default the Revision and // Build Numbers by using the '*' as shown below: -[assembly: AssemblyVersion("0.5.*")] +[assembly: AssemblyVersion("0.5.0.1")] Modified: trunk/plugins/VeraControl/releases/VeraControl.xmp2 =================================================================== --- trunk/plugins/VeraControl/releases/VeraControl.xmp2 2012-01-05 14:37:36 UTC (rev 4380) +++ trunk/plugins/VeraControl/releases/VeraControl.xmp2 2012-01-05 14:48:47 UTC (rev 4381) @@ -599,23 +599,29 @@ <Major>0</Major> <Minor>5</Minor> <Build>0</Build> - <Revision>0</Revision> + <Revision>1</Revision> </Version> - <ExtensionDescription>Control your Vera controller from MediaPortal. -Supports Scene triggers for starting, hibernating and exiting MediaPortal; Also starting, pausing and stopping media streams. So dim your lights and close the curtain autmatically when MediaPortal starts a movie... + <ExtensionDescription>Control your Vera controller from MediaPortal. -Vera is a Z-wave home automation controller from MicasaVerde. This version is tested with Vera 2 UI4 v.1.1.1267 +Supports Scene triggers for starting, hibernating and exiting MediaPortal; Also starting, pausing and stopping media streams. So dim your lights and close the curtain autmatically when MediaPortal starts a movie... + + +Vera is a Z-wave home automation controller from MicasaVerde. This version is tested with Vera 2 UI4 v.1.1.1267 + + + </ExtensionDescription> - <VersionDescription>First version - for beta testing only</VersionDescription> + <VersionDescription>First version - for beta testing only +Minor updates</VersionDescription> <DevelopmentStatus>Beta</DevelopmentStatus> <OnlineLocation>https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/VeraControl/releases/</OnlineLocation> - <ReleaseDate>2012-01-04T22:51:05.585629+01:00</ReleaseDate> + <ReleaseDate>2012-01-05T22:51:05</ReleaseDate> <Tags>home automation, z-wave, micasaverde, vera</Tags> - <Location>C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\releases\VeraControl_v0.5.0.0.mpe1</Location> + <Location>C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\releases\VeraControl_v[Version].mpe1</Location> <Params> <Items> <SectionParam Name="Icon"> Added: trunk/plugins/VeraControl/releases/VeraControl_v0.5.0.1.mpe1 =================================================================== (Binary files differ) Property changes on: trunk/plugins/VeraControl/releases/VeraControl_v0.5.0.1.mpe1 ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/plugins/VeraControl/releases/update.xml =================================================================== --- trunk/plugins/VeraControl/releases/update.xml 2012-01-05 14:37:36 UTC (rev 4380) +++ trunk/plugins/VeraControl/releases/update.xml 2012-01-05 14:48:47 UTC (rev 4381) @@ -139,5 +139,150 @@ </ProjectSettings> <IsSkin>false</IsSkin> </PackageClass> + <PackageClass> + <Version>2.0</Version> + <Groups> + <Items> + <GroupItem Name="Default"> + <DisplayName>Default</DisplayName> + <DefaulChecked>true</DefaulChecked> + <Description>Default</Description> + <Files> + <Items /> + </Files> + </GroupItem> + <GroupItem Name="IconsDefault"> + <DisplayName>IconsDefault</DisplayName> + <DefaulChecked>true</DefaulChecked> + <Description>IconsDefault</Description> + <Files> + <Items /> + </Files> + </GroupItem> + <GroupItem Name="IconsDefaultWide"> + <DisplayName>IconsDefaultWide</DisplayName> + <DefaulChecked>true</DefaulChecked> + <Description>IconsDefaultWide</Description> + <Files> + <Items /> + </Files> + </GroupItem> + </Items> + </Groups> + <Sections> + <Items /> + </Sections> + <Dependencies> + <Items> + <DependencyItem> + <Type>MediaPortal</Type> + <Id /> + <MinVersion> + <Major>1</Major> + <Minor>1</Minor> + <Build>6</Build> + <Revision>27644</Revision> + </MinVersion> + <MaxVersion> + <Major>1</Major> + <Minor>1</Minor> + <Build>6</Build> + <Revision>27644</Revision> + </MaxVersion> + <WarnOnly>false</WarnOnly> + <Message>requires MediaPortal version 1.1.6.27644 to 1.1.6.27644.</Message> + <Name>MediaPortal</Name> + </DependencyItem> + </Items> + </Dependencies> + <PluginDependencies> + <Items> + <PluginDependencyItem AssemblyName="VeraControl.dll"> + <CompatibleVersion> + <Items> + <CompatibleVersionItem> + <MinRequiredVersion>1.1.6.27644</MinRequiredVersion> + <DesignedForVersion>1.1.6.27644</DesignedForVersion> + </CompatibleVersionItem> + </Items> + </CompatibleVersion> + <SubSystemsUsed> + <Items> + <SubSystemItem Name="MP.SkinEngine" /> + <SubSystemItem Name="MP.Config" /> + </Items> + </SubSystemsUsed> + </PluginDependencyItem> + </Items> + </PluginDependencies> + <GeneralInfo> + <Name>Vera Controller</Name> + <Id>ebb6b1af-6fb9-44e5-a859-9d32ffe20a9e</Id> + <Author>Bart Eversdijk</Author> + <HomePage>http://www.team-mediaportal.com/extensions/micasaverde-vera-controller</HomePage> + <ForumPage>http://forum.team-mediaportal.com/mediaportal-plugins-47/plugin-micasaverde-vera-controller-104337/</ForumPage> + <UpdateUrl>https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/VeraControl/releases/update.xml</UpdateUrl> + <Version> + <Major>0</Major> + <Minor>5</Minor> + <Build>0</Build> + <Revision>1</Revision> + </Version> + <ExtensionDescription>Control your Vera controller from MediaPortal. + +Supports Scene triggers for starting, hibernating and exiting MediaPortal; Also starting, pausing and stopping media streams. So dim your lights and close the curtain autmatically when MediaPortal starts a movie... + + + +Vera is a Z-wave home automation controller from MicasaVerde. This version is tested with Vera 2 UI4 v.1.1.1267 + + + +</ExtensionDescription> + <VersionDescription>First version - for beta testing only +Minor updates</VersionDescription> + <DevelopmentStatus>Beta</DevelopmentStatus> + <OnlineLocation>https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/VeraControl/releases/</OnlineLocation> + <ReleaseDate>2012-01-05T22:51:05</ReleaseDate> + <Tags>home automation, +z-wave, +micasaverde, +vera</Tags> + <Location>C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\releases\VeraControl_v[Version].mpe1</Location> + <Params> + <Items> + <SectionParam Name="Online Icon"> + <Value /> + <ValueType>String</ValueType> + <Description>The icon file of the package stored online (jpg,png,bmp)</Description> + </SectionParam> + <SectionParam Name="Configuration file"> + <Value /> + <ValueType>Template</ValueType> + <Description>The file used to configure the extension. + If have .exe extension the will be executed + If have .dll extension used like MP plugin configuration</Description> + </SectionParam> + <SectionParam Name="Online Screenshots"> + <Value /> + <ValueType>String</ValueType> + <Description>Online stored screenshot urls separated by ; </Description> + </SectionParam> + <SectionParam Name="Force to uninstall on update"> + <Value>yes</Value> + <ValueType>Bool</ValueType> + <Description>Show dialog and force to uninstall previous version when updating an extension. Should only be disabled if you are using an NSIS/MSI installer.</Description> + </SectionParam> + </Items> + </Params> + </GeneralInfo> + <UniqueFileList> + <Items /> + </UniqueFileList> + <ProjectSettings> + <FolderGroups /> + </ProjectSettings> + <IsSkin>false</IsSkin> + </PackageClass> </Items> -</ExtensionCollection> +</ExtensionCollection> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ba...@us...> - 2012-01-08 19:33:42
|
Revision: 4394 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4394&view=rev Author: BartEv Date: 2012-01-08 19:33:34 +0000 (Sun, 08 Jan 2012) Log Message: ----------- Modified Paths: -------------- trunk/plugins/VeraControl/DevCategories.cs trunk/plugins/VeraControl/DeviceDimmer.cs trunk/plugins/VeraControl/DeviceDoorlock.cs trunk/plugins/VeraControl/DeviceGWeather.cs trunk/plugins/VeraControl/DeviceGeneric.cs trunk/plugins/VeraControl/DeviceHumidity.cs trunk/plugins/VeraControl/DeviceLightSensor.cs trunk/plugins/VeraControl/DevicePowerMeter.cs trunk/plugins/VeraControl/DeviceSecurity.cs trunk/plugins/VeraControl/DeviceSprinkler.cs trunk/plugins/VeraControl/DeviceSwitch.cs trunk/plugins/VeraControl/DeviceTemperature.cs trunk/plugins/VeraControl/DeviceThermostat.cs trunk/plugins/VeraControl/DialogActionTrigger.cs trunk/plugins/VeraControl/DialogDeviceControl.cs trunk/plugins/VeraControl/Properties/AssemblyInfo.cs trunk/plugins/VeraControl/Room.cs trunk/plugins/VeraControl/Scene.cs trunk/plugins/VeraControl/Section.cs trunk/plugins/VeraControl/VeraCommunication.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/VeraControl.csproj trunk/plugins/VeraControl/skin/Default/VeraControl.xml trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml Added Paths: ----------- trunk/plugins/VeraControl/VeraHelper.cs trunk/plugins/VeraControl/skin/Media/Vera/Ip_Camera.png trunk/plugins/VeraControl/skin/Media/Vera/location.png Modified: trunk/plugins/VeraControl/DevCategories.cs =================================================================== --- trunk/plugins/VeraControl/DevCategories.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DevCategories.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -20,21 +20,20 @@ { public DevCategories(XmlNode xn) { - if (xn == null) { - m_sName = ""; - m_iId = 0; - } else { + if (xn != null) + { update(xn); } } - private string m_sName; - private int m_iId; + private string m_sName = "unknown category"; + private int m_iId = 0; + public VeraHelper helper = VeraHelper.Instance; public bool update(XmlNode xn) { - m_sName = xn.Attributes["name"].Value; - m_iId = int.Parse(xn.Attributes["id"].Value); + m_sName = helper.getAttrAsString(xn, "name", m_sName); + m_iId = helper.getAttrAsInt (xn, "id", m_iId); return true; } Modified: trunk/plugins/VeraControl/DeviceDimmer.cs =================================================================== --- trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -18,8 +18,9 @@ /// </summary> public class DeviceDimmer : DeviceGeneric { - private int m_iLevel; - private string m_sWatt; + private int m_iLevel = 0; + private string m_sWatt = "-"; + private string m_sKwh = "-"; public DeviceDimmer( XmlNode xn ): base (xn) { @@ -31,8 +32,9 @@ public override bool update(XmlNode xn) { - m_iLevel = (xn.Attributes["level"] != null ? int.Parse(xn.Attributes["level"].Value) : 0); - m_sWatt = (xn.Attributes["watts"] != null ? xn.Attributes["watts"].Value : "0"); + m_iLevel = helper.getAttrAsInt (xn, "level", m_iLevel); + m_sWatt = helper.getAttrAsString(xn, "watts", m_sWatt); + m_sKwh = helper.getAttrAsString(xn, "kwh", m_sKwh); return base.update(xn); } @@ -43,7 +45,7 @@ set { } } - public override bool state + public override bool status { get { return (m_iLevel > 0); } set { @@ -62,12 +64,14 @@ } else { if (newValue < 0) { newValue = 0; } } - VeraCommunication vera = VeraCommunication.Instance; - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget" + - "&newLoadlevelTarget="+value; - string sResult = vera.doVeraRequest(cmd); + if (id > 0) // Only send when a valid ID is found + { + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget" + + "&newLoadlevelTarget="+value; + vera.doVeraRequest(cmd); + } m_iLevel = newValue; } } @@ -100,9 +104,15 @@ return "Dimmable_Light_"+leveltxt; } + + public override string getExtraText() + { + return (m_sKwh != "" ? m_sKwh + "kWh" : ""); + } + public override string getStatusText() { - return ( state ? level.ToString() + "%" : "Off"); + return ( status ? level.ToString() + "%" : "Off"); } } } Modified: trunk/plugins/VeraControl/DeviceDoorlock.cs =================================================================== --- trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -18,7 +18,7 @@ /// </summary> public class DeviceDoorlock : DeviceGeneric { - private bool m_bStatus; + private bool m_bStatus = false; public DeviceDoorlock( XmlNode xn ): base (xn) { @@ -30,21 +30,23 @@ public override bool update(XmlNode xn) { - m_bStatus = (xn.Attributes["status"].Value == "1"); + m_bStatus = helper.getAttrAsBool(xn, "status", m_bStatus); return base.update(xn); } - public override bool state + public override bool status { get { return m_bStatus; } set { - VeraCommunication vera = VeraCommunication.Instance; - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget" + - "&newTargetValue="+(value ? "1" : "0"); - string sResult = vera.doVeraRequest(cmd); + if (id > 0) // Only send when a valid ID is found + { + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget" + + "&newTargetValue="+(value ? "1" : "0"); + vera.doVeraRequest(cmd); + } m_bStatus = value; } } @@ -54,7 +56,7 @@ get { return (m_bStatus ? 1 : 0); } set { - state = (value > 0); + status = (value > 0); } } @@ -82,7 +84,7 @@ public override string getStatusText() { - return (state ? "Locked" : "Unlocked"); + return (status ? "Locked" : "Unlocked"); } } Modified: trunk/plugins/VeraControl/DeviceGWeather.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGWeather.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DeviceGWeather.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -18,8 +18,8 @@ /// </summary> public class DeviceGWeather : DeviceGeneric { - private string m_sCondition; - private string m_sWindCondition; + private string m_sCondition = "-"; + private string m_sWindCondition = "-"; public DeviceGWeather( XmlNode xn ): base (xn) { @@ -31,8 +31,10 @@ public override bool update(XmlNode xn) { - m_sCondition = (xn.Attributes["Condition"] != null ? xn.Attributes["Condition"].Value : "-"); - m_sWindCondition = (xn.Attributes["WindCondition"] != null ? xn.Attributes["WindCondition"].Value : "-"); + m_sCondition = helper.getAttrAsString(xn, "Condition", m_sCondition); // Google Weather Plugin + m_sCondition = helper.getAttrAsString(xn, "condition", m_sCondition); // World Weather plugin + m_sWindCondition = helper.getAttrAsString(xn, "WindCondition", m_sWindCondition); + m_sWindCondition = helper.getAttrAsString(xn, "windcondition", m_sWindCondition); return base.update(xn); } @@ -50,5 +52,10 @@ { return m_sWindCondition; } + + public override string getIconName() + { + return "location"; + } } } Modified: trunk/plugins/VeraControl/DeviceGeneric.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -4,8 +4,8 @@ * Date: 22-12-2011 * Time: 13:07 * - * Copyright: 2012 GPL - Bart Eversdijk - * MediaPort plugin - MicasaVerde (TM) Vera Controller + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller * E-mail: ba...@ev... */ using System; @@ -14,17 +14,26 @@ namespace VeraControl.Properties { + + /// <summary> /// Description of DeviceGeneric. /// </summary> public class DeviceGeneric { - private string m_sName = ""; + private string m_sName = "unknown device"; private int m_iId = 0; private string m_sAltId = ""; private int m_iCategory = 0; private int m_iRoom = 0; + // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) + private DevState m_dsState = DevState.NONE; + private string m_sComment = ""; // red(error), green(success) or blue(pending) - icon/text + + public VeraHelper helper = VeraHelper.Instance; + public VeraCommunication vera = VeraCommunication.Instance; + public DeviceGeneric(XmlNode xn) { if (xn != null) @@ -35,11 +44,29 @@ public virtual bool update(XmlNode xn) { - m_sName = xn.Attributes["name"].Value; - m_iId = int.Parse(xn.Attributes["id"].Value); - m_sAltId = xn.Attributes["altid"].Value; - m_iCategory = int.Parse(xn.Attributes["category"].Value); - m_iRoom = int.Parse(xn.Attributes["room"].Value); + m_sName = helper.getAttrAsString(xn, "name", m_sName); + m_iId = helper.getAttrAsInt (xn, "id", m_iId); + m_sAltId = helper.getAttrAsString(xn, "altid", m_sAltId); + m_iCategory = helper.getAttrAsInt (xn, "category", m_iCategory); + m_iRoom = helper.getAttrAsInt (xn, "room", m_iRoom); + + m_sComment = helper.getAttrAsString(xn, "comment", m_sComment ); + m_dsState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1)); + + if (m_iId == 0) + { + // void device no further processing needed + return true; + } + // Make sure room exists + if (m_iRoom == 0 || !vera.status.isRoomFound(m_iRoom)) + { + if (!vera.status.isRoomFound(0)) + { // create dummy room to attach to + vera.rooms.Add(new Room(null)); + } + m_iRoom = 0; + } return true; } @@ -88,9 +115,21 @@ get { return false; } set { } } - - public virtual bool state + + public virtual DevState commstate { + get { return m_dsState; } + set { } + } + + public virtual string comment + { + get { return (commstate != DevState.NONE ? m_sComment : ""); } + set { } + } + + public virtual bool status + { get { return false; } set { } } Modified: trunk/plugins/VeraControl/DeviceHumidity.cs =================================================================== --- trunk/plugins/VeraControl/DeviceHumidity.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DeviceHumidity.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -18,7 +18,7 @@ /// </summary> public class DeviceHumidity : DeviceGeneric { - private int m_iLevel; + private int m_iLevel = 0; public DeviceHumidity( XmlNode xn ): base (xn) { @@ -30,7 +30,7 @@ public override bool update(XmlNode xn) { - m_iLevel = int.Parse(xn.Attributes["humidity"].Value); + m_iLevel = helper.getAttrAsInt(xn, "humidity", m_iLevel); return base.update(xn); } Modified: trunk/plugins/VeraControl/DeviceLightSensor.cs =================================================================== --- trunk/plugins/VeraControl/DeviceLightSensor.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DeviceLightSensor.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -18,7 +18,7 @@ /// </summary> public class DeviceLightSensor : DeviceGeneric { - private int m_iLevel; + private int m_iLevel = 0; public DeviceLightSensor( XmlNode xn ): base (xn) { @@ -30,11 +30,12 @@ public override bool update(XmlNode xn) { - m_iLevel = (xn.Attributes["level"] != null ? int.Parse(xn.Attributes["level"].Value) : 0); + m_iLevel = helper.getAttrAsInt(xn, "level", m_iLevel); + m_iLevel = helper.getAttrAsInt(xn, "light", m_iLevel); return base.update(xn); } - public override bool state + public override bool status { get { return (m_iLevel > 0); } set { } Modified: trunk/plugins/VeraControl/DevicePowerMeter.cs =================================================================== --- trunk/plugins/VeraControl/DevicePowerMeter.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DevicePowerMeter.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -18,7 +18,8 @@ /// </summary> public class DevicePowerMeter : DeviceGeneric { - private int m_iLevel; + private int m_iLevel = 0; + private string m_sKwh = ""; public DevicePowerMeter( XmlNode xn ): base (xn) { @@ -30,7 +31,8 @@ public override bool update(XmlNode xn) { - m_iLevel = (xn.Attributes["level"] != null ? int.Parse(xn.Attributes["watts"].Value) : 0); + m_iLevel = helper.getAttrAsInt (xn, "watts", m_iLevel); + m_sKwh = helper.getAttrAsString(xn, "kwh", m_sKwh); return base.update(xn); } @@ -40,7 +42,7 @@ set { } } - public override bool state + public override bool status { get { return (m_iLevel > 0); } set { } @@ -68,6 +70,11 @@ return "Power_Meter"; } + public override string getExtraText() + { + return (m_sKwh != "" ? m_sKwh + "kWh" : ""); + } + public override string getStatusText() { return level.ToString() + "W"; Modified: trunk/plugins/VeraControl/DeviceSecurity.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSecurity.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DeviceSecurity.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -19,8 +19,8 @@ /// </summary> public class DeviceSecurity: DeviceGeneric { - private bool m_bTripped; - private bool m_bArmed; + private bool m_bTripped = false; + private bool m_bArmed = true; public DeviceSecurity( XmlNode xn ): base (xn) { @@ -32,20 +32,23 @@ public override bool update(XmlNode xn) { - m_bTripped = (xn.Attributes["tripped"].Value == "1"); - m_bArmed = (xn.Attributes["armed"].Value == "1"); + m_bTripped = helper.getAttrAsBool(xn, "tripped", m_bTripped); + m_bArmed = helper.getAttrAsBool(xn, "armed", m_bArmed); return base.update(xn); } - public override bool state + public override bool status { get { return m_bArmed; } - set { VeraCommunication vera = VeraCommunication.Instance; - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&action=SetArmed" + - "&newArmedValue=" + (value ? "1" : "0"); - string sResult = vera.doVeraRequest(cmd); + set { + if (id > 0) // Only send when a valid ID is found + { + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&action=SetArmed" + + "&newArmedValue=" + (value ? "1" : "0"); + vera.doVeraRequest(cmd); + } m_bArmed = value; } } @@ -59,7 +62,7 @@ public override int level { get { return (m_bArmed ? 1 : 0); } - set { state = (value > 0); } + set { status = (value > 0); } } public override int maxLevel @@ -84,7 +87,7 @@ public override string getStatusText() { - return (state ? ( tripped ? "TRIPPED" : "standby") : "bypass"); + return (status ? ( tripped ? "TRIPPED" : "standby") : "bypass"); } public override string[] getCommands() Modified: trunk/plugins/VeraControl/DeviceSprinkler.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -19,11 +19,11 @@ /// </summary> public class DeviceSprinkler : DeviceGeneric { - private bool m_bStatus; - private string m_sMode; - private string m_sShortMode; - private string m_sOperationMode; - private string m_sCondition; + private bool m_bStatus = false; + private string m_sMode = "-"; + private string m_sShortMode = "-"; + private string m_sOperationMode = "-"; + private string m_sCondition = "-"; public DeviceSprinkler( XmlNode xn ): base (xn) { @@ -35,24 +35,26 @@ public override bool update(XmlNode xn) { - m_bStatus = (xn.Attributes["status"].Value == "1"); - m_sMode = (xn.Attributes["Mode"] != null ? xn.Attributes["Mode"].Value : "-"); - m_sShortMode = (xn.Attributes["ShortMode"] != null ? xn.Attributes["ShortMode"].Value : "-"); - m_sOperationMode = (xn.Attributes["OperationMode"] != null ? xn.Attributes["OperationMode"].Value : "-"); - m_sCondition = (xn.Attributes["Condition"] != null ? xn.Attributes["Condition"].Value : "-"); + m_bStatus = helper.getAttrAsBool (xn, "status", m_bStatus); + m_sMode = helper.getAttrAsString(xn, "Mode", m_sMode); + m_sShortMode = helper.getAttrAsString(xn, "ShortMode", m_sShortMode); + m_sOperationMode = helper.getAttrAsString(xn, "OperationMode", m_sOperationMode); + m_sCondition = helper.getAttrAsString(xn, "Condition", m_sCondition); return base.update(xn); } - public override bool state + public override bool status { get { return m_bStatus; } set { - VeraCommunication vera = VeraCommunication.Instance; - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + - "&newTargetValue="+(value ? "1" : "0"); - string sResult = vera.doVeraRequest(cmd); + if (id > 0) // Only send when a valid ID is found + { + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + + "&newTargetValue="+(value ? "1" : "0"); + vera.doVeraRequest(cmd); + } m_bStatus = value; } } @@ -60,19 +62,21 @@ public override int level { get { return (m_bStatus ? 1 : 0); } - set { state = (value > 0); } + set { status = (value > 0); } } public override string mode { get { return m_sMode; } set { - VeraCommunication vera = VeraCommunication.Instance; - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:upnp-micasaverde-com:serviceId:Sprinkler1&action=" + - (value == "Auto" ? "SetModeAuto" : (value == "Block" ? "SetModeBlock" : "SetModeManual")); - string sResult = vera.doVeraRequest(cmd); + if (id > 0) // Only send when a valid ID is found + { + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:upnp-micasaverde-com:serviceId:Sprinkler1&action=" + + (value == "Auto" ? "SetModeAuto" : (value == "Block" ? "SetModeBlock" : "SetModeManual")); + vera.doVeraRequest(cmd); + } m_sMode = value; } } @@ -108,8 +112,6 @@ { return m_sCondition; } - - public override string [] getCommands() { Modified: trunk/plugins/VeraControl/DeviceSwitch.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSwitch.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DeviceSwitch.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -18,8 +18,9 @@ /// </summary> public class DeviceSwitch : DeviceGeneric { - private bool m_bStatus; - private string m_sWatt; + private bool m_bStatus = false; + private string m_sWatt = "-"; + private string m_sKwh = "-"; public DeviceSwitch( XmlNode xn ): base (xn) { @@ -31,8 +32,10 @@ public override bool update(XmlNode xn) { - m_bStatus = (xn.Attributes["status"].Value == "1"); - m_sWatt = (xn.Attributes["watts"] != null ? xn.Attributes["watts"].Value : "0"); + m_bStatus = helper.getAttrAsBool (xn, "status", m_bStatus); + m_sWatt = helper.getAttrAsString(xn, "watts", m_sWatt); + m_sKwh = helper.getAttrAsString(xn, "kwh", m_sKwh); + return base.update(xn); } @@ -42,16 +45,18 @@ set { } } - public override bool state + public override bool status { get { return m_bStatus; } set { - VeraCommunication vera = VeraCommunication.Instance; - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + - "&newTargetValue="+(value ? "1" : "0"); - string sResult = vera.doVeraRequest(cmd); + if (id > 0) // Only send when a valid ID is found + { + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + + "&newTargetValue="+(value ? "1" : "0"); + vera.doVeraRequest(cmd); + } m_bStatus = value; } } @@ -59,7 +64,7 @@ public override int level { get { return (m_bStatus ? 1 : 0); } - set { state = (value > 0); } + set { status = (value > 0); } } public override int maxLevel @@ -84,9 +89,14 @@ return "Binary_Light_" + (m_bStatus ? "100" : "0"); } + public override string getExtraText() + { + return (m_sKwh != "" ? m_sKwh + "kWh" : ""); + } + public override string getStatusText() { - return (state ? "On" : "Off"); + return (status ? "On" : "Off"); } } } Modified: trunk/plugins/VeraControl/DeviceTemperature.cs =================================================================== --- trunk/plugins/VeraControl/DeviceTemperature.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DeviceTemperature.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -18,8 +18,8 @@ /// </summary> public class DeviceTemperature : DeviceGeneric { - public int m_iLevel; - private bool m_bMetric = true; + public string m_sTemp = "0"; // public thermostat class + private bool m_bMetric = true; public DeviceTemperature( XmlNode xn, bool bMetric ): base (xn) { @@ -32,13 +32,13 @@ public override bool update(XmlNode xn) { - m_iLevel = (xn.Attributes["temperature"] != null ? int.Parse(xn.Attributes["temperature"].Value) : 0); + m_sTemp = helper.getAttrAsString(xn, "temperature", m_sTemp); return base.update(xn); } public override int level { - get { return m_iLevel; } + get { return int.Parse(m_sTemp); } set { } } @@ -66,7 +66,7 @@ public override string getStatusText() { - return level + (m_bMetric ? "°C" : "F"); + return m_sTemp + (m_bMetric ? "°C" : "°F"); } } Modified: trunk/plugins/VeraControl/DeviceThermostat.cs =================================================================== --- trunk/plugins/VeraControl/DeviceThermostat.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DeviceThermostat.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -18,10 +18,10 @@ /// </summary> public class DeviceThermostat : DeviceTemperature { - private bool m_bMetric = true; - private string m_sFan = ""; - private string m_sState = "Off"; // "Off', "Idle", "Heating", "Cooling", "FanOnly", "PendingHeat", "PendingCool", "Vent" - private string m_sMode = "Off"; // "Off', "InDeadBand", "HeatOn", "CoolOn", "AutoChangeOver", "AuxHeatOn", "EconomyHeatOn", "EmergencyHeatOn", + private bool m_bMetric = true; + private string m_sFanMode = ""; + private string m_sHvacState = "Off"; // "Off', "Idle", "Heating", "Cooling", "FanOnly", "PendingHeat", "PendingCool", "Vent" + private string m_sMode = "Off"; // "Off', "InDeadBand", "HeatOn", "CoolOn", "AutoChangeOver", "AuxHeatOn", "EconomyHeatOn", "EmergencyHeatOn", // "AuxCoolOn", "EconomyCoolOn", "BuildingProtection", "EnergySavingsHeating", "EnergySavingsCooling" public DeviceThermostat( XmlNode xn, bool bMetric ): base (xn, bMetric) @@ -35,14 +35,14 @@ public override bool update(XmlNode xn) { - m_iLevel = (xn.Attributes["temperature"] != null ? int.Parse(xn.Attributes["temperature"].Value) : 0); - m_sFan = (xn.Attributes["fan"] != null ? xn.Attributes["fn"].Value : "Off"); - m_sState = (xn.Attributes["hvacstate"] != null ? xn.Attributes["hvacstate"].Value : "Off"); - m_sMode = (xn.Attributes["mode"] != null ? xn.Attributes["mode"].Value : "Off"); + m_sTemp = helper.getAttrAsString(xn, "temperature", m_sTemp); + m_sFanMode = helper.getAttrAsString(xn, "fanmode", m_sFanMode); + m_sHvacState = helper.getAttrAsString(xn, "hvacstate", m_sHvacState); + m_sMode = helper.getAttrAsString(xn, "mode", m_sMode); return base.update(xn); } - public override bool state + public override bool status { get { return (mode != "Off"); } set { mode = (value ? "Auto" : "Off"); } @@ -58,13 +58,15 @@ { get { return m_sMode; } set { - VeraCommunication vera = VeraCommunication.Instance; - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:upnp-org:serviceId:HVAC_UserOperatingMode1&action=SetModeTarget" + - "&NewModeTarget="+(value == "Off" ? "Off" : (value == "Cool" ? "CoolOn" : (value == "Heat" ? "HeatOn" : "AutoChangeOver")) - ); - string sResult = vera.doVeraRequest(cmd); + if (id > 0) // Only send when a valid ID is found + { + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:upnp-org:serviceId:HVAC_UserOperatingMode1&action=SetModeTarget" + + "&NewModeTarget="+(value == "Off" ? "Off" : (value == "Cool" ? "CoolOn" : (value == "Heat" ? "HeatOn" : "AutoChangeOver")) + ); + vera.doVeraRequest(cmd); + } m_sMode = value; } } @@ -93,7 +95,7 @@ public override string getExtraText() { - return m_sState + " - Fan : " + m_sFan + " - " + m_iLevel + (m_bMetric ? "°C" : "F") ; + return m_sHvacState + " - Fan : " + m_sFanMode + " - " + m_sTemp + (m_bMetric ? "°C" : "°F") ; } public override string getIconName() Modified: trunk/plugins/VeraControl/DialogActionTrigger.cs =================================================================== --- trunk/plugins/VeraControl/DialogActionTrigger.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DialogActionTrigger.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -65,6 +65,8 @@ [SkinControlAttribute(52)] protected GUISpinButton spMPExit = null; + private VeraCommunication vera = VeraCommunication.Instance; + public DialogActionTrigger() { GetID = (int)1974; @@ -89,7 +91,7 @@ // (P)re load spin contor for (int i = 0; i < spinList.Length; i++) { - initSpinButtons(spinList[i], VeraCommunication.Instance.actionTriggerTable[i]); + initSpinButtons(spinList[i], vera.actionTriggerTable[i]); } lblHeading.Label = strLine; @@ -97,13 +99,6 @@ public override bool Init() { - using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) - { - for (Actiontrigger i = 0; i < Actiontrigger.LAST_ACTIONTRIGGER; i++) - { - VeraCommunication.Instance.actionTriggerTable[(int)i] = xmlreader.GetValueAsInt("veracontroller", i.ToString(), 0); - } - } return Load(GUIGraphicsContext.Skin + @"\VeraDialogActionTrigger.xml"); } @@ -128,10 +123,10 @@ int iSceneIndex = 0; spin.AddSpinLabel("- none -", 0); - for (int i = 0; i < VeraCommunication.Instance.scenes.Count; i++) + for (int i = 0; i < vera.scenes.Count; i++) { - spin.AddSpinLabel(shortString(VeraCommunication.Instance.scenes[i].name), VeraCommunication.Instance.scenes[i].id); - if (VeraCommunication.Instance.scenes[i].id == iSelectedScene) + spin.AddSpinLabel(shortString(vera.scenes[i].name), vera.scenes[i].id); + if (vera.scenes[i].id == iSelectedScene) { iSceneIndex = i + 1; // 0 is - none - } @@ -164,11 +159,11 @@ for (int i = 0; i < spinList.Length; i++) { if (spinList[i].SpinValue == 0) { - VeraCommunication.Instance.actionTriggerTable[i] = 0; + vera.actionTriggerTable[i] = 0; } else { - VeraCommunication.Instance.actionTriggerTable[i] = VeraCommunication.Instance.scenes[spinList[i].SpinValue - 1].id; + vera.actionTriggerTable[i] = vera.scenes[spinList[i].SpinValue - 1].id; } - xmlwritter.SetValue("veracontroller", ((Actiontrigger) i).ToString(), VeraCommunication.Instance.actionTriggerTable[i].ToString()); + xmlwritter.SetValue("veracontroller", ((Actiontrigger) i).ToString(), vera.actionTriggerTable[i].ToString()); } } } Modified: trunk/plugins/VeraControl/DialogDeviceControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -41,7 +41,9 @@ [SkinControl(13)] protected GUIButtonControl btnMode2 = null; [SkinControl(14)] protected GUIButtonControl btnMode3 = null; [SkinControl(15)] protected GUISliderControl slider = null; + [SkinControl(20)] protected GUIImage camImage = null; + DeviceGeneric myDev = null; public DialogDeviceControl() @@ -183,6 +185,17 @@ } } + public void SetCamImage(string url) + { + + camImage.Dispose(); + camImage.SetFileName(url); + camImage.AllocResources(); + camImage.KeepAspectRatio = true; + camImage.Visibility = System.Windows.Visibility.Visible; + imgLogo.Visibility = System.Windows.Visibility.Hidden; + } + public void SetImage(string filename) { imgLogo.Dispose(); Modified: trunk/plugins/VeraControl/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -16,7 +16,7 @@ [assembly: AssemblyProduct("VeraControl")] [assembly: AssemblyCopyright("Copyright 2012")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("ba...@ev...")] +[assembly: AssemblyCulture("")] // This sets the default COM visibility of types in the assembly to invisible. // If you need to expose a type to COM, use [ComVisible(true)] on that type. Modified: trunk/plugins/VeraControl/Room.cs =================================================================== --- trunk/plugins/VeraControl/Room.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/Room.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -20,25 +20,40 @@ { public Room(XmlNode xn) { - if (xn == null) + if (xn != null) { - m_sName = ""; - m_iId = 0; - m_iSection = 0; - } else { update(xn); } } - private string m_sName; - private int m_iId; - private int m_iSection; + public VeraHelper helper = VeraHelper.Instance; + public VeraCommunication vera = VeraCommunication.Instance; + private string m_sName = "unknown room"; + private int m_iId = 0; + private int m_iSection = 0; + public bool update(XmlNode xn) { - m_sName = xn.Attributes["name"].Value; - m_iId = int.Parse(xn.Attributes["id"].Value); - m_iSection = int.Parse(xn.Attributes["section"].Value); + m_sName = helper.getAttrAsString(xn, "name", m_sName); + m_iId = helper.getAttrAsInt (xn, "id", m_iId); + m_iSection = helper.getAttrAsInt (xn, "section", m_iSection); + + if (m_iId == 0) + { + // void room no further processing needed + return true; + } + // Make sure room exists + if (m_iSection == 0 || !vera.status.isSectionFound(m_iSection)) + { + if (!vera.status.isSectionFound(0)) + { // create dummy room to attach to + vera.sections.Add(new Section(null)); + } + m_iSection = 0; + } + return true; } Modified: trunk/plugins/VeraControl/Scene.cs =================================================================== --- trunk/plugins/VeraControl/Scene.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/Scene.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -10,6 +10,7 @@ */ using System; using System.Xml; +using VeraControl; namespace VeraControl.Properties { @@ -20,28 +21,32 @@ { public Scene(XmlNode xn) { - if (xn == null) + if (xn != null) { - m_sName = ""; - m_iId = 0; - m_bActive = false; - m_iRoom = 0; - } else { update(xn); } } + public VeraHelper helper = VeraHelper.Instance; - private string m_sName; - private int m_iId; - private bool m_bActive; - private int m_iRoom; + private string m_sName = "unknown scene"; + private int m_iId = 0; + private bool m_bActive = false; + private int m_iRoom = 0; + // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) + private string m_sComment = ""; // red(error), green(success) or blue(pending) - icon/text + private DevState m_dsState = DevState.NONE; + public bool update(XmlNode xn) { - m_sName = xn.Attributes["name"].Value; - m_iId = int.Parse(xn.Attributes["id"].Value); - m_iRoom = int.Parse(xn.Attributes["room"].Value); - m_bActive = (xn.Attributes["name"].Value == "1"); + m_sName = helper.getAttrAsString(xn, "name", m_sName); + m_iId = helper.getAttrAsInt (xn, "id", m_iId); + m_iRoom = helper.getAttrAsInt (xn, "room", m_iRoom); + m_bActive = helper.getAttrAsBool (xn, "active", m_bActive); + + m_sComment = helper.getAttrAsString(xn, "comment", m_sComment ); + m_dsState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1)); + return true; } @@ -56,7 +61,17 @@ get { return m_sName; } set { } } - + + public virtual DevState commstate + { + get { return m_dsState; } + set { } + } + public virtual string comment + { + get { return (commstate != DevState.NONE ? m_sComment : ""); } + set { } + } public bool isActive() { Modified: trunk/plugins/VeraControl/Section.cs =================================================================== --- trunk/plugins/VeraControl/Section.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/Section.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -20,22 +20,21 @@ { public Section(XmlNode xn) { - if (xn == null) + if (xn != null) { - m_sName = ""; - m_iId = 0; - } else { update(xn); } } - private string m_sName; - private int m_iId; + public VeraHelper helper = VeraHelper.Instance; + private string m_sName = "unknown section"; + private int m_iId = 0; + public bool update(XmlNode xn) { - m_sName = xn.Attributes["name"].Value; - m_iId = int.Parse(xn.Attributes["id"].Value); + m_sName = helper.getAttrAsString(xn, "name", m_sName); + m_iId = helper.getAttrAsInt (xn, "id", m_iId); return true; } Modified: trunk/plugins/VeraControl/VeraCommunication.cs =================================================================== --- trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -166,17 +166,20 @@ private static volatile VeraCommunication instance; private static object syncRoot = new Object(); - private string m_sVeraIPAddress; - private string m_sVeraTCPIPPort; - private string m_sDataVersion = ""; - private bool m_bMetric = true; + private string m_sVeraIPAddress; + private string m_sVeraTCPIPPort; + private string m_sDataVersion = ""; + private bool m_bMetric = true; + private DevState m_dsVeraState = DevState.NONE; + private string m_sComment = ""; private VeraStatus m_status = new VeraStatus(); private long m_lLastUpdate = 0; private bool m_bUpdatePending = false; public int[] actionTriggerTable = new int[(int)Actiontrigger.LAST_ACTIONTRIGGER]; - + private VeraHelper helper = VeraHelper.Instance; + public static VeraCommunication Instance { get @@ -202,12 +205,16 @@ { m_sVeraIPAddress = xmlreader.GetValueAsString("veracontroller", "ipaddress", "127.0.0.1"); m_sVeraTCPIPPort = xmlreader.GetValueAsString("veracontroller", "portnumber", "49451"); + m_sVeraIPAddress = "192.10.1.240"; + // m_sVeraIPAddress = "demo.mios.com"; + m_sVeraTCPIPPort = "3480"; + + // Fill action table (config settings) + for (Actiontrigger i = 0; i < Actiontrigger.LAST_ACTIONTRIGGER; i++) + { + actionTriggerTable[(int)i] = xmlreader.GetValueAsInt("veracontroller", i.ToString(), 0); + } } - // Clear action table (TO DO: load with config settings) - for (int i = 0; i < (int)Actiontrigger.LAST_ACTIONTRIGGER; i++) - { - actionTriggerTable[i] = 0; - } } public bool updateCurrentStatus() @@ -218,16 +225,18 @@ } m_bUpdatePending = true; string verastatus = doVeraRequest("?id=lu_sdata&output_format=xml"); - m_lLastUpdate = getSecondSince1970(); + m_lLastUpdate = getSecondsSince1970(); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(verastatus); // Parse header - XmlNode rootnode = xmlDoc.SelectSingleNode("/root"); - m_bMetric = (rootnode.Attributes["temperature"].Value == "C"); - bool bFullRefresh = (m_sDataVersion != rootnode.Attributes["dataversion"].Value); - m_sDataVersion = rootnode.Attributes["dataversion"].Value; + XmlNode rootnode = xmlDoc.SelectSingleNode("/root"); + m_bMetric = (helper.getAttrAsString(rootnode, "temperature", "C") == "C"); + bool bFullRefresh = helper.getAttrAsBool (rootnode, "full", true); + m_sDataVersion = helper.getAttrAsString (rootnode, "dataversion", "0"); + m_sComment = helper.getAttrAsString (rootnode, "comment", ""); + m_dsVeraState = helper.toDevState(helper.getAttrAsInt(rootnode, "state", -1)); if (bFullRefresh) { @@ -247,6 +256,18 @@ } } + // Process Rooms + xnList = xmlDoc.SelectNodes("/root/rooms/room"); + foreach (XmlNode xn in xnList) + { + Room room = m_status.getRoomById( int.Parse(xn.Attributes["id"].Value) ); + if (room.id != 0) { + room.update(xn); + } else { + m_status.rooms.Add(new Room(xn)); + } + } + // Process Scenes xnList = xmlDoc.SelectNodes("/root/scenes/scene"); foreach (XmlNode xn in xnList) @@ -259,17 +280,6 @@ } } - // Process Rooms - xnList = xmlDoc.SelectNodes("/root/rooms/room"); - foreach (XmlNode xn in xnList) - { - Room room = m_status.getRoomById( int.Parse(xn.Attributes["id"].Value) ); - if (room.id != 0) { - room.update(xn); - } else { - m_status.rooms.Add(new Room(xn)); - } - } // Process Categories xnList = xmlDoc.SelectNodes("/root/categories/categorie"); @@ -293,6 +303,10 @@ } else { switch (xn.Attributes["category"].Value) { + //case "1": + // m_status.devices.Add(new DeviceInterface(xn)); + // break; + case "2": m_status.devices.Add(new DeviceDimmer(xn)); break; @@ -311,9 +325,9 @@ m_status.devices.Add(new DeviceThermostat(xn, m_bMetric)); break; - // case "6": // TODO: Implement camera class ? - // m_status.devices.Add(new DeviceCamera(xn, m_bMetric)); - // break; + case "6": + m_status.devices.Add(new DeviceCam(xn)); + break; case "7": m_status.devices.Add(new DeviceDoorlock(xn)); @@ -323,9 +337,9 @@ m_status.devices.Add(new DeviceWindowCovering(xn)); break; - // case "14": // TODO: Implement Scene controller device ? - // m_status.devices.Add(new DeviceSceneController(xn)); - // break; + case "14": + m_status.devices.Add(new DeviceSceneController(xn)); + break; // case "15": // TODO: Implement AV device ? // m_status.devices.Add(new DeviceSensor(xn)); @@ -350,7 +364,7 @@ case "0": default: // Check for Google Weather Device - if (xn.Attributes["WindCondition"] != null) + if (xn.Attributes["WindCondition"] != null || xn.Attributes["windcondition"] != null) { m_status.devices.Add(new DeviceGWeather(xn)); break; @@ -368,7 +382,7 @@ } } // update timer again (took some time to get the data) - m_lLastUpdate = getSecondSince1970(); + m_lLastUpdate = getSecondsSince1970(); m_bUpdatePending = false; return bFullRefresh; } @@ -385,7 +399,8 @@ public string doVeraRequest( string param ) { - return retrieveURL("http://" + m_sVeraIPAddress + ":" + m_sVeraTCPIPPort + "/data_request" + param + "&time="+DateTime.Now.Ticks); + + return retrieveURL("http://" + vera_Address + "/data_request" + param + "&time="+DateTime.Now.Ticks); } private string retrieveURL( string url ) @@ -410,14 +425,14 @@ return response; } - private long getSecondSince1970() + private long getSecondsSince1970() { return (DateTime.Now.Ticks / 10000000); } public long secondsSinceLastUpdate { - get { return (getSecondSince1970() - m_lLastUpdate); } + get { return (getSecondsSince1970() - m_lLastUpdate); } set { } } Modified: trunk/plugins/VeraControl/VeraControl.cs =================================================================== --- trunk/plugins/VeraControl/VeraControl.cs 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/VeraControl.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -1,6 +1,6 @@ /* * Created by SharpDevelop. - * User: Bart Everrsdijk + * User: Bart * Date: 21-12-2011 * Time: 21:20 * @@ -444,9 +444,9 @@ //Store last action - never send the same action twice... iLastAction = action; - if ((VeraCommunication.Instance.actionTriggerTable[(int)action] > 0) && (VeraCommunication.Instance.actionTriggerTable[(int)action] < Int16.MaxValue)) + if ((vera.actionTriggerTable[(int)action] > 0) && (vera.actionTriggerTable[(int)action] < Int16.MaxValue)) { - Scene scene = vera.status.getSceneById(VeraCommunication.Instance.actionTriggerTable[(int)action]); + Scene scene = vera.status.getSceneById(vera.actionTriggerTable[(int)action]); if (scene.id > 0) { scene.run(); @@ -683,25 +683,30 @@ if (dev.GetType() == typeof(DeviceSprinkler)) { dlg.SetText(dev.name, dev.getStatusText() + " - " + dev.mode, dev.getExtraText() ); - dlg.SetActiveBut((dev.state ? 1 : 0), (dev.mode == "Auto" ? 0 : (dev.mode == "Block" ? 2 : 1) )); + dlg.SetActiveBut((dev.status ? 1 : 0), (dev.mode == "Auto" ? 0 : (dev.mode == "Block" ? 2 : 1) )); } else if (dev.GetType() == typeof(DeviceThermostat)) { dlg.SetText(dev.name, dev.getStatusText(), dev.getExtraText() ); - dlg.SetActiveBut((dev.state ? 1 : 0), (dev.mode == "Auto" ? 0 : + dlg.SetActiveBut((dev.status ? 1 : 0), (dev.mode == "Auto" ? 0 : (dev.mode == "CoolOn" || dev.mode == "Cool" ? 1 : (dev.mode == "HeatOn" || dev.mode == "Heat" ? 2 : 3) ))); - } + } else { dlg.SetText(dev.name, "", ""); - dlg.SetActiveBut(dev.state ? 1 : 0, -1); + dlg.SetActiveBut(dev.status ? 1 : 0, -1); } dlg.SetButtons(dev.getCommands()); dlg.SetSlider(dev.level, dev.maxLevel); } else { + if (dev.GetType() == typeof(DeviceCam)) + { + DeviceCam cam = (DeviceCam) dev; + dlg.SetCamImage(cam.imgUrl); + } dlg.SetText(dev.name, dev.getStatusText(), dev.getExtraText()); } dlg.DoModal(GUIWindowManager.ActiveWindow); Modified: trunk/plugins/VeraControl/VeraControl.csproj =================================================================== --- trunk/plugins/VeraControl/VeraControl.csproj 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/VeraControl.csproj 2012-01-08 19:33:34 UTC (rev 4394) @@ -84,6 +84,7 @@ </ItemGroup> <ItemGroup> <Compile Include="DevCategories.cs" /> + <Compile Include="DeviceCam.cs" /> <Compile Include="DeviceDimmer.cs" /> <Compile Include="DeviceDoorlock.cs" /> <Compile Include="DeviceGeneric.cs" /> @@ -91,6 +92,7 @@ <Compile Include="DeviceHumidity.cs" /> <Compile Include="DeviceLightSensor.cs" /> <Compile Include="DevicePowerMeter.cs" /> + <Compile Include="DeviceSceneController.cs" /> <Compile Include="DeviceSecurity.cs" /> <Compile Include="DeviceSprinkler.cs" /> <Compile Include="DeviceSwitch.cs" /> @@ -105,6 +107,7 @@ <Compile Include="Scene.cs" /> <Compile Include="Section.cs" /> <Compile Include="VeraCommunication.cs" /> + <Compile Include="VeraHelper.cs" /> <Compile Include="VeraSetupForm.cs" /> <Compile Include="VeraSetupForm.Designer.cs"> <DependentUpon>VeraSetupForm.cs</DependentUpon> Added: trunk/plugins/VeraControl/VeraHelper.cs =================================================================== --- trunk/plugins/VeraControl/VeraHelper.cs (rev 0) +++ trunk/plugins/VeraControl/VeraHelper.cs 2012-01-08 19:33:34 UTC (rev 4394) @@ -0,0 +1,104 @@ +/* + * Created by SharpDevelop. + * User: Bart + * Date: 7-1-2012 + * Time: 12:07 + * + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller + * E-mail: ba...@ev... + */ +using System; +using System.Xml; + +namespace VeraControl.Properties +{ + + public enum DevState + { + NONE = 0, + PENDING, + SUCCESS, + ERROR + } + + /// <summary> + /// Description of VeraHelper. + /// </summary> + public class VeraHelper + { + public VeraHelper() + { + } + + private static volatile VeraHelper instance; + private static object syncRoot = new Object(); + + public static VeraHelper Instance + { + get + { + if (instance == null) + { + lock (syncRoot) + { + if (instance == null) + { + instance = new VeraHelper(); + } + } + } + + return instance; + } + } + + public DevState toDevState (int iRawState) + { // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) + switch (iRawState) + { + case -1: + return DevState.NONE; + case 0: + case 1: + case 5: + case 6: + return DevState.PENDING; + case 4: + return DevState.SUCCESS; + case 2: + case 3: + default: + return DevState.ERROR; + } + } + + public int getAttrAsInt(XmlNode xn, string key, int iDefault) + { + if (xn == null || xn.Attributes[key] == null) + { + return iDefault; + } + return int.Parse(xn.Attributes[key].Value); + } + + public bool getAttrAsBool(XmlNode xn, string key, bool bDefault) + { + if (xn == null || xn.Attributes[key] == null) + { + return bDefault; + } + string value = xn.Attributes[key].Value.ToLower(); + return (value == "true" || value == "1" || value == "yes"); + } + + public string getAttrAsString(XmlNode xn, string key, string sDefault) + { + if (xn == null || xn.Attributes[key] == null) + { + return sDefault; + } + return xn.Attributes[key].Value; + } + } +} Modified: trunk/plugins/VeraControl/skin/Default/VeraControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/Default/VeraControl.xml 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/skin/Default/VeraControl.xml 2012-01-08 19:33:34 UTC (rev 4394) @@ -104,7 +104,7 @@ <id>40</id> <posX>30</posX> <posY>85</posY> - <height>200</height> + <height>300</height> <width>250</width> <onup>20</onup> <ondown>70</ondown> @@ -147,7 +147,7 @@ <id>50</id> <posX>300</posX> <posY>55</posY> - <height>400</height> + <height>460</height> <width>300</width> <onleft>40</onleft> <onright>60</onright> Modified: trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml 2012-01-08 19:33:34 UTC (rev 4394) @@ -64,7 +64,7 @@ <type>label</type> <id>6</id> <posX>180</posX> - <posY>150</posY> + <posY>130</posY> <label>Dit is een label!!!</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -215,6 +215,17 @@ <animation effect="fade" time="250">visiblechange</animation> <animation effect="fade" time="250">windowopen</animation> </control> - + + <control> + <type>image</type> + <id>20</id> + <posX>240</posX> + <posY>160</posY> + <width>600</width> + <height>240</height> + <texture></texture> + <visible>no</visible> + </control> + </controls> </window> Modified: trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml 2012-01-08 19:32:04 UTC (rev 4393) +++ trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml 2012-01-08 19:33:34 UTC (rev 4394) @@ -216,6 +216,17 @@ <animation effect="fade" time="250">visiblechange</animation> <animation effect="fade" time="250">windowopen</animation> </control> - + + <control> + <type>image</type> + <id>20</id> + <posX>450</posX> + <posY>200</posY> + <width>600</width> + <height>300</height> + <texture></texture> + <visible>no</visible> + </control> + </controls> </window> Added: trunk/plugins/VeraControl/skin/Media/Vera/Ip_Camera.png =================================================================== (Binary files differ) Property changes on: trunk/plugins/VeraControl/skin/Media/Vera/Ip_Camera.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/VeraControl/skin/Media/Vera/location.png =================================================================== (Binary files differ) Property changes on: trunk/plugins/VeraControl/skin/Media/Vera/location.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ba...@us...> - 2012-01-08 22:16:54
|
Revision: 4398 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4398&view=rev Author: BartEv Date: 2012-01-08 22:16:47 +0000 (Sun, 08 Jan 2012) Log Message: ----------- Modified Paths: -------------- trunk/plugins/VeraControl/VeraCommunication.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/VeraSetupForm.Designer.cs trunk/plugins/VeraControl/VeraSetupForm.cs Modified: trunk/plugins/VeraControl/VeraCommunication.cs =================================================================== --- trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-08 21:54:57 UTC (rev 4397) +++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-08 22:16:47 UTC (rev 4398) @@ -204,10 +204,10 @@ using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { m_sVeraIPAddress = xmlreader.GetValueAsString("veracontroller", "ipaddress", "127.0.0.1"); - m_sVeraTCPIPPort = xmlreader.GetValueAsString("veracontroller", "portnumber", "49451"); - m_sVeraIPAddress = "192.10.1.240"; + m_sVeraTCPIPPort = xmlreader.GetValueAsString("veracontroller", "portnumber", "3480"); + //m_sVeraIPAddress = "192.10.1.240"; // m_sVeraIPAddress = "demo.mios.com"; - m_sVeraTCPIPPort = "3480"; + // m_sVeraTCPIPPort = "3480"; // Fill action table (config settings) for (Actiontrigger i = 0; i < Actiontrigger.LAST_ACTIONTRIGGER; i++) @@ -397,9 +397,15 @@ return response; } + public bool isVeraAlive(string ip, string port) + { + string response = retrieveURL("http://" + ip + ":" + port + "/data_request?id=lu_alive&time="+DateTime.Now.Ticks); + + return (response == "OK"); + } + public string doVeraRequest( string param ) { - return retrieveURL("http://" + vera_Address + "/data_request" + param + "&time="+DateTime.Now.Ticks); } @@ -425,7 +431,7 @@ return response; } - private long getSecondsSince1970() + public long getSecondsSince1970() { return (DateTime.Now.Ticks / 10000000); } @@ -480,7 +486,7 @@ public string vera_Address { - get { return m_sVeraIPAddress + " : " +m_sVeraTCPIPPort; } + get { return m_sVeraIPAddress + ":" +m_sVeraTCPIPPort; } set { } } } Modified: trunk/plugins/VeraControl/VeraControl.cs =================================================================== --- trunk/plugins/VeraControl/VeraControl.cs 2012-01-08 21:54:57 UTC (rev 4397) +++ trunk/plugins/VeraControl/VeraControl.cs 2012-01-08 22:16:47 UTC (rev 4398) @@ -31,6 +31,10 @@ [assembly: UsesSubsystem("MP.SkinEngine")] [assembly: UsesSubsystem("MP.Config")] +// TODO: support multiple Vera Box +// TODO: get all boxes for a specific user (http://sta1.mios.com/locator_json.php?username=<user>) +// TODO: support remote vera Boxes (http://fwd1.mios.com/<name>/<pass>/<serial>/data_request?...) + namespace VeraControl { public enum Actiontrigger Modified: trunk/plugins/VeraControl/VeraSetupForm.Designer.cs =================================================================== --- trunk/plugins/VeraControl/VeraSetupForm.Designer.cs 2012-01-08 21:54:57 UTC (rev 4397) +++ trunk/plugins/VeraControl/VeraSetupForm.Designer.cs 2012-01-08 22:16:47 UTC (rev 4398) @@ -33,6 +33,8 @@ this.labelIPaddress = new System.Windows.Forms.Label(); this.IPaddress = new System.Windows.Forms.TextBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.ConnectionResponse = new System.Windows.Forms.Label(); + this.CheckConnection = new System.Windows.Forms.Button(); this.labelPortNumber = new System.Windows.Forms.Label(); this.portnumber = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); @@ -46,7 +48,7 @@ // btnOK // this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnOK.Location = new System.Drawing.Point(31, 194); + this.btnOK.Location = new System.Drawing.Point(31, 236); this.btnOK.Name = "btnOK"; this.btnOK.Size = new System.Drawing.Size(75, 23); this.btnOK.TabIndex = 3; @@ -58,7 +60,7 @@ // this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(231, 194); + this.btnCancel.Location = new System.Drawing.Point(231, 236); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.TabIndex = 4; @@ -88,17 +90,36 @@ // // groupBox1 // + this.groupBox1.Controls.Add(this.ConnectionResponse); + this.groupBox1.Controls.Add(this.CheckConnection); this.groupBox1.Controls.Add(this.labelPortNumber); this.groupBox1.Controls.Add(this.portnumber); this.groupBox1.Controls.Add(this.labelIPaddress); this.groupBox1.Controls.Add(this.IPaddress); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(311, 78); + this.groupBox1.Size = new System.Drawing.Size(311, 121); this.groupBox1.TabIndex = 5; this.groupBox1.TabStop = false; this.groupBox1.Text = "Vera Box -setting"; // + // ConnectionResponse + // + this.ConnectionResponse.Location = new System.Drawing.Point(168, 88); + this.ConnectionResponse.Name = "ConnectionResponse"; + this.ConnectionResponse.Size = new System.Drawing.Size(123, 19); + this.ConnectionResponse.TabIndex = 7; + // + // CheckConnection + // + this.CheckConnection.Location = new System.Drawing.Point(19, 84); + this.CheckConnection.Name = "CheckConnection"; + this.CheckConnection.Size = new System.Drawing.Size(136, 23); + this.CheckConnection.TabIndex = 6; + this.CheckConnection.Text = "Check Connection"; + this.CheckConnection.UseVisualStyleBackColor = true; + this.CheckConnection.Click += new System.EventHandler(this.CheckConnection_Click); + // // labelPortNumber // this.labelPortNumber.AutoSize = true; @@ -118,7 +139,7 @@ this.portnumber.Name = "portnumber"; this.portnumber.Size = new System.Drawing.Size(205, 20); this.portnumber.TabIndex = 2; - this.portnumber.Text = "49451"; + this.portnumber.Text = "3480"; // // label1 // @@ -146,7 +167,7 @@ this.groupBox2.Controls.Add(this.enableSceneTrigger); this.groupBox2.Controls.Add(this.refreshdelay); this.groupBox2.Controls.Add(this.label1); - this.groupBox2.Location = new System.Drawing.Point(14, 96); + this.groupBox2.Location = new System.Drawing.Point(11, 139); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(309, 82); this.groupBox2.TabIndex = 8; @@ -168,7 +189,7 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(332, 229); + this.ClientSize = new System.Drawing.Size(332, 271); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Controls.Add(this.btnCancel); @@ -183,6 +204,8 @@ this.groupBox2.PerformLayout(); this.ResumeLayout(false); } + private System.Windows.Forms.Label ConnectionResponse; + private System.Windows.Forms.Button CheckConnection; private System.Windows.Forms.CheckBox enableSceneTrigger; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.TextBox refreshdelay; Modified: trunk/plugins/VeraControl/VeraSetupForm.cs =================================================================== --- trunk/plugins/VeraControl/VeraSetupForm.cs 2012-01-08 21:54:57 UTC (rev 4397) +++ trunk/plugins/VeraControl/VeraSetupForm.cs 2012-01-08 22:16:47 UTC (rev 4398) @@ -25,6 +25,8 @@ using MediaPortal.Configuration; using MediaPortal.UserInterface.Controls; using MediaPortal.Profile; +using VeraControl.Properties; +using System.Net; namespace MediaPortal.GUI.VeraSetupForm { @@ -70,5 +72,49 @@ Close(); } + + void CheckConnection_Click(object sender, EventArgs e) + { + ConnectionResponse.Text = "testing"; + ConnectionResponse.Update(); + + try { + WebClient webClient = new WebClient(); + + Uri url = new Uri("http://" + IPaddress.Text + ":" + portnumber.Text + "/data_request?id=lu_alive&time="+DateTime.Now.Ticks); + webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnAsyncCompletedEventArgs); + webClient.DownloadStringAsync(url); + + int cnt = 0; + long time = VeraCommunication.Instance.getSecondsSince1970(); + while (webClient.IsBusy) + { + if (time != VeraCommunication.Instance.getSecondsSince1970()) + { + cnt++; + time = VeraCommunication.Instance.getSecondsSince1970(); + ConnectionResponse.Text = "testing" + new string('.', cnt % 10); + ConnectionResponse.Update(); + } + } + } + catch + { + ConnectionResponse.Text = "Bad response"; + } + } + + void OnAsyncCompletedEventArgs(Object sender, DownloadStringCompletedEventArgs e) + { + //if (VeraCommunication.Instance.isVeraAlive(IPaddress.Text, portnumber.Text)) + if (!e.Cancelled && e.Error == null && (string)e.Result == "OK") + { + ConnectionResponse.Text = "- Ok -"; + } + else + { + ConnectionResponse.Text = "ERR: Time out"; + } + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ba...@us...> - 2012-01-15 23:50:27
|
Revision: 4405 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4405&view=rev Author: BartEv Date: 2012-01-15 23:50:18 +0000 (Sun, 15 Jan 2012) Log Message: ----------- Modified Paths: -------------- trunk/plugins/VeraControl/DeviceDimmer.cs trunk/plugins/VeraControl/DeviceGeneric.cs trunk/plugins/VeraControl/DialogDeviceControl.cs trunk/plugins/VeraControl/Properties/AssemblyInfo.cs trunk/plugins/VeraControl/Scene.cs trunk/plugins/VeraControl/VeraCommunication.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/VeraControl.csproj trunk/plugins/VeraControl/VeraHelper.cs trunk/plugins/VeraControl/VeraSetupForm.Designer.cs trunk/plugins/VeraControl/VeraSetupForm.cs trunk/plugins/VeraControl/releases/VeraControl.xmp2 trunk/plugins/VeraControl/releases/update.xml trunk/plugins/VeraControl/skin/Default/VeraControl.xml trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml Added Paths: ----------- trunk/plugins/VeraControl/DeviceCam.cs trunk/plugins/VeraControl/DeviceSceneController.cs trunk/plugins/VeraControl/DeviceSystem.cs trunk/plugins/VeraControl/DialogSceneControl.cs trunk/plugins/VeraControl/releases/VeraControl_v0.6.0.1.mpe1 trunk/plugins/VeraControl/skin/Default/VeraDialogSceneControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogSceneControl.xml trunk/plugins/VeraControl/skin/Media/Vera/IR_Transmitter.png trunk/plugins/VeraControl/skin/Media/Vera/USB_UIRT.png trunk/plugins/VeraControl/skin/Media/Vera/Zwave.png trunk/plugins/VeraControl/skin/Media/Vera/music_audio.png trunk/plugins/VeraControl/skin/Media/Vera/plugins.png trunk/plugins/VeraControl/skin/Media/Vera/users.png Added: trunk/plugins/VeraControl/DeviceCam.cs =================================================================== --- trunk/plugins/VeraControl/DeviceCam.cs (rev 0) +++ trunk/plugins/VeraControl/DeviceCam.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -0,0 +1,88 @@ +/* + * Created by SharpDevelop. + * User: Bart + * Date: 7-1-2012 + * Time: 21:42 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Xml; + +namespace VeraControl.Properties +{ + /// <summary> + /// Description of DeviceCam. + /// </summary> + public class DeviceCam : DeviceGeneric + { + private string m_sIp = "127.0.0.1"; + private string m_sUrl = "/"; + private string m_sStream = ""; + private string m_sVideoUrl = ""; + private int m_refresh = 10; + + public DeviceCam( XmlNode xn ): base (xn) + { + if (xn != null) + { + update(xn); + } + } + + public override bool update(XmlNode xn) + { + m_sIp = helper.getAttrAsString(xn, "ip", m_sIp); + m_sUrl = helper.getAttrAsString(xn, "url", m_sUrl); + m_sStream = helper.getAttrAsString(xn, "streaming", m_sStream); + m_sVideoUrl = helper.getAttrAsString(xn, "videourls", m_sVideoUrl); + + return base.update(xn); + } + + public string imgUrl + { + get { return "http://" + m_sIp + "/" + m_sUrl.Replace("%2F", "/"); } + set { } + } + + public int refreshRate + { + get { return m_refresh; } + set { m_refresh = value; } + } + + private bool refreshDelayPassed(long lastcheck) + { + return ((helper.getSecondsSince1970() - refreshRate) > (lastcheck / 10000000)); + } + + public override string getIconName() + { + return "Ip_Camera"; + } + + public override bool newScreenUpdateWaitingAndClearFlag( ) + { + // Invoking this method will clear the update ready flag -> so caller need to handle the update + // A cam device requires an update every refreshRate seconds + bool b = m_bScreenUpdateRequired || refreshDelayPassed(DateTime.Now.Ticks); + m_bScreenUpdateRequired = false; + if (b) + { + m_lLastUpdate = DateTime.Now.Ticks; + } + return b; + } + + public override bool newUpdateSince(long lTimePreviousCheck) + { + bool b = (lTimePreviousCheck <= m_lLastUpdate) || refreshDelayPassed(m_lLastUpdate); + if (b) + { + m_lLastUpdate = DateTime.Now.Ticks; + } + return b; + } + } +} Modified: trunk/plugins/VeraControl/DeviceDimmer.cs =================================================================== --- trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-14 17:51:27 UTC (rev 4404) +++ trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -57,14 +57,14 @@ { get { return m_iLevel; } set - { + { int newValue = value; if (newValue > 100) { newValue = 100; } else { if (newValue < 0) { newValue = 0; } } - if (id > 0) // Only send when a valid ID is found + if ((id > 0) && (newValue != m_iLevel)) // Only send when a valid ID is found { // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ @@ -97,9 +97,9 @@ { string leveltxt = "0"; if (level > 0) { leveltxt = "25"; } - if (level > 35) { leveltxt = "50"; } - if (level > 65) { leveltxt = "75"; } - if (level > 85) { leveltxt = "100"; } + if (level > 25) { leveltxt = "50"; } + if (level > 50) { leveltxt = "75"; } + if (level > 75) { leveltxt = "100"; } return "Dimmable_Light_"+leveltxt; } Modified: trunk/plugins/VeraControl/DeviceGeneric.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-14 17:51:27 UTC (rev 4404) +++ trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -21,11 +21,13 @@ /// </summary> public class DeviceGeneric { - private string m_sName = "unknown device"; - private int m_iId = 0; - private string m_sAltId = ""; - private int m_iCategory = 0; - private int m_iRoom = 0; + public long m_lLastUpdate = 0; + public bool m_bScreenUpdateRequired = false; + private string m_sName = "unknown device"; + private int m_iId = 0; + private string m_sAltId = ""; + private int m_iCategory = 0; + private int m_iRoom = 0; // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) private DevState m_dsState = DevState.NONE; @@ -56,7 +58,7 @@ if (m_iId == 0) { // void device no further processing needed - return true; + return false; } // Make sure room exists if (m_iRoom == 0 || !vera.status.isRoomFound(m_iRoom)) @@ -67,6 +69,11 @@ } m_iRoom = 0; } + + // Set update flag + m_bScreenUpdateRequired = true; + m_lLastUpdate = DateTime.Now.Ticks; + return true; } @@ -176,5 +183,18 @@ { return new string [] {"Off", "On"}; } + + public virtual bool newScreenUpdateWaitingAndClearFlag( ) + { + // Invoking this method will clear the update ready flag -> so caller need to handle the update + bool b = m_bScreenUpdateRequired; + m_bScreenUpdateRequired = false; + return b; + } + + public virtual bool newUpdateSince(long lTimePreviousCheck) + { + return (lTimePreviousCheck <= m_lLastUpdate); + } } } Added: trunk/plugins/VeraControl/DeviceSceneController.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSceneController.cs (rev 0) +++ trunk/plugins/VeraControl/DeviceSceneController.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -0,0 +1,70 @@ +/* + * Created by SharpDevelop. + * User: Bart + * Date: 8-1-2012 + * Time: 0:15 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Xml; + +namespace VeraControl.Properties +{ + /// <summary> + /// Description of DeviceSceneController. + /// </summary> + public class DeviceSceneController: DeviceGeneric + { + private bool m_bTripped = false; + + public DeviceSceneController( XmlNode xn ): base (xn) + { + if (xn != null) + { + update(xn); + } + } + + public override bool update(XmlNode xn) + { + m_bTripped = helper.getAttrAsBool(xn, "status", m_bTripped); + m_bTripped = helper.getAttrAsBool(xn, "tripped", m_bTripped); + return base.update(xn); + } + + public override bool status + { + get { return m_bTripped; } + set { } + } + + public bool tripped + { + get { return m_bTripped; } + set { } + } + + public override int level + { + get { return (m_bTripped ? 1 : 0); } + set { } + } + + public override string ToString() + { + return name + " [" + getStatusText() + "]"; + } + + public override string getIconName() + { + return "Motion_Sensor_" + (m_bTripped ? "100" : "0"); + } + + public override string getStatusText() + { + return (status ? "ACTIVE" : "standby"); + } + + } +} Added: trunk/plugins/VeraControl/DeviceSystem.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSystem.cs (rev 0) +++ trunk/plugins/VeraControl/DeviceSystem.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -0,0 +1,177 @@ +/* + * Created by SharpDevelop. + * User: Bart + * Date: 12-1-2012 + * Time: 10:32 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Xml; +// using VeraControl.Properties.Devstate; + +namespace VeraControl.Properties +{ + /// <summary> + /// Description of DeviceSystem. + /// </summary> + public class DeviceSystem + { + public DeviceSystem() + { + } + + public VeraHelper helper = VeraHelper.Instance; + + public long m_lLastUpdate = 0; + public bool m_bScreenUpdateRequired = false; + private bool m_bFullReload = true; + private string m_sVersion = ""; + private string m_sModel = ""; + private bool m_zWaveHeal = false; + private bool m_bMetric = true; + private string m_sSerial = ""; + private string m_sFwd1Server = ""; + private string m_sFwd2Server = ""; + private string m_sLoadTime = "0"; + private string m_sDataVersion = "0"; + private string m_sComment = ""; + private DevState m_dsVeraState = DevState.NONE; + + + public bool update(XmlNode xn) + { + m_bFullReload = helper.getAttrAsBool (xn, "full", m_bFullReload); + m_sVersion = helper.getAttrAsString (xn, "version", m_sVersion); + m_sModel = helper.getAttrAsString (xn, "model", m_sModel); + m_zWaveHeal = helper.getAttrAsBool (xn, "zwave_heal", m_zWaveHeal); + m_sSerial = helper.getAttrAsString (xn, "serial_number", m_sSerial); + m_sFwd1Server = helper.getAttrAsString (xn, "fwd1", m_sFwd1Server); + m_sFwd2Server = helper.getAttrAsString (xn, "fwd2", m_sFwd2Server); + m_sLoadTime = helper.getAttrAsString (xn, "loadtime", m_sLoadTime); + + // Set update flag + string tempDataversion = helper.getAttrAsString (xn, "dataversion", m_sDataVersion); + DevState tempVeraState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1)); + string tempComment = helper.getAttrAsString (xn, "comment", ""); + + if ((m_sDataVersion != tempDataversion) || m_sComment != tempComment || m_dsVeraState != tempVeraState) + { + m_bScreenUpdateRequired = true; + m_lLastUpdate = DateTime.Now.Ticks; + } + m_sDataVersion = tempDataversion; + m_dsVeraState = tempVeraState; + m_sComment = tempComment; + + m_dsVeraState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1)); + m_sComment = helper.getAttrAsString (xn, "comment", ""); + m_bMetric = (helper.getAttrAsString(xn, "temperature", "C") == "C"); + + return true; + } + + public void clearFullReloadFlag() + { + m_bFullReload = false; + } + + public void setFullReloadFlag() + { + m_bFullReload = true; + } + public bool fullReload + { + get { return m_bFullReload; } + set { } + } + + public string versionInfo + { + get { return m_sModel + " " + m_sVersion; } + set { } + } + + public bool bZWaveHeal + { + get { return m_zWaveHeal; } + set { } + } + + public string serialno + { + get { return m_sSerial; } + set { } + } + + public string fwd + { + get { return m_sFwd1Server; } + set { } + } + + public string fwdBackup + { + get { return m_sFwd2Server; } + set { } + } + + public string loadtime + { + get { return m_sLoadTime; } + set { } + } + + public string dataversion + { + get { return m_sDataVersion; } + set { } + } + + public DevState state + { + get { return m_dsVeraState; } + set { } + } + + public string comment + { + get { return m_sComment; } + set { } + } + + public void reportConnectionError( string errmsg ) + { + m_dsVeraState = DevState.CONNECTION_ERROR; + m_sComment = errmsg; + m_bScreenUpdateRequired = true; + m_lLastUpdate = DateTime.Now.Ticks; + } + + public void clearConnectionError( ) + { + m_dsVeraState = DevState.NONE; + m_sComment = ""; + m_bScreenUpdateRequired = true; + m_lLastUpdate = DateTime.Now.Ticks; + } + + public bool isMetric() + { + return m_bMetric; + } + + public bool newScreenUpdateWaitingAndClearFlag( ) + { + // Invoking this method will clear the update ready flag -> so caller need to handle the update + bool b = m_bScreenUpdateRequired; + m_bScreenUpdateRequired = false; + return b; + } + + public bool newUpdateSince(float fTimePreviousCheck) + { + return (fTimePreviousCheck <= m_lLastUpdate); + } + } +} Modified: trunk/plugins/VeraControl/DialogDeviceControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-14 17:51:27 UTC (rev 4404) +++ trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -4,8 +4,8 @@ * Date: 24-12-2011 * Time: 14:17 * - * Copyright: 2012 GPL - Bart Eversdijk - * MediaPort plugin - MicasaVerde (TM) Vera Controller + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller * E-mail: ba...@ev... */ using System; @@ -27,47 +27,100 @@ /// </summar`y> public class DialogDeviceControl : GUIDialogWindow { - [SkinControl(2)] protected GUIButtonControl btnClose = null; - [SkinControl(4)] protected GUILabelControl lblHeading = null; - [SkinControl(5)] protected GUIImage imgLogo = null; + [SkinControl(2)] protected GUIButtonControl btnClose = null; + [SkinControl(4)] protected GUILabelControl lblHeading = null; + [SkinControl(5)] protected GUIImage imgLogo = null; - [SkinControlAttribute(6)] protected GUILabelControl label1=null; + [SkinControlAttribute(6)] protected GUILabelControl label1=null; [SkinControlAttribute(7)] protected GUILabelControl label2=null; [SkinControlAttribute(8)] protected GUILabelControl label3=null; [SkinControl(10)] protected GUIButtonControl btnLeft = null; - [SkinControl(11)] protected GUIButtonControl btnRight = null; - [SkinControl(12)] protected GUIButtonControl btnMode1 = null; + [SkinControl(11)] protected GUIButtonControl btnRight = null; + [SkinControl(12)] protected GUIButtonControl btnMode1 = null; [SkinControl(13)] protected GUIButtonControl btnMode2 = null; [SkinControl(14)] protected GUIButtonControl btnMode3 = null; - [SkinControl(15)] protected GUISliderControl slider = null; - [SkinControl(20)] protected GUIImage camImage = null; - - - DeviceGeneric myDev = null; - + [SkinControl(15)] protected GUISliderControl slider = null; + [SkinControl(20)] protected GUIImage camImage = null; + + [SkinControl(30)] protected GUIImage cmtImage = null; + [SkinControlAttribute(31)] protected GUILabelControl comment=null; + + VeraHelper helper = new VeraHelper(); + private DeviceGeneric myDev = null; + private long m_iLastUpdate = 0; + public DialogDeviceControl() { GetID = (int)1973; } - public void InitDialog(string strLine, DeviceGeneric dev) - { - //LoadSkin(); - AllocResources(); - InitControls(); + public override bool Init() + { + bool bResult = Load(GUIGraphicsContext.Skin + @"\VeraDialogDeviceControl.xml"); + return bResult; + } - lblHeading.Label = strLine; - + + public void InitDialog(string strLine, DeviceGeneric dev) + { + //LoadSkin(); + AllocResources(); + InitControls(); + + lblHeading.Label = strLine; myDev = dev; + + if (!myDev.isControllable) + { + btnClose.SetNavigation(2,2,2,2); + } + + updateStatus(); } - - public override bool Init() - { - bool bResult = Load(GUIGraphicsContext.Skin + @"\VeraDialogDeviceControl.xml"); - return bResult; - } + public void updateStatus() + { + SetImage("Vera\\"+myDev.getIconName()+".png"); + + setComment(helper.getStateImage(myDev.commstate), myDev.comment); + + if (myDev.isControllable) + { + if (myDev.GetType() == typeof(DeviceSprinkler)) + { + SetText(myDev.name, myDev.getStatusText() + " - " + myDev.mode, myDev.getExtraText() ); + SetActiveBut((myDev.status ? 1 : 0), (myDev.mode == "Auto" ? 0 : (myDev.mode == "Block" ? 2 : 1) )); + } + else if (myDev.GetType() == typeof(DeviceThermostat)) + { + SetText(myDev.name, myDev.getStatusText(), myDev.getExtraText() ); + SetActiveBut((myDev.status ? 1 : 0), (myDev.mode == "Auto" ? 0 : + (myDev.mode == "CoolOn" || myDev.mode == "Cool" ? 1 : + (myDev.mode == "HeatOn" || myDev.mode == "Heat" ? 2 : 3) ))); + } + else + { + SetText(myDev.name, "", ""); + SetActiveBut(myDev.status ? 1 : 0, -1); + } + SetButtons(myDev.getCommands()); + SetSlider(myDev.level, myDev.maxLevel); + } + else + { + if (myDev.GetType() == typeof(DeviceCam)) + { + DeviceCam cam = (DeviceCam) myDev; + SetCamImage(cam.imgUrl); + } + SetText(myDev.name, myDev.getStatusText(), myDev.getExtraText()); + } + // save last update ticks + m_iLastUpdate = DateTime.Now.Ticks; + } + + protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (control == btnLeft) @@ -134,7 +187,7 @@ { btnLeft.NavigateUp = 12; btnRight.NavigateUp = 14; - + if (butTxt.Length < 5) { // if only 2 buttons required, use right iso middle button @@ -176,10 +229,10 @@ { btnMode1.TextColor = (iModeNr == 0 ? 0xFFFFFF00 : 0xFFFFFFFF ); btnMode1.TextColorNoFocus = (iModeNr == 0 ? 0x60FFFF00 : 0x60ffffff); - + btnMode2.TextColor = (iModeNr == 1 ? 0xFFFFFF00 : 0xFFFFFFFF ); btnMode2.TextColorNoFocus = (iModeNr == 1 ? 0x60FFFF00 : 0x60ffffff); - + btnMode3.TextColor = (iModeNr == 2 ? 0xFFFFFF00 : 0xFFFFFFFF ); btnMode3.TextColorNoFocus = (iModeNr == 2 ? 0x60FFFF00 : 0x60ffffff); } @@ -203,5 +256,29 @@ imgLogo.AllocResources(); imgLogo.KeepAspectRatio = true; } + + public void setComment(string img, string txt) + { + if (img != "") { + cmtImage.Dispose(); + cmtImage.SetFileName(img); + cmtImage.KeepAspectRatio = true; + cmtImage.Visibility = System.Windows.Visibility.Visible; + cmtImage.AllocResources(); + } else{ + cmtImage.Visibility = System.Windows.Visibility.Hidden; + } + comment.Label = txt; + } + + public override void Render(float timePassed) + { + if (myDev.newUpdateSince(m_iLastUpdate)) + { + updateStatus(); + } + + base.Render(timePassed); + } } } Added: trunk/plugins/VeraControl/DialogSceneControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogSceneControl.cs (rev 0) +++ trunk/plugins/VeraControl/DialogSceneControl.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -0,0 +1,120 @@ +/* + * Created by SharpDevelop. + * User: Bart + * Date: 24-12-2011 + * Time: 14:17 + * + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller + * E-mail: ba...@ev... + */ +using System; +using System.Collections; +using MediaPortal; +using MediaPortal.Util; +using MediaPortal.GUI.Library; +using MediaPortal.Dialogs; +using Alignment = MediaPortal.GUI.Library.GUIControl.Alignment; +using VAlignment = MediaPortal.GUI.Library.GUIControl.VAlignment; +using Action = MediaPortal.GUI.Library.Action; +using VeraControl.Properties; + +namespace VeraControl +{ + /// <summary> + /// Description of DialogDeviceControl. + /// </summar`y> + public class DialogSceneControl : GUIDialogWindow + { + [SkinControl(2)] protected GUIButtonControl btnClose = null; + [SkinControl(4)] protected GUILabelControl lblHeading = null; + [SkinControl(5)] protected GUIImage imgLogo = null; + + [SkinControlAttribute(6)] protected GUILabelControl label1=null; + + [SkinControl(11)] protected GUIButtonControl btnRight = null; + + [SkinControl(30)] protected GUIImage cmtImage = null; + [SkinControlAttribute(31)] protected GUILabelControl comment=null; + + VeraHelper helper = new VeraHelper(); + private Scene myScene = null; + private long m_iLastUpdate = 0; + + public DialogSceneControl() + { + GetID = (int)1975; + } + + public override bool Init() + { + bool bResult = Load(GUIGraphicsContext.Skin + @"\VeraDialogSceneControl.xml"); + return bResult; + } + + + public void InitDialog(string strLine, Scene scene) + { + //LoadSkin(); + AllocResources(); + InitControls(); + + lblHeading.Label = strLine; + myScene = scene; + + updateStatus(); + } + + public void updateStatus() + { + setComment(helper.getStateImage(myScene.commstate), myScene.comment); + + label1.Label = myScene.name; + + // save last update ticks + m_iLastUpdate = DateTime.Now.Ticks; + } + + protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) + { + if (control == btnRight) + { + if (myScene.id != 0) { + comment.Label = "Running..."; + myScene.run(); + + } + } + + // Back to the text button to switch from image view + if (control == btnClose) + { + PageDestroy(); + } + base.OnClicked(controlId, control, actionType); + } + + public void setComment(string img, string txt) + { + if (img != "") { + cmtImage.Dispose(); + cmtImage.SetFileName(img); + cmtImage.KeepAspectRatio = true; + cmtImage.Visibility = System.Windows.Visibility.Visible; + cmtImage.AllocResources(); + } else{ + cmtImage.Visibility = System.Windows.Visibility.Hidden; + } + comment.Label = txt; + } + + public override void Render(float timePassed) + { + if (myScene.newUpdateSince(m_iLastUpdate)) + { + updateStatus(); + } + base.Render(timePassed); + } + } +} Modified: trunk/plugins/VeraControl/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2012-01-14 17:51:27 UTC (rev 4404) +++ trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -28,4 +28,4 @@ // // You can specify all the values or you can use the default the Revision and // Build Numbers by using the '*' as shown below: -[assembly: AssemblyVersion("0.5.0.1")] +[assembly: AssemblyVersion("0.5.1.0")] Modified: trunk/plugins/VeraControl/Scene.cs =================================================================== --- trunk/plugins/VeraControl/Scene.cs 2012-01-14 17:51:27 UTC (rev 4404) +++ trunk/plugins/VeraControl/Scene.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -4,8 +4,8 @@ * Date: 22-12-2011 * Time: 13:50 * - * Copyright: 2012 GPL - Bart Eversdijk - * MediaPort plugin - MicasaVerde (TM) Vera Controller + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller * E-mail: ba...@ev... */ using System; @@ -28,11 +28,14 @@ } public VeraHelper helper = VeraHelper.Instance; + private bool m_bScreenUpdateRequired = false; private string m_sName = "unknown scene"; private int m_iId = 0; private bool m_bActive = false; private int m_iRoom = 0; + private long m_lLastUpdate = 0; + // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) private string m_sComment = ""; // red(error), green(success) or blue(pending) - icon/text private DevState m_dsState = DevState.NONE; @@ -47,6 +50,9 @@ m_sComment = helper.getAttrAsString(xn, "comment", m_sComment ); m_dsState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1)); + // Set update reqired flag + m_lLastUpdate = DateTime.Now.Ticks; + m_bScreenUpdateRequired = true; return true; } @@ -55,7 +61,7 @@ get { return m_iId; } set { } } - + public string name { get { return m_sName; } @@ -72,7 +78,7 @@ get { return (commstate != DevState.NONE ? m_sComment : ""); } set { } } - + public bool isActive() { return m_bActive; @@ -102,7 +108,25 @@ } VeraCommunication vera = VeraCommunication.Instance; string cmd = "?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum="+id; - return vera.doVeraRequest(cmd, true); + return vera.doVeraRequest(cmd); } + + public bool newScreenUpdateWaitingAndClearFlag( ) + { + // Invoking this method will clear the update ready flag -> so caller need to handle the update + bool b = m_bScreenUpdateRequired; + m_bScreenUpdateRequired = false; + if (m_dsState != DevState.NONE && (m_lLastUpdate < (DateTime.Now.Ticks - (10 * 10000000)))) + { + m_dsState = DevState.NONE; + return true; + } + return b; + } + + public virtual bool newUpdateSince(long lTimePreviousCheck) + { + return (lTimePreviousCheck <= m_lLastUpdate); + } } } Modified: trunk/plugins/VeraControl/VeraCommunication.cs =================================================================== --- trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-14 17:51:27 UTC (rev 4404) +++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -4,13 +4,14 @@ * Date: 21-12-2011 * Time: 22:26 * - * Copyright: 2012 GPL - Bart Eversdijk - * MediaPort plugin - MicasaVerde (TM) Vera Controller + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller * E-mail: ba...@ev... */ using System; using System.Net; using System.IO; +using System.Threading; using System.Collections.Generic; using System.Xml; @@ -22,6 +23,7 @@ public class VeraStatus { + public DeviceSystem system = new DeviceSystem(); public List<DeviceGeneric> devices = new List<DeviceGeneric>(); public List<Scene> scenes = new List<Scene>(); public List<Room> rooms = new List<Room>(); @@ -164,22 +166,29 @@ public sealed class VeraCommunication { private static volatile VeraCommunication instance; - private static object syncRoot = new Object(); + private static object syncRoot = new Object(); + private VeraHelper helper = VeraHelper.Instance; - private string m_sVeraIPAddress; - private string m_sVeraTCPIPPort; - private string m_sDataVersion = ""; - private bool m_bMetric = true; - private DevState m_dsVeraState = DevState.NONE; - private string m_sComment = ""; + // Config data + private string m_sVeraIPAddress; + private string m_sVeraTCPIPPort; + private int m_iMaxRefreshDelay; + + // Actual device information private VeraStatus m_status = new VeraStatus(); - private long m_lLastUpdate = 0; - private bool m_bUpdatePending = false; + // Communication status/control + private long m_lLastUpdate = 0; + private bool m_bUpdatePending = false; + private bool m_bScreenUpdateRequired = false; // Only true when a new update was received AND at least one device(staus) or scene was changed + private bool m_bLastUpdateFailed = false; + private string m_strLastUpdateError = ""; + private WebClient m_webClient = new WebClient(); + + // Action control table public int[] actionTriggerTable = new int[(int)Actiontrigger.LAST_ACTIONTRIGGER]; - private VeraHelper helper = VeraHelper.Instance; - + public static VeraCommunication Instance { get @@ -208,39 +217,132 @@ //m_sVeraIPAddress = "192.10.1.240"; // m_sVeraIPAddress = "demo.mios.com"; // m_sVeraTCPIPPort = "3480"; - + // Fill action table (config settings) for (Actiontrigger i = 0; i < Actiontrigger.LAST_ACTIONTRIGGER; i++) { actionTriggerTable[(int)i] = xmlreader.GetValueAsInt("veracontroller", i.ToString(), 0); } + m_iMaxRefreshDelay = int.Parse(xmlreader.GetValueAsString("veracontroller", "maxrefreshdelay", "60")); + + // Set DownloadStringCompleted handler + m_webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnAsyncCompletedEventArgs); } } - public bool updateCurrentStatus() + public void updateCurrentStatus(long lNow) { - if (m_bUpdatePending) + /* when to update in case connection gets lost --> keep updating with webClient timeout 180 sec....*/ + /* TODO: watch-dog !!! last time > 4 * maxDelay force an update - to recover from hibernate */ + if (m_bUpdatePending /* && m_lLastUpdate < ((lNow / 10000000) - (4 * m_iMaxRefreshDelay)) */) { - return false; + return; } + m_bUpdatePending = true; - string verastatus = doVeraRequest("?id=lu_sdata&output_format=xml"); - m_lLastUpdate = getSecondsSince1970(); + string url = "?id=lu_sdata&loadtime=" + m_status.system.loadtime + "&dataversion=" + m_status.system.dataversion + "&minimumdelay=2000&timeout=" + m_iMaxRefreshDelay + "&output_format=xml"; + doVeraRequest(url, OnAsyncCompletedEventArgs); + m_lLastUpdate = helper.getSecondsSince1970(); + } + + public bool isVeraAlive(string ip, string port) + { + string response = retrieveURL("http://" + ip + ":" + port + "/data_request?id=lu_alive&time="+DateTime.Now.Ticks); + return (response == "OK"); + } + + public string doVeraRequest(string param) + { + return retrieveURL("http://" + vera_Address + "/data_request" + param + "&time="+DateTime.Now.Ticks); + } + + public void doVeraRequest(string param, Action<object, DownloadStringCompletedEventArgs> onCallBack) + { + retrieveURLAsync("http://" + vera_Address + "/data_request" + param + "&time="+DateTime.Now.Ticks); + } + + private string retrieveURL(string url) + { + // No callback thus Synchronised call (wait for response) + try { + m_webClient.CancelAsync(); // Cancel any current pending Async calls... + return m_webClient.DownloadString(url); + } catch( Exception e ) + { + m_bLastUpdateFailed = true; + m_strLastUpdateError = e.Message; + return "ERROR"; + } + + } + + private void retrieveURLAsync(string url) + { + // Callback thus ASynchronised call (do NOT wait for response) + try { + m_webClient.CancelAsync(); // Cancel any current pending Async calls... + m_webClient.DownloadStringAsync(new Uri(url)); + } catch( Exception e ) + { + m_bLastUpdateFailed = true; + m_strLastUpdateError = e.Message; + } + } + + public void OnAsyncCompletedEventArgs(object sender, DownloadStringCompletedEventArgs e) + { + if (!e.Cancelled) + { + // Communication cancel for some reason, no valid data to be expected + if (e.Error != null) + { + // Handle error here + m_bLastUpdateFailed = true; + m_strLastUpdateError = e.Error.Message; + m_bScreenUpdateRequired = true; + } + else + { + ParseUpdateInfo(e.Result); + // ParseUpdateInfo(m_webClient.DownloadString(@"C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\testdata\text.xml")); + } + } + + // update timer again (took some time to get the data) + m_lLastUpdate = helper.getSecondsSince1970(); + m_bUpdatePending = false; + } + + public void ParseUpdateInfo(string veraresponse) + { var xmlDoc = new XmlDocument(); - xmlDoc.LoadXml(verastatus); - + xmlDoc.LoadXml(veraresponse); + // Parse header XmlNode rootnode = xmlDoc.SelectSingleNode("/root"); - m_bMetric = (helper.getAttrAsString(rootnode, "temperature", "C") == "C"); - bool bFullRefresh = helper.getAttrAsBool (rootnode, "full", true); - m_sDataVersion = helper.getAttrAsString (rootnode, "dataversion", "0"); - m_sComment = helper.getAttrAsString (rootnode, "comment", ""); - m_dsVeraState = helper.toDevState(helper.getAttrAsInt(rootnode, "state", -1)); + if (rootnode == null) + { + // not a status update, just return (might have been an Asynchrone sent command or start scene request) + return; + } - if (bFullRefresh) + if (!m_bScreenUpdateRequired) { - // We have a full refresh -> Clear all lists + // Clear flag, only when previous update was already handled + m_status.system.clearFullReloadFlag(); + } + if (m_bLastUpdateFailed) + { + m_bLastUpdateFailed = false; + m_bScreenUpdateRequired = true; + m_status.system.clearConnectionError(); + } + // Process system status first + m_status.system.update(rootnode); + if (m_status.system.fullReload) + { + // We have a full refresh -> Clear all lists (to get clear of removed devices) TODO: check/handle selected index when an item was deleted... m_status.clearAllLists(); } @@ -278,6 +380,9 @@ } else { m_status.scenes.Add(new Scene(xn)); } + + // At least one scene was found and thus changed + m_bScreenUpdateRequired = true; } @@ -292,20 +397,24 @@ m_status.categories.Add(new DevCategories(xn)); } } - + // Process Devices xnList = xmlDoc.SelectNodes("/root/devices/device"); foreach (XmlNode xn in xnList) { DeviceGeneric dev = m_status.getDeviceById( int.Parse(xn.Attributes["id"].Value) ); if (dev.id != 0) { + // update existing device dev.update(xn); } else { + m_status.system.setFullReloadFlag(); + + // catids: http://wiki.micasaverde.com/index.php/Luup_UPNP_Files switch (xn.Attributes["category"].Value) { - //case "1": - // m_status.devices.Add(new DeviceInterface(xn)); - // break; + //case "1": // TODO: Implement interface device ? + // m_status.devices.Add(new DeviceInterface(xn)); + // break; case "2": m_status.devices.Add(new DeviceDimmer(xn)); @@ -321,13 +430,13 @@ m_status.devices.Add(new DeviceSecurity(xn)); break; - case "5": - m_status.devices.Add(new DeviceThermostat(xn, m_bMetric)); - break; + case "5": + m_status.devices.Add(new DeviceThermostat(xn, m_status.system.isMetric())); + break; case "6": m_status.devices.Add(new DeviceCam(xn)); - break; + break; case "7": m_status.devices.Add(new DeviceDoorlock(xn)); @@ -336,31 +445,50 @@ case "8": m_status.devices.Add(new DeviceWindowCovering(xn)); break; - - case "14": + + //case "9": + // m_status.devices.Add(new DeviceRemoteControl(xn)); + // break; + + //case "10": + // m_status.devices.Add(new DeviceIrTx(xn)); + // break; + + //case "13": + // m_status.devices.Add(new DeviceSerialPort(xn)); + // break + + case "14": m_status.devices.Add(new DeviceSceneController(xn)); - break; - - // case "15": // TODO: Implement AV device ? - // m_status.devices.Add(new DeviceSensor(xn)); - // break; - + break; + + // case "15": + // m_status.devices.Add(new DeviceAV(xn)); + // break; + case "16": m_status.devices.Add(new DeviceHumidity(xn)); break; case "17": - m_status.devices.Add(new DeviceTemperature(xn, m_bMetric)); + m_status.devices.Add(new DeviceTemperature(xn, m_status.system.isMetric())); break; - - case "18": + + case "18": m_status.devices.Add(new DeviceLightSensor(xn)); - break; - - case "21": + break; + + //case "19": + // m_status.devices.Add(new DeviceZwaveInt(xn)); + // break + //case "20": + // m_status.devices.Add(new DeviceInsteonInt(xn)); + // break + + case "21": m_status.devices.Add(new DevicePowerMeter(xn)); - break; - + break; + case "0": default: // Check for Google Weather Device @@ -380,80 +508,30 @@ break; } } + // At least one device was found and thus changes + m_bScreenUpdateRequired = true; } - // update timer again (took some time to get the data) - m_lLastUpdate = getSecondsSince1970(); - m_bUpdatePending = false; - return bFullRefresh; } - public string doVeraRequest( string param, bool pParseResult ) - { - string response = doVeraRequest( param ); - if (pParseResult) - { - response = parseVeraRespones(response); - } - return response; - } - - public bool isVeraAlive(string ip, string port) - { - string response = retrieveURL("http://" + ip + ":" + port + "/data_request?id=lu_alive&time="+DateTime.Now.Ticks); - - return (response == "OK"); - } - - public string doVeraRequest( string param ) - { - return retrieveURL("http://" + vera_Address + "/data_request" + param + "&time="+DateTime.Now.Ticks); - } - - private string retrieveURL( string url ) - { - using (var webClient = new System.Net.WebClient()) { - return webClient.DownloadString(url); - } - } - - - private string parseVeraRespones(string response) - { - if (response.StartsWith("ERROR:")) - { - return response; - } - if (response.Contains("<OK>OK</OK>")) - { - return "Ok"; - } - - return response; - } - - public long getSecondsSince1970() - { - return (DateTime.Now.Ticks / 10000000); - } - public long secondsSinceLastUpdate { - get { return (getSecondsSince1970() - m_lLastUpdate); } + get { return (helper.getSecondsSince1970() - m_lLastUpdate); } set { } } + /* public bool metric { get { return m_bMetric; } set { } } - + */ public List<Scene> scenes { get { return m_status.scenes; } set { } } - + public List<DeviceGeneric> devices { get { return m_status.devices; } @@ -478,6 +556,32 @@ set { } } + public bool lastUpdateFailed + { + get { return m_bLastUpdateFailed; } + set { m_bLastUpdateFailed = value; } + } + + public string lastUpdateError + { + get { return m_strLastUpdateError; } + set { } + } + + public bool newScreenUpdateWaitingAndClearFlag() + { + // Invoking this method will clear the update ready flag -> so caller need to handle the update + bool b = m_bScreenUpdateRequired; + m_bScreenUpdateRequired = false; + return b; + } + + public bool updatePending + { + get { return m_bUpdatePending; } + set { } + } + public VeraStatus status { get { return m_status; } @@ -490,6 +594,6 @@ set { } } } - - + + } Modified: trunk/plugins/VeraControl/VeraControl.cs =================================================================== --- trunk/plugins/VeraControl/VeraControl.cs 2012-01-14 17:51:27 UTC (rev 4404) +++ trunk/plugins/VeraControl/VeraControl.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -4,8 +4,8 @@ * Date: 21-12-2011 * Time: 21:20 * - * Copyright: 2012 GPL - Bart Eversdijk - * MediaPort plugin - MicasaVerde (TM) Vera Controller + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller * E-mail: ba...@ev... */ using System; @@ -31,9 +31,7 @@ [assembly: UsesSubsystem("MP.SkinEngine")] [assembly: UsesSubsystem("MP.Config")] -// TODO: support multiple Vera Box -// TODO: get all boxes for a specific user (http://sta1.mios.com/locator_json.php?username=<user>) -// TODO: support remote vera Boxes (http://fwd1.mios.com/<name>/<pass>/<serial>/data_request?...) +// TODO: support multiple Vera Box AND get all boxes for a specific user (http://sta1.mios.com/locator_json.php?username=<user>) AND support remote vera Boxes (http://fwd1.mios.com/<name>/<pass>/<serial>/data_request?...) namespace VeraControl { @@ -88,17 +86,19 @@ [SkinControl(60)] protected GUIButtonControl ActionButton = null; [SkinControl(70)] protected GUIToggleButtonControl ActionTriggerButton = null; - int PluginID = 1972; - VeraCommunication vera = VeraCommunication.Instance; - int iSelectedRoom = Int16.MaxValue; - int iSelectedCategory = Int16.MaxValue; - int iRefreshDelay = 5; - public Actiontrigger iLastAction = Actiontrigger.LAST_ACTIONTRIGGER; + [SkinControl(30)] protected GUIImage cmtImage = null; + [SkinControlAttribute(31)] protected GUILabelControl comment=null; - public bool enableSceneTrigger = false; - bool bLastUpdateFailed = false; + private int PluginID = 1972; + private VeraCommunication vera = VeraCommunication.Instance; + private int m_iSelectedRoom = Int16.MaxValue; + private int m_iSelectedCategory = Int16.MaxValue; + public Actiontrigger iLastAction = Actiontrigger.LAST_ACTIONTRIGGER; + private VeraHelper helper = new VeraHelper(); - private string titleTxt = "Micasa Verde - Vera control"; + public bool enableSceneTrigger = false; + private bool bLastUpdateFailed = false; + private string titleTxt = "Micasa Verde - Vera control"; public VeraControl() { @@ -191,26 +191,33 @@ public override bool Init() { - iSelectedRoom = Int16.MaxValue; - iSelectedCategory = Int16.MaxValue; + m_iSelectedRoom = Int16.MaxValue; + m_iSelectedCategory = Int16.MaxValue; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { - iRefreshDelay = int.Parse(xmlreader.GetValueAsString("veracontroller", "refreshdelay", "5")); enableSceneTrigger = xmlreader.GetValueAsBool("veracontroller", "enableSceneTrigger", false); } GUIWindowManager.OnNewAction += new OnActionHandler(OnNewAction); - + Player.PlayBackEnded += new Player.EndedHandler(g_Player_PlayBackEnded); Player.PlayBackStarted += new Player.StartedHandler(g_Player_PlayBackStarted); Player.PlayBackStopped += new Player.StoppedHandler(g_Player_PlayBackStopped); - // Handle MP start-up trigger - InitClass initClass = new InitClass(this); - Thread oThread = new Thread(new ThreadStart(initClass.runFirstUpdate)); - oThread.Start(); - + // Handle MP start-up trigger - do this is a different Thread to not block MP-start up + new Thread( () => { + vera.updateCurrentStatus(DateTime.Now.Ticks); + // Run startup trigger after first update + if (enableSceneTrigger) + { + while (vera.updatePending) + { + Thread.Sleep(1000); + } + handleActionTriggers(Actiontrigger.MP_START_UP); + } + }).Start(); return Load(GUIGraphicsContext.Skin+@"\VeraControl.xml"); } @@ -269,6 +276,13 @@ } break; + case Action.ActionType.ACTION_CONTEXT_MENU: + if (GUIWindowManager.ActiveWindow == GetWindowId()) + { + showInfoDialog(); + } + break; + case Action.ActionType.ACTION_EXIT: handleActionTriggers(Actiontrigger.MP_EXIT); break; @@ -458,84 +472,150 @@ } } - public override void Render(float timePassed) { - if (vera.secondsSinceLastUpdate > iRefreshDelay) + // Give a message to the user a update failed + if (vera.lastUpdateFailed) { - refreshNow(); + // Show message only once! + if (!bLastUpdateFailed) + { + if (vera.status.system.dataversion == "0") + { // Give message on never connected... + new Thread (() => { NoConnection(vera.lastUpdateError);}).Start(); + } else { + vera.status.system.reportConnectionError(vera.lastUpdateError); + } + } + bLastUpdateFailed = true; } + else + { // Reset failed flag again + bLastUpdateFailed = false; + } + + // vera will only update when realy required + vera.updateCurrentStatus((long)timePassed); + refreshNow(); + base.Render(timePassed); - } public void refreshNow() { - if (updateNow()) + if (vera.newScreenUpdateWaitingAndClearFlag()) { + // update system status + if (vera.status.system.newScreenUpdateWaitingAndClearFlag()) + { + setSystemStatus(); + } + // update device status - if (iSelectedRoom != Int16.MaxValue) + if (m_iSelectedRoom != Int16.MaxValue) { foreach (GUIListItem item in RightList.ListItems) { DeviceGeneric dev = vera.status.getDeviceById( item.ItemId ); - item.Label2 = dev.getStatusText(); - - //Adjust color of item when option is turned off - item.IsPlayed = !dev.isControllable; - - item.IconImage = "Vera\\"+dev.getIconName()+".png"; - item.IconImageBig = "Vera\\"+dev.getIconName()+".png"; - item.ThumbnailImage = "Vera\\"+dev.getIconName()+".png"; - - Utils.SetDefaultIcons(item); + if (dev.newScreenUpdateWaitingAndClearFlag()) + { + item.Label2 = dev.getStatusText(); + item.PinImage = helper.getStateImage(dev.commstate); + + //Adjust color of item when option is turned off + item.IsPlayed = !dev.isControllable; + + item.IconImage = "Vera\\"+dev.getIconName()+".png"; + item.IconImageBig = "Vera\\"+dev.getIconName()+".png"; + item.ThumbnailImage = "Vera\\"+dev.getIconName()+".png"; + + Utils.SetDefaultIcons(item); + } } } + else + { + foreach(GUIListItem item in RightList.ListItems) + { + Scene scene = vera.status.getSceneById( item.ItemId ); + if (scene.newScreenUpdateWaitingAndClearFlag()) + { + item.Label2 = (scene.room == 0 ? "" : vera.status.getRoomById(scene.room).name); + item.PinImage = helper.getStateImage(scene.commstate); + item.IsPlayed = scene.isActive(); + Utils.SetDefaultIcons(item); + } + } + } } } protected override void OnPageLoad() { - updateNow(); + if (m_iSelectedCategory == 0) { m_iSelectedCategory = Int16.MaxValue; } - if (iSelectedCategory == 0) { iSelectedCategory = Int16.MaxValue; } - listCategories(); - listRooms(iSelectedCategory); - listScenes(); - - // Set Current Selected Item - LeftList.SelectedListItemIndex = 0; + listRooms(m_iSelectedCategory, m_iSelectedRoom); + if (m_iSelectedRoom == Int16.MaxValue) { + listScenes(); + } else { + listDevices(m_iSelectedRoom); + } + // Disable Page control (for left list) + LeftList.SetPageControlVisible( false ); + + setSystemStatus(); + refreshNow(); updateSceneTrigger(); base.OnPageLoad(); } + + private void setSystemStatus() + { + if (vera.status.system.state != DevState.NONE) { + cmtImage.Dispose(); + cmtImage.SetFileName(helper.getStateImage(vera.status.system.state)); + cmtImage.KeepAspectRatio = true; + cmtImage.Visibility = System.Windows.Visibility.Visible; + cmtImage.AllocResources(); + } else{ + cmtImage.Visibility = System.Windows.Visibility.Hidden; + } + comment.Label = vera.status.system.comment; + + } private void listCategories() { + int iCnt = 1; + int iSelected = 0; GUIControl.ClearControl(GetID, catList.GetID); catList.AddSpinLabel("All", Int16.MaxValue); - // Fill in scene for default foreach( Section sec in vera.sections ) { catList.AddSpinLabel(sec.name, sec.id); - + iCnt++; + if (m_iSelectedCategory == sec.id) + { + iSelected = iCnt; + } } - catList.SelectedItem = iSelectedCategory; + catList.SelectedItem = iSelected; } private void listScenes() { GUIControl.ClearControl(GetID, RightList.GetID); - // Fill in scene for default foreach( Scene scene in vera.scenes ) { GUIListItem item = new GUIListItem(scene.name); - item.Label2 = vera.status.getRoomById(scene.room).name; + item.Label2 = (scene.room == 0 ? "" : vera.status.getRoomById(scene.room).name); + item.PinImage = helper.getStateImage(scene.commstate); item.IsPlayed = scene.isActive(); item.ItemId = scene.id; @@ -545,7 +625,6 @@ Utils.SetDefaultIcons(item); RightList.Add(item); - } GUIControl.FocusControl(GetID, LeftList.GetID); @@ -555,8 +634,10 @@ title.Label = titleTxt + " - Scenes"; } - private void listRooms(int iShowSection) + private void listRooms(int iShowSection, int iSelectedRoom) { + int iCnt = 0; + int iSelected = 0; // --- fill in left lisft with rooms and scene item GUIControl.ClearControl(GetID, LeftList.GetID); GUIListItem sceneitem = new GUIListItem("Scenes"); @@ -583,9 +664,16 @@ Utils.SetDefaultIcons(item); LeftList.Add(item); + + iCnt++; + if (iSelectedRoom == room.id) + { + iSelected = iCnt; + } } } - + // Set Current Selected Item + LeftList.SelectedListItemIndex = iSelected; } private void listDevices(int iShowRoom) @@ -599,6 +687,7 @@ { GUIListItem item = new GUIListItem(dev.name); item.Label2 = dev.getStatusText(); + item.PinImage = helper.getStateImage(dev.commstate); //Adjust color of item when option is turned off item.IsPlayed = !dev.isControllable; @@ -624,11 +713,11 @@ private void OnLeftlistCrtl(GUIListControl control) { - iSelectedRoom = control.SelectedListItem.ItemId; + m_iSelectedRoom = control.SelectedListItem.ItemId; GUIAnimation.HideControl(GetID, RightList.GetID); - if (iSelectedRoom == Int16.MaxValue) + if (m_iSelectedRoom == Int16.MaxValue) { // Selected room is Int16.MaxValue which mean we need to have scenes in our list listScenes(); @@ -636,7 +725,7 @@ else { // Selected room != Int16.MaxValue which mean we need to have devices of a certain room in our list - listDevices(iSelectedRoom); + listDevices(m_iSelectedRoom); } GUIAnimation.ShowControl(GetID, RightList.GetID); @@ -645,33 +734,24 @@ private void OnCategoryList(GUISpinButton control) { if (control.SpinValue > 0) { - iSelectedCategory = vera.sections[control.SpinValue-1].id; + m_iSelectedCategory = vera.sections[control.SpinValue-1].id; } else { - iSelectedCategory = Int16.MaxValue; + m_iSelectedCategory = Int16.MaxValue; } - if (iSelectedCategory == 0 ) { iSelectedCategory = Int16.MaxValue; } - listRooms( iSelectedCategory ); - iSelectedRoom = Int16.MaxValue; + if (m_iSelectedCategory == 0 ) { m_iSelectedCategory = Int16.MaxValue; } + m_iSelectedRoom = Int16.MaxValue; + listRooms( m_iSelectedCategory, m_iSelectedRoom ); listScenes(); } private void OnRightlistCrtl(GUIListControl control) { - if (iSelectedRoom == Int16.MaxValue) + if (m_iSelectedRoom == Int16.MaxValue) { // Selected room is 0 which mean we have scenes in our list Scene scene = vera.status.getSceneById(control.SelectedListItem.ItemId); - - GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); - dlg.SetHeading("Scene has been pressed"); - - if (scene.id != 0) { - scene.run(); - dlg.SetLine(1, "Scene '" + scene.name + "' executed"); - } else { - dlg.SetLine(1, "Scene id not found: " + control.SelectedListItem.ItemId.ToString()); - } - dlg.SetLine(2, String.Empty); - dlg.SetLine(3, String.Empty); + + DialogSceneControl dlg = (DialogSceneControl)GUIWindowManager.GetWindow((int)1975); + dlg.InitDialog("Scene control", scene); dlg.DoModal(GUIWindowManager.ActiveWindow); } else @@ -680,39 +760,6 @@ DeviceGeneric dev = vera.status.getDeviceById(control.SelectedListItem.ItemId); DialogDeviceControl dlg = (DialogDeviceControl)GUIWindowManager.GetWindow((int)1973); dlg.InitDialog(vera.status.getRoomById(dev.room).name, dev); - dlg.SetImage("Vera\\"+dev.getIconName()+".png"); - - if (dev.isControllable) - { - if (dev.GetType() == typeof(DeviceSprinkler)) - { - dlg.SetText(dev.name, dev.getStatusText() + " - " + dev.mode, dev.getExtraText() ); - dlg.SetActiveBut((dev.status ? 1 : 0), (dev.mode == "Auto" ? 0 : (dev.mode == "Block" ? 2 : 1) )); - } - else if (dev.GetType() == typeof(DeviceThermostat)) - { - dlg.SetText(dev.name, dev.getStatusText(), dev.getExtraText() ); - dlg.SetActiveBut((dev.status ? 1 : 0), (dev.mode == "Auto" ? 0 : - (dev.mode == "CoolOn" || dev.mode == "Cool" ? 1 : - (dev.mode == "HeatOn" || dev.mode == "Heat" ? 2 : 3) ))); - } - else - { - dlg.SetText(dev.name, "", ""); - dlg.SetActiveBut(dev.status ? 1 : 0, -1); - } - dlg.SetButtons(dev.getCommands()); - dlg.SetSlider(dev.level, dev.maxLevel); - } - else - { - if (dev.GetType() == typeof(DeviceCam)) - { - DeviceCam cam = (DeviceCam) dev; - dlg.SetCamImage(cam.imgUrl); - } - dlg.SetText(dev.name, dev.getStatusText(), dev.getExtraText()); - } dlg.DoModal(GUIWindowManager.ActiveWindow); // Update list after closure @@ -744,34 +791,37 @@ { ActionButton.IsVisible = enableSceneTrigger; ActionTriggerButton.Selected = enableSceneTrigger; - if (enableSceneTrigger) + if (enableSceneTrigger) { - LeftList.NavigateLeft = 60; - RightList.NavigateRight = 60; + LeftList.NavigateLeft = 60; + RightList.NavigateRight = 60; } else { - LeftList.NavigateLeft = 50; - RightList.NavigateRight = 40; + LeftList.NavigateLeft = 50; + RightList.NavigateRight = 40; } } - public bool updateNow() + private void showInfoDialog() { - try { - bool result = vera.updateCurrentStatus(); - bLastUpdateFailed = false; - return result; - } catch(Exception e) + GUIDialogText dlg = (GUIDialogText)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TEXT); + if (dlg != null) { - if (!bLastUpdateFailed) - { - NoConnection(e.ToString()); - } - bLastUpdateFailed = false; - return false; + dlg.Reset(); + dlg.SetHeading("VeraBox - " + vera.status.system.serialno); + dlg.SetText ("version : " + vera.status.system.versionInfo +"\n" + + "addres : " + vera.vera_Address +"\n" + + "healed : " + (vera.status.system.bZWaveHeal ? "yes" : "no") +"\n" + + "units : " + (vera.status.system.isMetric() ? "metric" : "imperial") +"\n" + + "fwd1 : " + vera.status.system.fwd +"\n" + + "fwd2 : " + vera.status.system.fwdBackup + "\n" + "\n" + + "comment : " + (vera.status.system.comment == "" ? "-": vera.status.system.comment)); + + dlg.DoModal(GUIWindowManager.ActiveWindow); } } + private void NoConnection(string err) { GUIDialogText dlg = (GUIDialogText)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_TEXT); @@ -779,28 +829,11 @@ { dlg.Reset(); dlg.SetHeading("Error !!!"); - dlg.SetText ("Micasa Verde Vera 2 Box not found @ " + vera.vera_Address +"\n" + - "Check the plug-in cofiguration. \n\n Error message: \n" + err); + dlg.SetText ("MicasaVerde Vera 2 Box not found @ " + vera.vera_Address +"\n" + + "Check the plug-in configuration.\n\nError message: \n" + err); dlg.DoModal(GUIWindowManager.ActiveWindow); } } } - - public class InitClass - { - VeraControl _vc = null; - public InitClass(VeraControl vc) - { - _vc = vc; - } - public void runFirstUpdate() - { - _vc.updateNow(); - // Handle MP start-up trigger - _vc.handleActionTriggers(Actiontrigger.MP_START_UP); - } - } - - } \ No newline at end of file Modified: trunk/plugins/VeraControl/VeraControl.csproj =================================================================== --- trunk/plugins/VeraControl/VeraControl.csproj 2012-01-14 17:51:27 UTC (rev 4404) +++ trunk/plugins/VeraControl/VeraControl.csproj 2012-01-15 23:50:18 UTC (rev 4405) @@ -96,11 +96,13 @@ <Compile Include="DeviceSecurity.cs" /> <Compile Include="DeviceSprinkler.cs" /> <Compile Include="DeviceSwitch.cs" /> + <Compile Include="DeviceSystem.cs" /> <Compile Include="DeviceTemperature.cs" /> <Compile Include="DeviceThermostat.cs" /> <Compile Include="DeviceWindowCovering.cs" /> <Compile Include="DialogActionTrigger.cs" /> <Compile Include="DialogDeviceControl.cs" /> + <Compile Include="DialogSceneControl.cs" /> <Compile Include="VeraControl.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Room.cs" /> Modified: trunk/plugins/VeraControl/VeraHelper.cs =================================================================== --- trunk/plugins/VeraControl/VeraHelper.cs 2012-01-14 17:51:27 UTC (rev 4404) +++ trunk/plugins/VeraControl/VeraHelper.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -19,7 +19,9 @@ NONE = 0, PENDING, SUCCESS, - ERROR + ERROR, + + CONNECTION_ERROR // not a Vera state } /// <summary> @@ -73,6 +75,29 @@ } } + public string getStateImage( DevState state ) + { + switch(state) + { + case DevState.PENDING: + return "remote_blue.png"; + + case DevState.SUCCESS: + return "remote_green.png"; + + case DevState.ERROR: + return "tvguide_recordconflict_button.png"; + + case DevState.CONNECTION_ERROR: + return "warning-icon.png"; + + default: + case DevState.NONE: + return ""; + + } + } + public int getAttrAsInt(XmlNode xn, string key, int iDefault) { if (xn == null || xn.Attributes[key] == null) @@ -100,5 +125,10 @@ } return xn.Attributes[key].Value; } + + public long getSecondsSince1970() + { + return (DateTime.Now.Ticks / 10000000); + } } } Modified: trunk/plugins/VeraControl/VeraSetupForm.Designer.cs =================================================================== --- trunk/plugins/VeraControl/VeraSetupForm.Designer.cs 2012-01-14 17:51:27 UTC (rev 4404) +++ trunk/plugins/VeraControl/VeraSetupForm.Designer.cs 2012-01-15 23:50:18 UTC (rev 4405) @@ -37,10 +37,10 @@ this.CheckConnection = new System.Windows.Forms.Button(); this.labelPortNumber = new System.Windows.Forms.Label(); this.portnumber = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); this.refreshdelay = new System.Windows.Forms.TextBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.enableSceneTrigger = new System.Windows.Forms.CheckBox(); + this.label1 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); @@ -141,26 +141,17 @@ this.portnumber.TabIndex = 2; this.portnumber.Text = "3480"; // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(17, 24); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(117, 13); - this.label1.TabIndex = 7; - this.label1.Text = "Refresh status delay (s)"; - // // refreshdelay // this.refreshdelay.AcceptsTab = true; this.refreshdelay.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Win... [truncated message content] |
From: <Ba...@us...> - 2012-01-17 23:06:28
|
Revision: 4408 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4408&view=rev Author: BartEv Date: 2012-01-17 23:06:18 +0000 (Tue, 17 Jan 2012) Log Message: ----------- Improved error handling Modified Paths: -------------- trunk/plugins/VeraControl/DeviceCam.cs trunk/plugins/VeraControl/DeviceDimmer.cs trunk/plugins/VeraControl/DeviceDoorlock.cs trunk/plugins/VeraControl/DeviceGeneric.cs trunk/plugins/VeraControl/DeviceSecurity.cs trunk/plugins/VeraControl/DeviceSprinkler.cs trunk/plugins/VeraControl/DeviceSwitch.cs trunk/plugins/VeraControl/DeviceSystem.cs trunk/plugins/VeraControl/DeviceThermostat.cs trunk/plugins/VeraControl/DialogDeviceControl.cs trunk/plugins/VeraControl/DialogSceneControl.cs trunk/plugins/VeraControl/Scene.cs trunk/plugins/VeraControl/VeraCommunication.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/VeraControl.csproj trunk/plugins/VeraControl/VeraHelper.cs trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml Added Paths: ----------- trunk/plugins/VeraControl/BaseDevice.cs Added: trunk/plugins/VeraControl/BaseDevice.cs =================================================================== --- trunk/plugins/VeraControl/BaseDevice.cs (rev 0) +++ trunk/plugins/VeraControl/BaseDevice.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -0,0 +1,175 @@ +/* + * Created by SharpDevelop. + * User: Bart + * Date: 17-1-2012 + * Time: 19:12 + * + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller + * E-mail: ba...@ev... + */ +using System; +using System.Xml; + +namespace VeraControl.Properties +{ + /// <summary> + /// Description of BaseDevice. + /// </summary> + public class BaseDevice + { + public long m_lLastUpdate = 0; + public long m_lLastPendingUpdate = 0; + public bool m_bScreenUpdateRequired = false; + private string m_sName = "unknown device"; + private int m_iId = 0; + private int m_iRoom = 0; + + // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) + private DevState m_dsState = DevState.NONE; + private string m_sComment = ""; // red(error), green(success) or blue(pending) - icon/text + + public VeraHelper helper = VeraHelper.Instance; + public VeraCommunication vera = VeraCommunication.Instance; + + public BaseDevice(XmlNode xn) + { + if (xn != null) + { + update(xn); + } + } + + /// <summary> + /// Process Vera update information + /// </summary> + public virtual bool update(XmlNode xn) + { + m_sName = helper.getAttrAsString(xn, "name", m_sName); + m_iId = helper.getAttrAsInt (xn, "id", m_iId); + m_iRoom = helper.getAttrAsInt (xn, "room", m_iRoom); + + string temp_sComment = helper.getAttrAsString(xn, "comment", m_sComment ); + DevState temp_dsState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1)); + if (m_dsState != DevState.PENDING || temp_dsState != DevState.NONE || (temp_dsState == DevState.NONE && ((m_lLastPendingUpdate / TimeSpan.TicksPerSecond ) < (DateTime.Now.Ticks / TimeSpan.TicksPerSecond)))) + { // If state was set to pending next update should contain a new state or still pending - so do not clear pending flag for at least 10 seconds + m_sComment = temp_sComment; + m_dsState = temp_dsState; + } + if (m_iId == 0) + { + // void device no further processing needed + return false; + } + + // Set update flag + m_bScreenUpdateRequired = true; + m_lLastUpdate = DateTime.Now.Ticks; + return true; + } + + /// <summary> + /// Returns the id of this device + /// </summary> + public int id + { + get { return m_iId; } + set { } + } + + /// <summary> + /// Returns the name of this device + /// </summary> + public string name + { + get { return m_sName; } + set { } + } + + /// <summary> + /// Returns true when this device is associated with the given room + /// </summary> + public bool inRoom(int id) + { + return (m_iRoom == id); + } + + /// <summary> + /// Return the room is this device is associated with + /// </summary> + public int room + { + get { return m_iRoom; } + set { m_iRoom = value; } + } + + /// <summary> + /// Return the communications state for this device + /// </summary> + public DevState commstate + { + get { return m_dsState; } + set { } + } + + /// <summary> + /// Return the comment as reported by Vera for this device + /// </summary> + public string comment + { + get { return (commstate != DevState.NONE ? m_sComment : ""); } + set { } + } + + /// <summary> + /// Set virtual device state to pending request + /// </summary> + public void reportPendingRequest() + { + m_dsState = DevState.PENDING; + m_sComment = "Sending command..."; + m_bScreenUpdateRequired = true; + m_lLastUpdate = DateTime.Now.Ticks; + m_lLastPendingUpdate = m_lLastUpdate; + } + + /// <summary> + /// Callback function for Ansync Web Client call on to report errors... + /// </summary> + public void reportRequestError(string message) + { + m_dsState = DevState.COMMAND_ERROR; + m_sComment = message; + m_bScreenUpdateRequired = true; + m_lLastUpdate = DateTime.Now.Ticks; + } + + public void clearCommState() + { + m_dsState = DevState.NONE; + } + /// <summary> + /// True when an update was processed after the give time stamp + /// </summary> + public virtual bool newUpdateSince(long lTimePreviousCheck) + { + return (lTimePreviousCheck <= m_lLastUpdate); + } + + /// <summary> + /// Invoking this method will clear the update ready flag -> so caller need to handle the screen update + /// </summary> + public virtual bool newScreenUpdateWaitingAndClearFlag( ) + { + bool b = m_bScreenUpdateRequired; + m_bScreenUpdateRequired = false; + return b; + } + + public override string ToString() + { + return name; + } + + } +} Modified: trunk/plugins/VeraControl/DeviceCam.cs =================================================================== --- trunk/plugins/VeraControl/DeviceCam.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/DeviceCam.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -15,7 +15,7 @@ /// Description of DeviceCam. /// </summary> public class DeviceCam : DeviceGeneric - { + { // TODO: add IP-cam control buttons private string m_sIp = "127.0.0.1"; private string m_sUrl = "/"; private string m_sStream = ""; @@ -54,7 +54,7 @@ private bool refreshDelayPassed(long lastcheck) { - return ((helper.getSecondsSince1970() - refreshRate) > (lastcheck / 10000000)); + return ((helper.getSecondsSince1970() - refreshRate) > (lastcheck / TimeSpan.TicksPerSecond)); } public override string getIconName() Modified: trunk/plugins/VeraControl/DeviceDimmer.cs =================================================================== --- trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -64,13 +64,14 @@ } else { if (newValue < 0) { newValue = 0; } } - if ((id > 0) && (newValue != m_iLevel)) // Only send when a valid ID is found - { + if (id > 0) // Only send when a valid ID is found + { + reportPendingRequest(); // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget" + "&newLoadlevelTarget="+value; - vera.doVeraRequest(cmd); + vera.doVeraCommandRequest(cmd, reportRequestError); } m_iLevel = newValue; } Modified: trunk/plugins/VeraControl/DeviceDoorlock.cs =================================================================== --- trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -41,13 +41,13 @@ set { if (id > 0) // Only send when a valid ID is found { + reportPendingRequest(); // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ "&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget" + "&newTargetValue="+(value ? "1" : "0"); - vera.doVeraRequest(cmd); + vera.doVeraCommandRequest(cmd, reportRequestError); } - m_bStatus = value; } } Modified: trunk/plugins/VeraControl/DeviceGeneric.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -14,29 +14,15 @@ namespace VeraControl.Properties { - - /// <summary> /// Description of DeviceGeneric. /// </summary> - public class DeviceGeneric + public class DeviceGeneric : BaseDevice { - public long m_lLastUpdate = 0; - public bool m_bScreenUpdateRequired = false; - private string m_sName = "unknown device"; - private int m_iId = 0; private string m_sAltId = ""; private int m_iCategory = 0; - private int m_iRoom = 0; - // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) - private DevState m_dsState = DevState.NONE; - private string m_sComment = ""; // red(error), green(success) or blue(pending) - icon/text - - public VeraHelper helper = VeraHelper.Instance; - public VeraCommunication vera = VeraCommunication.Instance; - - public DeviceGeneric(XmlNode xn) + public DeviceGeneric(XmlNode xn): base (xn) { if (xn != null) { @@ -44,97 +30,43 @@ } } - public virtual bool update(XmlNode xn) + public override bool update(XmlNode xn) { - m_sName = helper.getAttrAsString(xn, "name", m_sName); - m_iId = helper.getAttrAsInt (xn, "id", m_iId); m_sAltId = helper.getAttrAsString(xn, "altid", m_sAltId); m_iCategory = helper.getAttrAsInt (xn, "category", m_iCategory); - m_iRoom = helper.getAttrAsInt (xn, "room", m_iRoom); - m_sComment = helper.getAttrAsString(xn, "comment", m_sComment ); - m_dsState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1)); - - if (m_iId == 0) + bool b = base.update(xn); + // Make sure the room exists + if (room == 0 || !vera.status.isRoomFound(room)) { - // void device no further processing needed - return false; - } - // Make sure room exists - if (m_iRoom == 0 || !vera.status.isRoomFound(m_iRoom)) - { if (!vera.status.isRoomFound(0)) { // create dummy room to attach to vera.rooms.Add(new Room(null)); } - m_iRoom = 0; + room = 0; } - - // Set update flag - m_bScreenUpdateRequired = true; - m_lLastUpdate = DateTime.Now.Ticks; - - return true; + + return b; } - - public int id - { - get { return m_iId; } - set { } - } - + public string altid { get { return m_sAltId; } set { } } - - public string name - { - get { return m_sName; } - set { } - } - + public int category { get { return m_iCategory; } set { } } - - public bool inRoom(int id) - { - return (m_iRoom == id); - } - public int room - { - get { return m_iRoom; } - set { } - } - - public override string ToString() - { - return name; - } - public virtual bool isControllable { get { return false; } set { } } - public virtual DevState commstate - { - get { return m_dsState; } - set { } - } - - public virtual string comment - { - get { return (commstate != DevState.NONE ? m_sComment : ""); } - set { } - } - public virtual bool status { get { return false; } @@ -183,18 +115,5 @@ { return new string [] {"Off", "On"}; } - - public virtual bool newScreenUpdateWaitingAndClearFlag( ) - { - // Invoking this method will clear the update ready flag -> so caller need to handle the update - bool b = m_bScreenUpdateRequired; - m_bScreenUpdateRequired = false; - return b; - } - - public virtual bool newUpdateSince(long lTimePreviousCheck) - { - return (lTimePreviousCheck <= m_lLastUpdate); - } } } Modified: trunk/plugins/VeraControl/DeviceSecurity.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSecurity.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/DeviceSecurity.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -43,13 +43,13 @@ set { if (id > 0) // Only send when a valid ID is found { + reportPendingRequest(); // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ "&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&action=SetArmed" + "&newArmedValue=" + (value ? "1" : "0"); - vera.doVeraRequest(cmd); + vera.doVeraCommandRequest(cmd, reportRequestError); } - m_bArmed = value; } } Modified: trunk/plugins/VeraControl/DeviceSprinkler.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -49,13 +49,13 @@ set { if (id > 0) // Only send when a valid ID is found { + reportPendingRequest(); // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + "&newTargetValue="+(value ? "1" : "0"); - vera.doVeraRequest(cmd); + vera.doVeraCommandRequest(cmd, reportRequestError); } - m_bStatus = value; } } @@ -71,13 +71,13 @@ set { if (id > 0) // Only send when a valid ID is found { + reportPendingRequest(); // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ "&serviceId=urn:upnp-micasaverde-com:serviceId:Sprinkler1&action=" + (value == "Auto" ? "SetModeAuto" : (value == "Block" ? "SetModeBlock" : "SetModeManual")); - vera.doVeraRequest(cmd); + vera.doVeraCommandRequest(cmd, reportRequestError); } - m_sMode = value; } } Modified: trunk/plugins/VeraControl/DeviceSwitch.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSwitch.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/DeviceSwitch.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -4,8 +4,8 @@ * Date: 22-12-2011 * Time: 14:25 * - * Copyright: 2012 GPL - Bart Eversdijk - * MediaPort plugin - MicasaVerde (TM) Vera Controller + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller * E-mail: ba...@ev... */ using System; @@ -22,7 +22,7 @@ private string m_sWatt = "-"; private string m_sKwh = "-"; - public DeviceSwitch( XmlNode xn ): base (xn) + public DeviceSwitch( XmlNode xn ): base (xn) { if (xn != null) { @@ -30,13 +30,13 @@ } } - public override bool update(XmlNode xn) + public override bool update(XmlNode xn) { m_bStatus = helper.getAttrAsBool (xn, "status", m_bStatus); m_sWatt = helper.getAttrAsString(xn, "watts", m_sWatt); m_sKwh = helper.getAttrAsString(xn, "kwh", m_sKwh); - return base.update(xn); + return base.update(xn); } public string watts @@ -48,16 +48,16 @@ public override bool status { get { return m_bStatus; } - set { - if (id > 0) // Only send when a valid ID is found - { - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + - "&newTargetValue="+(value ? "1" : "0"); - vera.doVeraRequest(cmd); - } - m_bStatus = value; + set { + if (id > 0) // Only send when a valid ID is found + { + reportPendingRequest(); + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + + "&newTargetValue="+(value ? "1" : "0"); + vera.doVeraCommandRequest(cmd, reportRequestError); + } } } Modified: trunk/plugins/VeraControl/DeviceSystem.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSystem.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/DeviceSystem.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -148,6 +148,14 @@ m_lLastUpdate = DateTime.Now.Ticks; } + public void reportCommandError( string errmsg ) + { + m_dsVeraState = DevState.COMMAND_ERROR; + m_sComment = errmsg; + m_bScreenUpdateRequired = true; + m_lLastUpdate = DateTime.Now.Ticks; + } + public void clearConnectionError( ) { m_dsVeraState = DevState.NONE; Modified: trunk/plugins/VeraControl/DeviceThermostat.cs =================================================================== --- trunk/plugins/VeraControl/DeviceThermostat.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/DeviceThermostat.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -60,14 +60,14 @@ set { if (id > 0) // Only send when a valid ID is found { + reportPendingRequest(); // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ "&serviceId=urn:upnp-org:serviceId:HVAC_UserOperatingMode1&action=SetModeTarget" + "&NewModeTarget="+(value == "Off" ? "Off" : (value == "Cool" ? "CoolOn" : (value == "Heat" ? "HeatOn" : "AutoChangeOver")) ); - vera.doVeraRequest(cmd); + vera.doVeraCommandRequest(cmd, reportRequestError); } - m_sMode = value; } } Modified: trunk/plugins/VeraControl/DialogDeviceControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -46,9 +46,12 @@ [SkinControl(30)] protected GUIImage cmtImage = null; [SkinControlAttribute(31)] protected GUILabelControl comment=null; - VeraHelper helper = new VeraHelper(); - private DeviceGeneric myDev = null; - private long m_iLastUpdate = 0; + private VeraHelper helper = new VeraHelper(); + private DeviceGeneric myDev = null; + private long m_iLastUpdate = 0; + private bool m_bLevelUpdatePending = false; + private long m_lLastLevelUpdate = 0; + private int m_iDesiredLevel = 0; public DialogDeviceControl() { @@ -60,7 +63,6 @@ bool bResult = Load(GUIGraphicsContext.Skin + @"\VeraDialogDeviceControl.xml"); return bResult; } - public void InitDialog(string strLine, DeviceGeneric dev) { @@ -75,7 +77,7 @@ { btnClose.SetNavigation(2,2,2,2); } - + updateStatus(); } @@ -96,8 +98,8 @@ { SetText(myDev.name, myDev.getStatusText(), myDev.getExtraText() ); SetActiveBut((myDev.status ? 1 : 0), (myDev.mode == "Auto" ? 0 : - (myDev.mode == "CoolOn" || myDev.mode == "Cool" ? 1 : - (myDev.mode == "HeatOn" || myDev.mode == "Heat" ? 2 : 3) ))); + (myDev.mode == "CoolOn" || myDev.mode == "Cool" ? 1 : + (myDev.mode == "HeatOn" || myDev.mode == "Heat" ? 2 : 3) ))); } else { @@ -105,7 +107,10 @@ SetActiveBut(myDev.status ? 1 : 0, -1); } SetButtons(myDev.getCommands()); - SetSlider(myDev.level, myDev.maxLevel); + if (!m_bLevelUpdatePending) + { + SetSlider(myDev.level, myDev.maxLevel); + } } else { @@ -120,52 +125,32 @@ m_iLastUpdate = DateTime.Now.Ticks; } - protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { - if (control == btnLeft) - { - myDev.level = myDev.minLevel; - SetSlider( myDev.level, myDev.maxLevel ); - } - - if (control == btnRight) - { - myDev.level = myDev.maxLevel; - SetSlider( myDev.level, myDev.maxLevel ); - } - - if (control == btnMode1) - { - myDev.mode = btnMode1.Label; - SetActiveBut(-1, 0); - } - if (control == btnMode2) - { - myDev.mode = btnMode2.Label; - SetActiveBut(-1, 1); - } - if (control == btnMode3) - { - myDev.mode = btnMode3.Label; - SetActiveBut(-1, 2); - } - - if (control == slider) - { - myDev.level = slider.IntValue; - } - - // update button high lighting - SetActiveBut( (slider.IntValue > 0 ? 1 : 0), -1); - - // update icon - SetImage("Vera\\" + myDev.getIconName() + ".png"); - - // Back to the text button to switch from image view - if (control == btnClose) - { + if (control == btnClose) { PageDestroy(); + } else { + if (control == btnLeft) { + myDev.level = myDev.minLevel; + } + if (control == btnRight) { + myDev.level = myDev.maxLevel; + } + if (control == btnMode1) { + myDev.mode = btnMode1.Label; + } + if (control == btnMode2) { + myDev.mode = btnMode2.Label; + } + if (control == btnMode3) { + myDev.mode = btnMode3.Label; + } + if (control == slider) { + // Do something with fast repeating level changes.... slow down communications + m_bLevelUpdatePending = true; + m_iDesiredLevel = slider.IntValue; + SliderDebouncer(); + } } base.OnClicked(controlId, control, actionType); } @@ -197,9 +182,23 @@ } } + public void SliderDebouncer() + { + if (m_lLastLevelUpdate < DateTime.Now.Ticks) + { // If minimum update delay (2 sec) has been passed + if (m_bLevelUpdatePending && myDev.level != m_iDesiredLevel) + { + myDev.level = m_iDesiredLevel; + slider.IntValue = m_iDesiredLevel; + m_lLastLevelUpdate = DateTime.Now.Ticks + (TimeSpan.TicksPerSecond * 2); + } + m_bLevelUpdatePending = false; + } + } + public void SetSlider(int iVal, int iMaxval) { - if (iVal >= 0) + if ((iVal >= 0) && !m_bLevelUpdatePending) { slider.SetRange(0, iMaxval); slider.IntValue = iVal; @@ -276,8 +275,8 @@ if (myDev.newUpdateSince(m_iLastUpdate)) { updateStatus(); + SliderDebouncer(); } - base.Render(timePassed); } } Modified: trunk/plugins/VeraControl/DialogSceneControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogSceneControl.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/DialogSceneControl.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -80,9 +80,7 @@ if (control == btnRight) { if (myScene.id != 0) { - comment.Label = "Running..."; myScene.run(); - } } Modified: trunk/plugins/VeraControl/Scene.cs =================================================================== --- trunk/plugins/VeraControl/Scene.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/Scene.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -17,116 +17,62 @@ /// <summary> /// Description of Scene. /// </summary> - public class Scene + public class Scene : BaseDevice { - public Scene(XmlNode xn) + public Scene(XmlNode xn): base (xn) { if (xn != null) { update(xn); } } - public VeraHelper helper = VeraHelper.Instance; - private bool m_bScreenUpdateRequired = false; - private string m_sName = "unknown scene"; - private int m_iId = 0; private bool m_bActive = false; - private int m_iRoom = 0; - private long m_lLastUpdate = 0; - - // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) - private string m_sComment = ""; // red(error), green(success) or blue(pending) - icon/text - private DevState m_dsState = DevState.NONE; - - public bool update(XmlNode xn) + public override bool update(XmlNode xn) { - m_sName = helper.getAttrAsString(xn, "name", m_sName); - m_iId = helper.getAttrAsInt (xn, "id", m_iId); - m_iRoom = helper.getAttrAsInt (xn, "room", m_iRoom); - m_bActive = helper.getAttrAsBool (xn, "active", m_bActive); + m_bActive = helper.getAttrAsBool(xn, "active", m_bActive); + bool b = base.update(xn); - m_sComment = helper.getAttrAsString(xn, "comment", m_sComment ); - m_dsState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1)); - - // Set update reqired flag - m_lLastUpdate = DateTime.Now.Ticks; - m_bScreenUpdateRequired = true; - return true; + // Make sure the room exists or is 0 + if (room != 0 && !vera.status.isRoomFound(room)) + { + if (!vera.status.isRoomFound(0)) + { // create dummy room to attach to + vera.rooms.Add(new Room(null)); + } + room = 0; + } + return b; } - public int id - { - get { return m_iId; } - set { } - } - - public string name - { - get { return m_sName; } - set { } - } - - public virtual DevState commstate - { - get { return m_dsState; } - set { } - } - public virtual string comment - { - get { return (commstate != DevState.NONE ? m_sComment : ""); } - set { } - } - public bool isActive() { return m_bActive; } - public bool inRoom(int id) + public void run() { - return (m_iRoom == id); - } - - public int room - { - get { return m_iRoom; } - set { } - } - - public override string ToString() - { - return name; - } - - public string run() - { if (id == 0) { - return "Unknown scene"; + vera.status.system.reportCommandError("Unknown scene"); + m_bScreenUpdateRequired = true; } - VeraCommunication vera = VeraCommunication.Instance; + reportPendingRequest(); string cmd = "?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum="+id; - return vera.doVeraRequest(cmd); + vera.doVeraCommandRequest(cmd, reportRequestError); } - public bool newScreenUpdateWaitingAndClearFlag( ) + public override bool newScreenUpdateWaitingAndClearFlag( ) { - // Invoking this method will clear the update ready flag -> so caller need to handle the update - bool b = m_bScreenUpdateRequired; - m_bScreenUpdateRequired = false; - if (m_dsState != DevState.NONE && (m_lLastUpdate < (DateTime.Now.Ticks - (10 * 10000000)))) + // Scenes are not reported Done by Vera so the will time out... + bool b = base.newScreenUpdateWaitingAndClearFlag(); + if (commstate != DevState.NONE && (m_lLastUpdate < (DateTime.Now.Ticks - (10 * 10000000)))) { - m_dsState = DevState.NONE; + clearCommState(); return true; } return b; } - - public virtual bool newUpdateSince(long lTimePreviousCheck) - { - return (lTimePreviousCheck <= m_lLastUpdate); - } } } Modified: trunk/plugins/VeraControl/VeraCommunication.cs =================================================================== --- trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -172,19 +172,20 @@ // Config data private string m_sVeraIPAddress; private string m_sVeraTCPIPPort; - private int m_iMaxRefreshDelay; + private int m_iMaxRefreshDelay; // Maximun delay between 2 status updates in seconds + private int m_iMinRefreshDelay = 1000; // Minimun delay between 2 status updates in miliseconds - // Actual device information private VeraStatus m_status = new VeraStatus(); // Communication status/control private long m_lLastUpdate = 0; - private bool m_bUpdatePending = false; private bool m_bScreenUpdateRequired = false; // Only true when a new update was received AND at least one device(staus) or scene was changed private bool m_bLastUpdateFailed = false; private string m_strLastUpdateError = ""; - private WebClient m_webClient = new WebClient(); + private WebClient m_webUpdateClient = new WebClient(); + private WebClient m_webCommandClient = new WebClient(); + private Action<string> m_webCommandClientReportError = null; // Action control table public int[] actionTriggerTable = new int[(int)Actiontrigger.LAST_ACTIONTRIGGER]; @@ -226,71 +227,113 @@ m_iMaxRefreshDelay = int.Parse(xmlreader.GetValueAsString("veracontroller", "maxrefreshdelay", "60")); // Set DownloadStringCompleted handler - m_webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnAsyncCompletedEventArgs); + m_webUpdateClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnCompletedUpdateStatusRequest); + m_webCommandClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnCompletedCommandRequest); } } - public void updateCurrentStatus(long lNow) - { - /* when to update in case connection gets lost --> keep updating with webClient timeout 180 sec....*/ - /* TODO: watch-dog !!! last time > 4 * maxDelay force an update - to recover from hibernate */ - if (m_bUpdatePending /* && m_lLastUpdate < ((lNow / 10000000) - (4 * m_iMaxRefreshDelay)) */) - { - return; - } - - m_bUpdatePending = true; - string url = "?id=lu_sdata&loadtime=" + m_status.system.loadtime + "&dataversion=" + m_status.system.dataversion + "&minimumdelay=2000&timeout=" + m_iMaxRefreshDelay + "&output_format=xml"; - doVeraRequest(url, OnAsyncCompletedEventArgs); - m_lLastUpdate = helper.getSecondsSince1970(); - } - public bool isVeraAlive(string ip, string port) { string response = retrieveURL("http://" + ip + ":" + port + "/data_request?id=lu_alive&time="+DateTime.Now.Ticks); - return (response == "OK"); } - public string doVeraRequest(string param) + private string retrieveURL(string url) { - return retrieveURL("http://" + vera_Address + "/data_request" + param + "&time="+DateTime.Now.Ticks); + // No callback thus Synchronised call (wait for response) + try { + WebClient wc = new WebClient(); + wc.CancelAsync(); // Cancel any current pending Async calls... + return wc.DownloadString(url); + } catch( Exception ) + { + return "ERROR"; + } } - public void doVeraRequest(string param, Action<object, DownloadStringCompletedEventArgs> onCallBack) + public void doVeraCommandRequest(string param, Action<string> errorReporter) { - retrieveURLAsync("http://" + vera_Address + "/data_request" + param + "&time="+DateTime.Now.Ticks); - } - - private string retrieveURL(string url) - { - // No callback thus Synchronised call (wait for response) + if (m_webCommandClient.IsBusy) + { + // TODO: What to do ? cancel pending request or queue new request? + } + string url = "http://" + vera_Address + "/data_request" + param + "&time="+DateTime.Now.Ticks; + + // Callback thus ASynchronised call (do NOT wait for response) try { - m_webClient.CancelAsync(); // Cancel any current pending Async calls... - return m_webClient.DownloadString(url); + m_webCommandClientReportError = errorReporter; + m_webCommandClient.CancelAsync(); // Cancel any current pending Async calls... + m_webCommandClient.DownloadStringAsync(new Uri(url)); + } catch( Exception e ) { - m_bLastUpdateFailed = true; - m_strLastUpdateError = e.Message; - return "ERROR"; + m_webCommandClientReportError = null; + status.system.reportCommandError(e.Message); + m_bScreenUpdateRequired = true; } - } - private void retrieveURLAsync(string url) + public void OnCompletedCommandRequest(object sender, DownloadStringCompletedEventArgs e) { - // Callback thus ASynchronised call (do NOT wait for response) + if (e.Cancelled) { + // Communication cancel for some reason, no valid data to be expected + if (m_webCommandClientReportError != null) { + m_webCommandClientReportError("Request was canceled"); + } else { + status.system.reportCommandError("Request was canceled"); + } + m_bScreenUpdateRequired = true; + } else if (e.Error != null) { + // Handle error here + if (m_webCommandClientReportError != null) { + m_webCommandClientReportError(e.Error.Message); + } else { + status.system.reportCommandError(e.Error.Message); + } + m_bScreenUpdateRequired = true; + } else { + // Communication succes full -> no parse Vera response... + if (!e.Result.ToUpper().Contains("<OK>OK</OK>") && !e.Result.ToUpper().Contains("<JOBID>")) + { + if (m_webCommandClientReportError != null) { + m_webCommandClientReportError(e.Result); + } else { + status.system.reportCommandError(e.Result); + } + m_bScreenUpdateRequired = true; + } + } + m_webCommandClientReportError = null; + } + + + public void updateCurrentStatus() + { + /* Keep updating with webClient timeout 180 sec, even when last time did fail or connection was lost....*/ + if (!m_webUpdateClient.IsBusy) + { + string url = "http://" + vera_Address + "/data_request" + + "?id=lu_sdata&loadtime=" + m_status.system.loadtime + + "&dataversion=" + m_status.system.dataversion + + "&minimumdelay=" + m_iMinRefreshDelay + + "&timeout=" + m_iMaxRefreshDelay + + "&output_format=xml" + + "&time="+DateTime.Now.Ticks; + + // Callback thus ASynchronised call (do NOT wait for response) try { - m_webClient.CancelAsync(); // Cancel any current pending Async calls... - m_webClient.DownloadStringAsync(new Uri(url)); + m_webUpdateClient.CancelAsync(); // Cancel any current pending Async calls... + m_webUpdateClient.DownloadStringAsync(new Uri(url)); } catch( Exception e ) { m_bLastUpdateFailed = true; m_strLastUpdateError = e.Message; } + m_lLastUpdate = helper.getSecondsSince1970(); + } } - - public void OnAsyncCompletedEventArgs(object sender, DownloadStringCompletedEventArgs e) + + public void OnCompletedUpdateStatusRequest(object sender, DownloadStringCompletedEventArgs e) { if (!e.Cancelled) { @@ -311,14 +354,18 @@ // update timer again (took some time to get the data) m_lLastUpdate = helper.getSecondsSince1970(); - m_bUpdatePending = false; } public void ParseUpdateInfo(string veraresponse) { var xmlDoc = new XmlDocument(); - xmlDoc.LoadXml(veraresponse); - + try { + xmlDoc.LoadXml(veraresponse); + } catch (Exception) + { + // Parser failed so in correct data received (could be an interrupted data transfer) + return; + } // Parse header XmlNode rootnode = xmlDoc.SelectSingleNode("/root"); if (rootnode == null) @@ -342,7 +389,7 @@ m_status.system.update(rootnode); if (m_status.system.fullReload) { - // We have a full refresh -> Clear all lists (to get clear of removed devices) TODO: check/handle selected index when an item was deleted... + // We have a full refresh -> Clear all lists (to get clear of removed devices) m_status.clearAllLists(); } @@ -578,7 +625,7 @@ public bool updatePending { - get { return m_bUpdatePending; } + get { return m_webUpdateClient.IsBusy; } set { } } Modified: trunk/plugins/VeraControl/VeraControl.cs =================================================================== --- trunk/plugins/VeraControl/VeraControl.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/VeraControl.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -207,7 +207,7 @@ // Handle MP start-up trigger - do this is a different Thread to not block MP-start up new Thread( () => { - vera.updateCurrentStatus(DateTime.Now.Ticks); + vera.updateCurrentStatus(); // Run startup trigger after first update if (enableSceneTrigger) { @@ -481,9 +481,10 @@ if (!bLastUpdateFailed) { if (vera.status.system.dataversion == "0") - { // Give message on never connected... + { // Give message dialog on never connected... new Thread (() => { NoConnection(vera.lastUpdateError);}).Start(); } else { + // Give an error message on screen vera.status.system.reportConnectionError(vera.lastUpdateError); } } @@ -495,7 +496,7 @@ } // vera will only update when realy required - vera.updateCurrentStatus((long)timePassed); + vera.updateCurrentStatus(); refreshNow(); base.Render(timePassed); @@ -511,39 +512,51 @@ setSystemStatus(); } - // update device status - if (m_iSelectedRoom != Int16.MaxValue) + // if full reload has been found rebuild lists + if (vera.status.system.fullReload ) { + listRooms(m_iSelectedCategory, m_iSelectedRoom); + if (m_iSelectedRoom == Int16.MaxValue) { + listScenes(); + } else { + listDevices(m_iSelectedRoom); + } + } + else { - foreach (GUIListItem item in RightList.ListItems) + // update device status + if (m_iSelectedRoom != Int16.MaxValue) { - DeviceGeneric dev = vera.status.getDeviceById( item.ItemId ); - if (dev.newScreenUpdateWaitingAndClearFlag()) + foreach (GUIListItem item in RightList.ListItems) { - item.Label2 = dev.getStatusText(); - item.PinImage = helper.getStateImage(dev.commstate); - - //Adjust color of item when option is turned off - item.IsPlayed = !dev.isControllable; - - item.IconImage = "Vera\\"+dev.getIconName()+".png"; - item.IconImageBig = "Vera\\"+dev.getIconName()+".png"; - item.ThumbnailImage = "Vera\\"+dev.getIconName()+".png"; - - Utils.SetDefaultIcons(item); + DeviceGeneric dev = vera.status.getDeviceById( item.ItemId ); + if (dev.newScreenUpdateWaitingAndClearFlag()) + { + item.Label2 = dev.getStatusText(); + item.PinImage = helper.getStateImage(dev.commstate); + + //Adjust color of item when option is turned off + item.IsPlayed = !dev.isControllable; + + item.IconImage = "Vera\\"+dev.getIconName()+".png"; + item.IconImageBig = "Vera\\"+dev.getIconName()+".png"; + item.ThumbnailImage = "Vera\\"+dev.getIconName()+".png"; + + Utils.SetDefaultIcons(item); + } } } - } - else - { - foreach(GUIListItem item in RightList.ListItems) + else { - Scene scene = vera.status.getSceneById( item.ItemId ); - if (scene.newScreenUpdateWaitingAndClearFlag()) + foreach(GUIListItem item in RightList.ListItems) { - item.Label2 = (scene.room == 0 ? "" : vera.status.getRoomById(scene.room).name); - item.PinImage = helper.getStateImage(scene.commstate); - item.IsPlayed = scene.isActive(); - Utils.SetDefaultIcons(item); + Scene scene = vera.status.getSceneById( item.ItemId ); + if (scene.newScreenUpdateWaitingAndClearFlag()) + { + item.Label2 = (scene.room == 0 ? "" : vera.status.getRoomById(scene.room).name); + item.PinImage = helper.getStateImage(scene.commstate); + item.IsPlayed = scene.isActive(); + Utils.SetDefaultIcons(item); + } } } } @@ -571,8 +584,7 @@ base.OnPageLoad(); } - - + private void setSystemStatus() { if (vera.status.system.state != DevState.NONE) { @@ -587,6 +599,7 @@ comment.Label = vera.status.system.comment; } + private void listCategories() { int iCnt = 1; Modified: trunk/plugins/VeraControl/VeraControl.csproj =================================================================== --- trunk/plugins/VeraControl/VeraControl.csproj 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/VeraControl.csproj 2012-01-17 23:06:18 UTC (rev 4408) @@ -83,6 +83,7 @@ </Reference> </ItemGroup> <ItemGroup> + <Compile Include="BaseDevice.cs" /> <Compile Include="DevCategories.cs" /> <Compile Include="DeviceCam.cs" /> <Compile Include="DeviceDimmer.cs" /> Modified: trunk/plugins/VeraControl/VeraHelper.cs =================================================================== --- trunk/plugins/VeraControl/VeraHelper.cs 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/VeraHelper.cs 2012-01-17 23:06:18 UTC (rev 4408) @@ -13,7 +13,6 @@ namespace VeraControl.Properties { - public enum DevState { NONE = 0, @@ -21,7 +20,8 @@ SUCCESS, ERROR, - CONNECTION_ERROR // not a Vera state + CONNECTION_ERROR, // not a Vera state: update request failed + COMMAND_ERROR // not a Vera state: command request failed } /// <summary> @@ -79,6 +79,9 @@ { switch(state) { + case DevState.NONE: + return ""; + case DevState.PENDING: return "remote_blue.png"; @@ -87,14 +90,14 @@ case DevState.ERROR: return "tvguide_recordconflict_button.png"; - + + case DevState.COMMAND_ERROR: + return "tvguide_record_button.png"; + case DevState.CONNECTION_ERROR: + default: return "warning-icon.png"; - - default: - case DevState.NONE: - return ""; - + } } @@ -128,7 +131,7 @@ public long getSecondsSince1970() { - return (DateTime.Now.Ticks / 10000000); + return (DateTime.Now.Ticks / TimeSpan.TicksPerSecond); } } } Modified: trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml 2012-01-17 23:05:16 UTC (rev 4407) +++ trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml 2012-01-17 23:06:18 UTC (rev 4408) @@ -222,7 +222,6 @@ <id>15</id> <description>Dimmable Light</description> <type>slider</type> - <id>15</id> <posX>330</posX> <posY>345</posY> <spintype>Int</spintype> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ba...@us...> - 2012-01-17 23:11:46
|
Revision: 4410 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4410&view=rev Author: BartEv Date: 2012-01-17 23:11:40 +0000 (Tue, 17 Jan 2012) Log Message: ----------- Modified Paths: -------------- trunk/plugins/VeraControl/Scene.cs trunk/plugins/VeraControl/VeraCommunication.cs Modified: trunk/plugins/VeraControl/Scene.cs =================================================================== --- trunk/plugins/VeraControl/Scene.cs 2012-01-17 23:11:15 UTC (rev 4409) +++ trunk/plugins/VeraControl/Scene.cs 2012-01-17 23:11:40 UTC (rev 4410) @@ -57,6 +57,7 @@ { vera.status.system.reportCommandError("Unknown scene"); m_bScreenUpdateRequired = true; + return; } reportPendingRequest(); string cmd = "?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum="+id; Modified: trunk/plugins/VeraControl/VeraCommunication.cs =================================================================== --- trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-17 23:11:15 UTC (rev 4409) +++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-17 23:11:40 UTC (rev 4410) @@ -565,14 +565,7 @@ get { return (helper.getSecondsSince1970() - m_lLastUpdate); } set { } } - - /* - public bool metric - { - get { return m_bMetric; } - set { } - } - */ + public List<Scene> scenes { get { return m_status.scenes; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ba...@us...> - 2012-01-21 12:46:03
|
Revision: 4417 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4417&view=rev Author: BartEv Date: 2012-01-21 12:45:56 +0000 (Sat, 21 Jan 2012) Log Message: ----------- Added WebCam movement control support Modified Paths: -------------- trunk/plugins/VeraControl/DeviceCam.cs trunk/plugins/VeraControl/DeviceGeneric.cs trunk/plugins/VeraControl/DialogDeviceControl.cs trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml Modified: trunk/plugins/VeraControl/DeviceCam.cs =================================================================== --- trunk/plugins/VeraControl/DeviceCam.cs 2012-01-21 10:50:48 UTC (rev 4416) +++ trunk/plugins/VeraControl/DeviceCam.cs 2012-01-21 12:45:56 UTC (rev 4417) @@ -18,11 +18,13 @@ { // TODO: add IP-cam control buttons private string m_sIp = "127.0.0.1"; private string m_sUrl = "/"; - private string m_sStream = ""; + private string m_sStream = ""; private string m_sVideoUrl = ""; - private int m_refresh = 10; + private int m_refresh = 2; + private string m_sUser = ""; + private string m_sPass = ""; - public DeviceCam( XmlNode xn ): base (xn) + public DeviceCam( XmlNode xn ): base (xn) { if (xn != null) { @@ -30,22 +32,44 @@ } } - public override bool update(XmlNode xn) + public override bool update(XmlNode xn) { m_sIp = helper.getAttrAsString(xn, "ip", m_sIp); m_sUrl = helper.getAttrAsString(xn, "url", m_sUrl); m_sStream = helper.getAttrAsString(xn, "streaming", m_sStream); m_sVideoUrl = helper.getAttrAsString(xn, "videourls", m_sVideoUrl); + m_sUser = helper.getAttrAsString(xn, "username", ""); + m_sPass = helper.getAttrAsString(xn, "password", ""); - return base.update(xn); + return base.update(xn); } + private string passString + { + get { + if (m_sUser == "") + { + return ""; + } + return m_sUser + ":" + m_sPass + "@"; + } + set { } + } + public string imgUrl { - get { return "http://" + m_sIp + "/" + m_sUrl.Replace("%2F", "/"); } + get { return "http://" + passString + vera.vera_Address + "/data_request?id=cam_image¶meters=get_video_frame&Device_Num=" + id + "&rand=" + DateTime.Now.Ticks; + // return "http://" + passString + m_sIp + "/" + m_sUrl.Replace("%2F", "/"); + } set { } } + public string streamUrl + { + get { return "http://" + passString + m_sIp + "/" + m_sStream.Replace("%2F", "/"); } + set { } + } + public int refreshRate { get { return m_refresh; } @@ -84,5 +108,42 @@ } return b; } + + private void move(string direction) + { + if (id == 0) + { + vera.status.system.reportCommandError("Unknown device"); + m_bScreenUpdateRequired = true; + return; + } + string cmd = "?id=lu_action&DeviceNum=" + id + "&serviceId=urn:micasaverde-com:serviceId:PanTiltZoom1&action=" + direction; + vera.doVeraCommandRequest(cmd, reportRequestError); + } + + public override void moveUp() + { + move("MoveUp"); + } + public override void moveLeft() + { + move("MoveLeft"); + } + public override void moveRight() + { + move("MoveRight"); + } + public override void moveDown() + { + move("MoveDown"); + } + public override void moveZoomIn() + { + move("ZoomIn"); + } + public override void moveZoomOut() + { + move("ZoomOut"); + } } } Modified: trunk/plugins/VeraControl/DeviceGeneric.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-21 10:50:48 UTC (rev 4416) +++ trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-21 12:45:56 UTC (rev 4417) @@ -115,5 +115,31 @@ { return new string [] {"Off", "On"}; } + + // Overrides for Cam Device + public virtual void moveUp() + { + // do nothing + } + public virtual void moveLeft() + { + // do nothing + } + public virtual void moveRight() + { + // do nothing + } + public virtual void moveDown() + { + // do nothing + } + public virtual void moveZoomIn() + { + // do nothing + } + public virtual void moveZoomOut() + { + // do nothing + } } } Modified: trunk/plugins/VeraControl/DialogDeviceControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-21 10:50:48 UTC (rev 4416) +++ trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-21 12:45:56 UTC (rev 4417) @@ -9,6 +9,7 @@ * E-mail: ba...@ev... */ using System; +using System.Threading; using System.Collections; using MediaPortal; using MediaPortal.Util; @@ -35,15 +36,25 @@ [SkinControlAttribute(7)] protected GUILabelControl label2=null; [SkinControlAttribute(8)] protected GUILabelControl label3=null; - [SkinControl(10)] protected GUIButtonControl btnLeft = null; - [SkinControl(11)] protected GUIButtonControl btnRight = null; - [SkinControl(12)] protected GUIButtonControl btnMode1 = null; - [SkinControl(13)] protected GUIButtonControl btnMode2 = null; - [SkinControl(14)] protected GUIButtonControl btnMode3 = null; - [SkinControl(15)] protected GUISliderControl slider = null; - [SkinControl(20)] protected GUIImage camImage = null; + [SkinControl(10)] protected GUIButtonControl btnLeft = null; + [SkinControl(11)] protected GUIButtonControl btnRight = null; + [SkinControl(12)] protected GUIButtonControl btnMode1 = null; + [SkinControl(13)] protected GUIButtonControl btnMode2 = null; + [SkinControl(14)] protected GUIButtonControl btnMode3 = null; + [SkinControl(15)] protected GUISliderControl slider = null; - [SkinControl(30)] protected GUIImage cmtImage = null; + [SkinControl(20)] protected GUIImage camImage1 = null; + [SkinControl(21)] protected GUIImage camImage2 = null; + [SkinControl(50)] protected GUIButtonControl btnCamUp = null; + [SkinControl(51)] protected GUIButtonControl btnCamLeft = null; + [SkinControl(52)] protected GUIButtonControl btnCamRight = null; + [SkinControl(53)] protected GUIButtonControl btnCamDown = null; + [SkinControl(55)] protected GUIButtonControl btnCamZmMin = null; + [SkinControl(56)] protected GUIButtonControl btnCamZmPlus = null; + [SkinControl(57)] protected GUILabelControl labelLoading = null; + + + [SkinControl(30)] protected GUIImage cmtImage = null; [SkinControlAttribute(31)] protected GUILabelControl comment=null; private VeraHelper helper = new VeraHelper(); @@ -52,6 +63,8 @@ private bool m_bLevelUpdatePending = false; private long m_lLastLevelUpdate = 0; private int m_iDesiredLevel = 0; + private bool m_bKeepUpdating = false; + private int _camUpdateDelay = 2; public DialogDeviceControl() { @@ -79,6 +92,22 @@ } updateStatus(); + + if (myDev.GetType() == typeof(DeviceCam)) + { + btnCamUp.Visibility = System.Windows.Visibility.Visible; + btnCamLeft.Visibility = System.Windows.Visibility.Visible; + btnCamRight.Visibility = System.Windows.Visibility.Visible; + btnCamDown.Visibility = System.Windows.Visibility.Visible; + btnCamZmMin.Visibility = System.Windows.Visibility.Visible; + btnCamZmPlus.Visibility = System.Windows.Visibility.Visible; + + btnClose.NavigateDown = 50; + btnClose.NavigateUp = 56; + + imgLogo.Visibility = System.Windows.Visibility.Hidden; + startCamImageUpdater(((DeviceCam)dev).imgUrl); + } } public void updateStatus() @@ -114,11 +143,6 @@ } else { - if (myDev.GetType() == typeof(DeviceCam)) - { - DeviceCam cam = (DeviceCam) myDev; - SetCamImage(cam.imgUrl); - } SetText(myDev.name, myDev.getStatusText(), myDev.getExtraText()); } // save last update ticks @@ -128,6 +152,7 @@ protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (control == btnClose) { + m_bKeepUpdating = false; PageDestroy(); } else { if (control == btnLeft) { @@ -145,6 +170,25 @@ if (control == btnMode3) { myDev.mode = btnMode3.Label; } + // Cam only commands + if (control == btnCamUp) { + myDev.moveUp(); + } + if (control == btnCamLeft) { + myDev.moveLeft(); + } + if (control == btnCamRight) { + myDev.moveRight(); + } + if (control == btnCamDown) { + myDev.moveDown(); + } + if (control == btnCamZmMin) { + myDev.moveZoomOut(); + } + if (control == btnCamZmPlus) { + myDev.moveZoomIn(); + } if (control == slider) { // Do something with fast repeating level changes.... slow down communications m_bLevelUpdatePending = true; @@ -237,17 +281,55 @@ } } - public void SetCamImage(string url) + public int camUpdateDelay { - - camImage.Dispose(); - camImage.SetFileName(url); - camImage.AllocResources(); - camImage.KeepAspectRatio = true; - camImage.Visibility = System.Windows.Visibility.Visible; - imgLogo.Visibility = System.Windows.Visibility.Hidden; + get { return _camUpdateDelay; } + set { _camUpdateDelay = value; } } + public void startCamImageUpdater(string url) + { + m_bKeepUpdating = true; + labelLoading.Visibility = System.Windows.Visibility.Visible; + new Thread (() => + { + while (m_bKeepUpdating) + { + camImage1.Dispose(); + camImage1.SetFileName(url+"&time="+DateTime.Now.Ticks); + camImage1.AllocResources(); + camImage1.KeepAspectRatio = true; + + while (!camImage1.Allocated) + { + Thread.Sleep(100); + } + camImage1.Visibility = System.Windows.Visibility.Visible; + camImage2.Visibility = System.Windows.Visibility.Hidden; + labelLoading.Visibility = System.Windows.Visibility.Hidden; + + Thread.Sleep(_camUpdateDelay * 1000); + + if (m_bKeepUpdating) + { + camImage2.Dispose(); + camImage2.SetFileName(url+"&time="+DateTime.Now.Ticks); + camImage2.AllocResources(); + camImage2.KeepAspectRatio = true; + while (!camImage2.Allocated) + { + Thread.Sleep(100); + } + camImage2.Visibility = System.Windows.Visibility.Visible; + camImage1.Visibility = System.Windows.Visibility.Hidden; + labelLoading.Visibility = System.Windows.Visibility.Hidden; + + Thread.Sleep(_camUpdateDelay * 1000); + } + } + }).Start(); + } + public void SetImage(string filename) { imgLogo.Dispose(); Modified: trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml 2012-01-21 10:50:48 UTC (rev 4416) +++ trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml 2012-01-21 12:45:56 UTC (rev 4417) @@ -237,15 +237,168 @@ </control> <control> + <description>loading label</description> + <type>label</type> + <id>57</id> + <posX>400</posX> + <posY>240</posY> + <label>Loading image...</label> + <font>font13</font> + <textcolor>90FFFFFF</textcolor> + <visible>no</visible> + </control> + <control> <type>image</type> <id>20</id> - <posX>240</posX> + <posX>340</posX> <posY>160</posY> <width>600</width> <height>240</height> <texture></texture> <visible>no</visible> </control> - + <control> + <type>image</type> + <id>21</id> + <posX>340</posX> + <posY>160</posY> + <width>600</width> + <height>240</height> + <texture></texture> + <visible>no</visible> + </control> + <control> + <description>Cam Up</description> + <type>button</type> + <id>50</id> + <posX>190</posX> + <posY>180</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>80</width> + <height>32</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>up</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>51</onleft> + <onright>52</onright> + <onup>2</onup> + <ondown>53</ondown> + <visible>no</visible> + </control> + <control> + <description>Cam left</description> + <type>button</type> + <id>51</id> + <posX>140</posX> + <posY>220</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>80</width> + <height>32</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>left</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>52</onleft> + <onright>52</onright> + <onup>50</onup> + <ondown>52</ondown> + <visible>no</visible> + </control> + <control> + <description>Cam right</description> + <type>button</type> + <id>52</id> + <posX>240</posX> + <posY>220</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>80</width> + <height>32</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>right</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>51</onleft> + <onright>51</onright> + <onup>50</onup> + <ondown>53</ondown> + <visible>no</visible> + </control> + <control> + <description>Cam down</description> + <type>button</type> + <id>53</id> + <posX>190</posX> + <posY>260</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>80</width> + <height>32</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>down</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>51</onleft> + <onright>52</onright> + <onup>50</onup> + <ondown>55</ondown> + <visible>no</visible> + </control> + <control> + <description>Zoom min</description> + <type>button</type> + <id>55</id> + <posX>140</posX> + <posY>320</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>80</width> + <height>32</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>zoom -</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>56</onleft> + <onright>56</onright> + <onup>53</onup> + <ondown>2</ondown> + <visible>no</visible> + </control> + <control> + <description>Zoom plus</description> + <type>button</type> + <id>56</id> + <posX>240</posX> + <posY>320</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>80</width> + <height>32</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>zoom +</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>55</onleft> + <onright>55</onright> + <onup>53</onup> + <ondown>2</ondown> + <visible>no</visible> + </control> + </controls> </window> Modified: trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml 2012-01-21 10:50:48 UTC (rev 4416) +++ trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml 2012-01-21 12:45:56 UTC (rev 4417) @@ -239,15 +239,169 @@ <animation effect="fade" time="250">windowopen</animation> </control> + <control> + <description>loading label</description> + <type>label</type> + <id>57</id> + <posX>630</posX> + <posY>280</posY> + <label>Loading image...</label> + <font>font13</font> + <textcolor>90FFFFFF</textcolor> + <visible>no</visible> + </control> <control> <type>image</type> <id>20</id> - <posX>450</posX> + <posX>550</posX> <posY>200</posY> <width>600</width> <height>300</height> <texture></texture> <visible>no</visible> + </control> + <control> + <type>image</type> + <id>21</id> + <posX>550</posX> + <posY>200</posY> + <width>600</width> + <height>300</height> + <texture></texture> + <visible>no</visible> </control> + <control> + <description>Cam Up</description> + <type>button</type> + <id>50</id> + <posX>335</posX> + <posY>220</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>130</width> + <height>50</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>up</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>51</onleft> + <onright>52</onright> + <onup>2</onup> + <ondown>53</ondown> + <visible>no</visible> + </control> + <control> + <description>Cam left</description> + <type>button</type> + <id>51</id> + <posX>260</posX> + <posY>275</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>130</width> + <height>50</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>left</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>52</onleft> + <onright>52</onright> + <onup>50</onup> + <ondown>52</ondown> + <visible>no</visible> + </control> + <control> + <description>Cam right</description> + <type>button</type> + <id>52</id> + <posX>400</posX> + <posY>275</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>130</width> + <height>50</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>right</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>51</onleft> + <onright>51</onright> + <onup>50</onup> + <ondown>53</ondown> + <visible>no</visible> + </control> + <control> + <description>Cam down</description> + <type>button</type> + <id>53</id> + <posX>335</posX> + <posY>330</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>130</width> + <height>50</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>down</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>51</onleft> + <onright>52</onright> + <onup>50</onup> + <ondown>55</ondown> + <visible>no</visible> + </control> + <control> + <description>Zoom min</description> + <type>button</type> + <id>55</id> + <posX>260</posX> + <posY>420</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>130</width> + <height>50</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>zoom -</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>56</onleft> + <onright>56</onright> + <onup>53</onup> + <ondown>2</ondown> + <visible>no</visible> + </control> + <control> + <description>Zoom plus</description> + <type>button</type> + <id>56</id> + <posX>400</posX> + <posY>420</posY> + <textXOff>29</textXOff> + <textYOff>6</textYOff> + <width>130</width> + <height>50</height> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + <label>zoom +</label> + <font>font10</font> + <textalign>center</textalign> + <textvalign>middle</textvalign> + <onleft>55</onleft> + <onright>55</onright> + <onup>53</onup> + <ondown>2</ondown> + <visible>no</visible> + </control> + </controls> </window> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ba...@us...> - 2012-01-21 23:31:46
|
Revision: 4418 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4418&view=rev Author: BartEv Date: 2012-01-21 23:31:37 +0000 (Sat, 21 Jan 2012) Log Message: ----------- - complied with coding standards - improved update Cam Images handler - cleaned up messy code Modified Paths: -------------- trunk/plugins/VeraControl/BaseDevice.cs trunk/plugins/VeraControl/DevCategories.cs trunk/plugins/VeraControl/DeviceCam.cs trunk/plugins/VeraControl/DeviceDimmer.cs trunk/plugins/VeraControl/DeviceDoorlock.cs trunk/plugins/VeraControl/DeviceGWeather.cs trunk/plugins/VeraControl/DeviceGeneric.cs trunk/plugins/VeraControl/DeviceHumidity.cs trunk/plugins/VeraControl/DeviceLightSensor.cs trunk/plugins/VeraControl/DevicePowerMeter.cs trunk/plugins/VeraControl/DeviceSceneController.cs trunk/plugins/VeraControl/DeviceSecurity.cs trunk/plugins/VeraControl/DeviceSprinkler.cs trunk/plugins/VeraControl/DeviceSwitch.cs trunk/plugins/VeraControl/DeviceSystem.cs trunk/plugins/VeraControl/DeviceTemperature.cs trunk/plugins/VeraControl/DeviceThermostat.cs trunk/plugins/VeraControl/DeviceWindowCovering.cs trunk/plugins/VeraControl/DialogActionTrigger.cs trunk/plugins/VeraControl/DialogDeviceControl.cs trunk/plugins/VeraControl/DialogSceneControl.cs trunk/plugins/VeraControl/Room.cs trunk/plugins/VeraControl/Scene.cs trunk/plugins/VeraControl/Section.cs trunk/plugins/VeraControl/VeraCommunication.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/VeraHelper.cs trunk/plugins/VeraControl/VeraSetupForm.Designer.cs trunk/plugins/VeraControl/VeraSetupForm.cs Modified: trunk/plugins/VeraControl/BaseDevice.cs =================================================================== --- trunk/plugins/VeraControl/BaseDevice.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/BaseDevice.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -18,151 +18,131 @@ /// </summary> public class BaseDevice { - public long m_lLastUpdate = 0; - public long m_lLastPendingUpdate = 0; - public bool m_bScreenUpdateRequired = false; - private string m_sName = "unknown device"; - private int m_iId = 0; - private int m_iRoom = 0; + public long _lastUpdate = 0; + public long _lastPendingUpdate = 0; + public bool _screenUpdateRequired = false; + private string _name = "unknown device"; + private int _id = 0; + private int _room = 0; // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) - private DevState m_dsState = DevState.NONE; - private string m_sComment = ""; // red(error), green(success) or blue(pending) - icon/text + private DevState _dsState = DevState.NONE; + private string _comment = ""; // red(error), green(success) or blue(pending) - icon/text - public VeraHelper helper = VeraHelper.Instance; - public VeraCommunication vera = VeraCommunication.Instance; + public VeraHelper _helper = VeraHelper.Instance; + public VeraCommunication _vera = VeraCommunication.Instance; public BaseDevice(XmlNode xn) { if (xn != null) { - update(xn); + Update(xn); } } /// <summary> /// Process Vera update information /// </summary> - public virtual bool update(XmlNode xn) + public virtual bool Update(XmlNode xn) { - m_sName = helper.getAttrAsString(xn, "name", m_sName); - m_iId = helper.getAttrAsInt (xn, "id", m_iId); - m_iRoom = helper.getAttrAsInt (xn, "room", m_iRoom); + _name = _helper.GetAttrAsString(xn, "name", _name); + _id = _helper.GetAttrAsInt (xn, "id", _id); + _room = _helper.GetAttrAsInt (xn, "room", _room); - string temp_sComment = helper.getAttrAsString(xn, "comment", m_sComment ); - DevState temp_dsState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1)); - if (m_dsState != DevState.PENDING || temp_dsState != DevState.NONE || (temp_dsState == DevState.NONE && ((m_lLastPendingUpdate / TimeSpan.TicksPerSecond ) < (DateTime.Now.Ticks / TimeSpan.TicksPerSecond)))) + string tempComment = _helper.GetAttrAsString(xn, "comment", _comment ); + DevState tempDsState = _helper.ToDevState(_helper.GetAttrAsInt(xn, "state", -1)); + if (_dsState != DevState.PENDING || tempDsState != DevState.NONE || (tempDsState == DevState.NONE && ((_lastPendingUpdate / TimeSpan.TicksPerSecond ) < (DateTime.Now.Ticks / TimeSpan.TicksPerSecond)))) { // If state was set to pending next update should contain a new state or still pending - so do not clear pending flag for at least 10 seconds - m_sComment = temp_sComment; - m_dsState = temp_dsState; + _comment = tempComment; + _dsState = tempDsState; } - if (m_iId == 0) + if (_id == 0) { // void device no further processing needed return false; } // Set update flag - m_bScreenUpdateRequired = true; - m_lLastUpdate = DateTime.Now.Ticks; + _screenUpdateRequired = true; + _lastUpdate = DateTime.Now.Ticks; return true; } - /// <summary> - /// Returns the id of this device - /// </summary> public int id { - get { return m_iId; } + get { return _id; } set { } } - /// <summary> - /// Returns the name of this device - /// </summary> public string name { - get { return m_sName; } + get { return _name; } set { } } - /// <summary> - /// Returns true when this device is associated with the given room - /// </summary> - public bool inRoom(int id) + public bool InRoom(int id) { - return (m_iRoom == id); + return (_room == id); } - /// <summary> - /// Return the room is this device is associated with - /// </summary> public int room { - get { return m_iRoom; } - set { m_iRoom = value; } + get { return _room; } + set { _room = value; } } - /// <summary> - /// Return the communications state for this device - /// </summary> public DevState commstate { - get { return m_dsState; } + get { return _dsState; } set { } } - /// <summary> - /// Return the comment as reported by Vera for this device - /// </summary> public string comment { - get { return (commstate != DevState.NONE ? m_sComment : ""); } + get { return (commstate != DevState.NONE ? _comment : ""); } set { } } - /// <summary> - /// Set virtual device state to pending request - /// </summary> - public void reportPendingRequest() + public void ReportPendingRequest() { - m_dsState = DevState.PENDING; - m_sComment = "Sending command..."; - m_bScreenUpdateRequired = true; - m_lLastUpdate = DateTime.Now.Ticks; - m_lLastPendingUpdate = m_lLastUpdate; + _dsState = DevState.PENDING; + _comment = "Sending command..."; + _screenUpdateRequired = true; + _lastUpdate = DateTime.Now.Ticks; + _lastPendingUpdate = _lastUpdate; } /// <summary> /// Callback function for Ansync Web Client call on to report errors... /// </summary> - public void reportRequestError(string message) + public void ReportRequestError(string message) { - m_dsState = DevState.COMMAND_ERROR; - m_sComment = message; - m_bScreenUpdateRequired = true; - m_lLastUpdate = DateTime.Now.Ticks; + _dsState = DevState.COMMAND_ERROR; + _comment = message; + _screenUpdateRequired = true; + _lastUpdate = DateTime.Now.Ticks; } - public void clearCommState() + public void ClearCommState() { - m_dsState = DevState.NONE; + _dsState = DevState.NONE; } + /// <summary> /// True when an update was processed after the give time stamp /// </summary> - public virtual bool newUpdateSince(long lTimePreviousCheck) + public virtual bool NewUpdateSince(long timePreviousCheck) { - return (lTimePreviousCheck <= m_lLastUpdate); + return (timePreviousCheck <= _lastUpdate); } /// <summary> /// Invoking this method will clear the update ready flag -> so caller need to handle the screen update /// </summary> - public virtual bool newScreenUpdateWaitingAndClearFlag( ) + public virtual bool NewScreenUpdateWaitingAndClearFlag() { - bool b = m_bScreenUpdateRequired; - m_bScreenUpdateRequired = false; + bool b = _screenUpdateRequired; + _screenUpdateRequired = false; return b; } @@ -170,6 +150,5 @@ { return name; } - } } Modified: trunk/plugins/VeraControl/DevCategories.cs =================================================================== --- trunk/plugins/VeraControl/DevCategories.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DevCategories.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -22,30 +22,30 @@ { if (xn != null) { - update(xn); + Update(xn); } } - private string m_sName = "unknown category"; - private int m_iId = 0; - public VeraHelper helper = VeraHelper.Instance; + private string _name = "unknown category"; + private int _id = 0; + public VeraHelper _helper = VeraHelper.Instance; - public bool update(XmlNode xn) + public bool Update(XmlNode xn) { - m_sName = helper.getAttrAsString(xn, "name", m_sName); - m_iId = helper.getAttrAsInt (xn, "id", m_iId); + _name = _helper.GetAttrAsString(xn, "name", _name); + _id = _helper.GetAttrAsInt (xn, "id", _id); return true; } public int id { - get { return m_iId; } + get { return _id; } set { } } public string name { - get { return m_sName; } + get { return _name; } set { } } Modified: trunk/plugins/VeraControl/DeviceCam.cs =================================================================== --- trunk/plugins/VeraControl/DeviceCam.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceCam.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -15,50 +15,50 @@ /// Description of DeviceCam. /// </summary> public class DeviceCam : DeviceGeneric - { // TODO: add IP-cam control buttons - private string m_sIp = "127.0.0.1"; - private string m_sUrl = "/"; - private string m_sStream = ""; - private string m_sVideoUrl = ""; - private int m_refresh = 2; - private string m_sUser = ""; - private string m_sPass = ""; + { + private string _ip = "127.0.0.1"; + private string _url = "/"; + private string _stream = ""; + private string _videoUrl = ""; + private int _refreshRate = 2; + private string _user = ""; + private string _pass = ""; - public DeviceCam( XmlNode xn ): base (xn) + public DeviceCam(XmlNode xn): base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_sIp = helper.getAttrAsString(xn, "ip", m_sIp); - m_sUrl = helper.getAttrAsString(xn, "url", m_sUrl); - m_sStream = helper.getAttrAsString(xn, "streaming", m_sStream); - m_sVideoUrl = helper.getAttrAsString(xn, "videourls", m_sVideoUrl); - m_sUser = helper.getAttrAsString(xn, "username", ""); - m_sPass = helper.getAttrAsString(xn, "password", ""); + _ip = _helper.GetAttrAsString(xn, "ip", _ip); + _url = _helper.GetAttrAsString(xn, "url", _url); + _stream = _helper.GetAttrAsString(xn, "streaming", _stream); + _videoUrl = _helper.GetAttrAsString(xn, "videourls", _videoUrl); + _user = _helper.GetAttrAsString(xn, "username", ""); + _pass = _helper.GetAttrAsString(xn, "password", ""); - return base.update(xn); + return base.Update(xn); } private string passString { get { - if (m_sUser == "") + if (_user == "") { return ""; } - return m_sUser + ":" + m_sPass + "@"; + return _user + ":" + _pass + "@"; } set { } } public string imgUrl { - get { return "http://" + passString + vera.vera_Address + "/data_request?id=cam_image¶meters=get_video_frame&Device_Num=" + id + "&rand=" + DateTime.Now.Ticks; + get { return "http://" + passString + _vera.veraAddress + "/data_request?id=cam_image¶meters=get_video_frame&Device_Num=" + id + "&rand=" + DateTime.Now.Ticks; // return "http://" + passString + m_sIp + "/" + m_sUrl.Replace("%2F", "/"); } set { } @@ -66,84 +66,84 @@ public string streamUrl { - get { return "http://" + passString + m_sIp + "/" + m_sStream.Replace("%2F", "/"); } + get { return "http://" + passString + _ip + "/" + _stream.Replace("%2F", "/"); } set { } } public int refreshRate { - get { return m_refresh; } - set { m_refresh = value; } + get { return _refreshRate; } + set { _refreshRate = value; } } - private bool refreshDelayPassed(long lastcheck) + private bool HasRefreshDelayPassed(long lastcheck) { - return ((helper.getSecondsSince1970() - refreshRate) > (lastcheck / TimeSpan.TicksPerSecond)); + return ((_helper.GetSecondsSince1970() - refreshRate) > (lastcheck / TimeSpan.TicksPerSecond)); } - public override string getIconName() + public override string GetIconName() { return "Ip_Camera"; } - public override bool newScreenUpdateWaitingAndClearFlag( ) + public override bool NewScreenUpdateWaitingAndClearFlag( ) { // Invoking this method will clear the update ready flag -> so caller need to handle the update // A cam device requires an update every refreshRate seconds - bool b = m_bScreenUpdateRequired || refreshDelayPassed(DateTime.Now.Ticks); - m_bScreenUpdateRequired = false; + bool b = _screenUpdateRequired || HasRefreshDelayPassed(DateTime.Now.Ticks); + _screenUpdateRequired = false; if (b) { - m_lLastUpdate = DateTime.Now.Ticks; + _lastUpdate = DateTime.Now.Ticks; } return b; } - public override bool newUpdateSince(long lTimePreviousCheck) + public override bool NewUpdateSince(long lTimePreviousCheck) { - bool b = (lTimePreviousCheck <= m_lLastUpdate) || refreshDelayPassed(m_lLastUpdate); + bool b = (lTimePreviousCheck <= _lastUpdate) || HasRefreshDelayPassed(_lastUpdate); if (b) { - m_lLastUpdate = DateTime.Now.Ticks; + _lastUpdate = DateTime.Now.Ticks; } return b; } - private void move(string direction) + private void Move(string direction) { if (id == 0) { - vera.status.system.reportCommandError("Unknown device"); - m_bScreenUpdateRequired = true; + _vera.status.system.ReportCommandError("Unknown device"); + _screenUpdateRequired = true; return; } string cmd = "?id=lu_action&DeviceNum=" + id + "&serviceId=urn:micasaverde-com:serviceId:PanTiltZoom1&action=" + direction; - vera.doVeraCommandRequest(cmd, reportRequestError); + _vera.DoVeraCommandRequest(cmd, ReportRequestError); } - public override void moveUp() + public override void MoveUp() { - move("MoveUp"); + Move("MoveUp"); } - public override void moveLeft() + public override void MoveLeft() { - move("MoveLeft"); + Move("MoveLeft"); } - public override void moveRight() + public override void MoveRight() { - move("MoveRight"); + Move("MoveRight"); } - public override void moveDown() + public override void MoveDown() { - move("MoveDown"); + Move("MoveDown"); } - public override void moveZoomIn() + public override void ZoomIn() { - move("ZoomIn"); + Move("ZoomIn"); } - public override void moveZoomOut() + public override void ZoomOut() { - move("ZoomOut"); + Move("ZoomOut"); } } } Modified: trunk/plugins/VeraControl/DeviceDimmer.cs =================================================================== --- trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -4,8 +4,8 @@ * Date: 22-12-2011 * Time: 17:36 * - * Copyright: 2012 GPL - Bart Eversdijk - * MediaPort plugin - MicasaVerde (TM) Vera Controller + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller * E-mail: ba...@ev... */ using System; @@ -18,45 +18,45 @@ /// </summary> public class DeviceDimmer : DeviceGeneric { - private int m_iLevel = 0; - private string m_sWatt = "-"; - private string m_sKwh = "-"; + private int _level = 0; + private string _watt = "-"; + private string _kwh = "-"; - public DeviceDimmer( XmlNode xn ): base (xn) + public DeviceDimmer(XmlNode xn): base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_iLevel = helper.getAttrAsInt (xn, "level", m_iLevel); - m_sWatt = helper.getAttrAsString(xn, "watts", m_sWatt); - m_sKwh = helper.getAttrAsString(xn, "kwh", m_sKwh); + _level = _helper.GetAttrAsInt (xn, "level", _level); + _watt = _helper.GetAttrAsString(xn, "watts", _watt); + _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh); - return base.update(xn); + return base.Update(xn); } public string watts { - get { return m_sWatt; } + get { return _watt; } set { } } public override bool status { - get { return (m_iLevel > 0); } - set { - + get { return (_level > 0); } + set { + } } public override int level { - get { return m_iLevel; } - set + get { return _level; } + set { int newValue = value; if (newValue > 100) { @@ -65,15 +65,15 @@ if (newValue < 0) { newValue = 0; } } if (id > 0) // Only send when a valid ID is found - { - reportPendingRequest(); + { + ReportPendingRequest(); // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + string cmd = "?id=lu_action&DeviceNum="+id.ToString() + "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget" + - "&newLoadlevelTarget="+value; - vera.doVeraCommandRequest(cmd, reportRequestError); + "&newLoadlevelTarget=" + value; + _vera.DoVeraCommandRequest(cmd, ReportRequestError); } - m_iLevel = newValue; + _level = newValue; } } @@ -85,7 +85,7 @@ public override string ToString() { - return name + " [" + getStatusText() + "]"; + return name + " [" + GetStatusText() + "]"; } public override bool isControllable @@ -94,7 +94,7 @@ set { } } - public override string getIconName() + public override string GetIconName() { string leveltxt = "0"; if (level > 0) { leveltxt = "25"; } @@ -102,18 +102,18 @@ if (level > 50) { leveltxt = "75"; } if (level > 75) { leveltxt = "100"; } - return "Dimmable_Light_"+leveltxt; + return "Dimmable_Light_" + leveltxt; } - public override string getExtraText() + public override string GetExtraText() { - return (m_sKwh != "" ? m_sKwh + "kWh" : ""); + return (_kwh != "" ? _kwh + "kWh" : ""); } - public override string getStatusText() + public override string GetStatusText() { - return ( status ? level.ToString() + "%" : "Off"); + return (status ? level.ToString() + "%" : "Off"); } } } Modified: trunk/plugins/VeraControl/DeviceDoorlock.cs =================================================================== --- trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -18,42 +18,42 @@ /// </summary> public class DeviceDoorlock : DeviceGeneric { - private bool m_bStatus = false; + private bool _status = false; public DeviceDoorlock( XmlNode xn ): base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_bStatus = helper.getAttrAsBool(xn, "status", m_bStatus); + _status = _helper.GetAttrAsBool(xn, "status", _status); - return base.update(xn); + return base.Update(xn); } public override bool status { - get { return m_bStatus; } + get { return _status; } set { if (id > 0) // Only send when a valid ID is found { - reportPendingRequest(); + ReportPendingRequest(); // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ "&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget" + "&newTargetValue="+(value ? "1" : "0"); - vera.doVeraCommandRequest(cmd, reportRequestError); + _vera.DoVeraCommandRequest(cmd, ReportRequestError); } } } public override int level { - get { return (m_bStatus ? 1 : 0); } + get { return (_status ? 1 : 0); } set { status = (value > 0); @@ -68,7 +68,7 @@ public override string ToString() { - return name + " [" + getStatusText() + "]"; + return name + " [" + GetStatusText() + "]"; } public override bool isControllable @@ -77,12 +77,12 @@ set { } } - public override string getIconName() + public override string GetIconName() { - return "Door_" + (m_bStatus ? "LOCKED" : "UNLOCKED"); + return "Door_" + (_status ? "LOCKED" : "UNLOCKED"); } - public override string getStatusText() + public override string GetStatusText() { return (status ? "Locked" : "Unlocked"); } Modified: trunk/plugins/VeraControl/DeviceGWeather.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGWeather.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceGWeather.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -18,42 +18,42 @@ /// </summary> public class DeviceGWeather : DeviceGeneric { - private string m_sCondition = "-"; - private string m_sWindCondition = "-"; + private string _condition = "-"; + private string _windCondition = "-"; - public DeviceGWeather( XmlNode xn ): base (xn) + public DeviceGWeather(XmlNode xn): base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_sCondition = helper.getAttrAsString(xn, "Condition", m_sCondition); // Google Weather Plugin - m_sCondition = helper.getAttrAsString(xn, "condition", m_sCondition); // World Weather plugin - m_sWindCondition = helper.getAttrAsString(xn, "WindCondition", m_sWindCondition); - m_sWindCondition = helper.getAttrAsString(xn, "windcondition", m_sWindCondition); + _condition = _helper.GetAttrAsString(xn, "Condition", _condition); // Google Weather Plugin + _condition = _helper.GetAttrAsString(xn, "condition", _condition); // World Weather plugin + _windCondition = _helper.GetAttrAsString(xn, "WindCondition", _windCondition); + _windCondition = _helper.GetAttrAsString(xn, "windcondition", _windCondition); - return base.update(xn); + return base.Update(xn); } public override string ToString() { - return name + " [" + getStatusText() + "]"; + return name + " [" + GetStatusText() + "]"; } - public override string getStatusText() + public override string GetStatusText() { - return m_sCondition.Replace("_", " "); + return _condition.Replace("_", " "); } - public override string getExtraText() + public override string GetExtraText() { - return m_sWindCondition; + return _windCondition; } - public override string getIconName() + public override string GetIconName() { return "location"; } Modified: trunk/plugins/VeraControl/DeviceGeneric.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -19,29 +19,29 @@ /// </summary> public class DeviceGeneric : BaseDevice { - private string m_sAltId = ""; - private int m_iCategory = 0; + private string _altId = ""; + private int _category = 0; public DeviceGeneric(XmlNode xn): base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_sAltId = helper.getAttrAsString(xn, "altid", m_sAltId); - m_iCategory = helper.getAttrAsInt (xn, "category", m_iCategory); + _altId = _helper.GetAttrAsString(xn, "altid", _altId); + _category = _helper.GetAttrAsInt (xn, "category", _category); - bool b = base.update(xn); + bool b = base.Update(xn); // Make sure the room exists - if (room == 0 || !vera.status.isRoomFound(room)) + if (room == 0 || !_vera.status.IsRoomFound(room)) { - if (!vera.status.isRoomFound(0)) + if (!_vera.status.IsRoomFound(0)) { // create dummy room to attach to - vera.rooms.Add(new Room(null)); + _vera.rooms.Add(new Room(null)); } room = 0; } @@ -51,13 +51,13 @@ public string altid { - get { return m_sAltId; } + get { return _altId; } set { } } public int category { - get { return m_iCategory; } + get { return _category; } set { } } @@ -96,48 +96,48 @@ set { } } - public virtual string getIconName() + public virtual string GetIconName() { return "generic_sensor"; } - public virtual string getStatusText() + public virtual string GetStatusText() { return ""; } - public virtual string getExtraText() + public virtual string GetExtraText() { return ""; } - public virtual string[] getCommands() + public virtual string [] GetCommands() { return new string [] {"Off", "On"}; } - // Overrides for Cam Device - public virtual void moveUp() + // Overridables for Cam Device + public virtual void MoveUp() { // do nothing } - public virtual void moveLeft() + public virtual void MoveLeft() { // do nothing } - public virtual void moveRight() + public virtual void MoveRight() { // do nothing } - public virtual void moveDown() + public virtual void MoveDown() { // do nothing } - public virtual void moveZoomIn() + public virtual void ZoomIn() { // do nothing } - public virtual void moveZoomOut() + public virtual void ZoomOut() { // do nothing } Modified: trunk/plugins/VeraControl/DeviceHumidity.cs =================================================================== --- trunk/plugins/VeraControl/DeviceHumidity.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceHumidity.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -18,25 +18,25 @@ /// </summary> public class DeviceHumidity : DeviceGeneric { - private int m_iLevel = 0; + private int _level = 0; - public DeviceHumidity( XmlNode xn ): base (xn) + public DeviceHumidity(XmlNode xn): base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_iLevel = helper.getAttrAsInt(xn, "humidity", m_iLevel); - return base.update(xn); + _level = _helper.GetAttrAsInt(xn, "humidity", _level); + return base.Update(xn); } public override int level { - get { return m_iLevel; } + get { return _level; } set {} } @@ -51,12 +51,12 @@ return name + " [" + level.ToString() + "%]"; } - public override string getIconName() + public override string GetIconName() { return "Humidity_Sensor"; } - public override string getStatusText() + public override string GetStatusText() { return level + "%"; } Modified: trunk/plugins/VeraControl/DeviceLightSensor.cs =================================================================== --- trunk/plugins/VeraControl/DeviceLightSensor.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceLightSensor.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -18,32 +18,32 @@ /// </summary> public class DeviceLightSensor : DeviceGeneric { - private int m_iLevel = 0; + private int _level = 0; - public DeviceLightSensor( XmlNode xn ): base (xn) + public DeviceLightSensor(XmlNode xn): base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_iLevel = helper.getAttrAsInt(xn, "level", m_iLevel); - m_iLevel = helper.getAttrAsInt(xn, "light", m_iLevel); - return base.update(xn); + _level = _helper.GetAttrAsInt(xn, "level", _level); + _level = _helper.GetAttrAsInt(xn, "light", _level); + return base.Update(xn); } public override bool status { - get { return (m_iLevel > 0); } + get { return (_level > 0); } set { } } public override int level { - get { return m_iLevel; } + get { return _level; } set { } } @@ -55,15 +55,15 @@ public override string ToString() { - return name + " [" + getStatusText() + "]"; + return name + " [" + GetStatusText() + "]"; } - public override string getIconName() + public override string GetIconName() { return "Light_Sensor"; } - public override string getStatusText() + public override string GetStatusText() { return level.ToString() + "%"; } Modified: trunk/plugins/VeraControl/DevicePowerMeter.cs =================================================================== --- trunk/plugins/VeraControl/DevicePowerMeter.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DevicePowerMeter.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -18,39 +18,39 @@ /// </summary> public class DevicePowerMeter : DeviceGeneric { - private int m_iLevel = 0; - private string m_sKwh = ""; + private int _level = 0; + private string _kwh = ""; - public DevicePowerMeter( XmlNode xn ): base (xn) + public DevicePowerMeter(XmlNode xn): base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_iLevel = helper.getAttrAsInt (xn, "watts", m_iLevel); - m_sKwh = helper.getAttrAsString(xn, "kwh", m_sKwh); - return base.update(xn); + _level = _helper.GetAttrAsInt (xn, "watts", _level); + _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh); + return base.Update(xn); } public string watts { - get { return m_iLevel.ToString(); } + get { return _level.ToString(); } set { } } public override bool status { - get { return (m_iLevel > 0); } + get { return (_level > 0); } set { } } public override int level { - get { return m_iLevel; } + get { return _level; } set { } } @@ -62,20 +62,20 @@ public override string ToString() { - return name + " [" + getStatusText() + "]"; + return name + " [" + GetStatusText() + "]"; } - public override string getIconName() + public override string GetIconName() { return "Power_Meter"; } - public override string getExtraText() + public override string GetExtraText() { - return (m_sKwh != "" ? m_sKwh + "kWh" : ""); + return (_kwh != "" ? _kwh + "kWh" : ""); } - public override string getStatusText() + public override string GetStatusText() { return level.ToString() + "W"; } Modified: trunk/plugins/VeraControl/DeviceSceneController.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSceneController.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceSceneController.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -16,52 +16,52 @@ /// </summary> public class DeviceSceneController: DeviceGeneric { - private bool m_bTripped = false; + private bool _isTripped = false; public DeviceSceneController( XmlNode xn ): base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_bTripped = helper.getAttrAsBool(xn, "status", m_bTripped); - m_bTripped = helper.getAttrAsBool(xn, "tripped", m_bTripped); - return base.update(xn); + _isTripped = _helper.GetAttrAsBool(xn, "status", _isTripped); + _isTripped = _helper.GetAttrAsBool(xn, "tripped", _isTripped); + return base.Update(xn); } public override bool status { - get { return m_bTripped; } + get { return _isTripped; } set { } } - public bool tripped + public bool isTripped { - get { return m_bTripped; } + get { return _isTripped; } set { } } public override int level { - get { return (m_bTripped ? 1 : 0); } + get { return (_isTripped ? 1 : 0); } set { } } public override string ToString() { - return name + " [" + getStatusText() + "]"; + return name + " [" + GetStatusText() + "]"; } - public override string getIconName() + public override string GetIconName() { - return "Motion_Sensor_" + (m_bTripped ? "100" : "0"); + return "Motion_Sensor_" + (_isTripped ? "100" : "0"); } - public override string getStatusText() + public override string GetStatusText() { return (status ? "ACTIVE" : "standby"); } Modified: trunk/plugins/VeraControl/DeviceSecurity.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSecurity.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceSecurity.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -17,52 +17,52 @@ /// <summary> /// Description of DeviceSecurity. /// </summary> - public class DeviceSecurity: DeviceGeneric + public class DeviceSecurity : DeviceGeneric { - private bool m_bTripped = false; - private bool m_bArmed = true; + private bool _isTripped = false; + private bool _isArmed = true; - public DeviceSecurity( XmlNode xn ): base (xn) + public DeviceSecurity(XmlNode xn): base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_bTripped = helper.getAttrAsBool(xn, "tripped", m_bTripped); - m_bArmed = helper.getAttrAsBool(xn, "armed", m_bArmed); - return base.update(xn); + _isTripped = _helper.GetAttrAsBool(xn, "tripped", _isTripped); + _isArmed = _helper.GetAttrAsBool(xn, "armed", _isArmed); + return base.Update(xn); } public override bool status { - get { return m_bArmed; } + get { return _isArmed; } set { if (id > 0) // Only send when a valid ID is found { - reportPendingRequest(); + ReportPendingRequest(); // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ "&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&action=SetArmed" + "&newArmedValue=" + (value ? "1" : "0"); - vera.doVeraCommandRequest(cmd, reportRequestError); + _vera.DoVeraCommandRequest(cmd, ReportRequestError); } } } - public bool tripped + public bool isTripped { - get { return m_bTripped; } + get { return _isTripped; } set { } } public override int level { - get { return (m_bArmed ? 1 : 0); } - set { status = (value > 0); } + get { return (_isArmed ? 1 : 0); } + set { status = (value > 0); } } public override int maxLevel @@ -77,20 +77,20 @@ } public override string ToString() { - return name + " [" + getStatusText() + "]"; + return name + " [" + GetStatusText() + "]"; } - public override string getIconName() + public override string GetIconName() { - return "Motion_Sensor_" + (m_bTripped ? "100" : "0"); + return "Motion_Sensor_" + (_isTripped ? "100" : "0"); } - public override string getStatusText() + public override string GetStatusText() { - return (status ? ( tripped ? "TRIPPED" : "standby") : "bypass"); + return (status ? ( isTripped ? "TRIPPED" : "standby") : "bypass"); } - public override string[] getCommands() + public override string [] GetCommands() { return new string [] {"Bypass", "Arm"}; } Modified: trunk/plugins/VeraControl/DeviceSprinkler.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -19,71 +19,71 @@ /// </summary> public class DeviceSprinkler : DeviceGeneric { - private bool m_bStatus = false; - private string m_sMode = "-"; - private string m_sShortMode = "-"; - private string m_sOperationMode = "-"; - private string m_sCondition = "-"; + private bool _status = false; + private string _mode = "-"; + private string _shortMode = "-"; + private string _operationMode = "-"; + private string _condition = "-"; - public DeviceSprinkler( XmlNode xn ): base (xn) + public DeviceSprinkler(XmlNode xn): base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_bStatus = helper.getAttrAsBool (xn, "status", m_bStatus); - m_sMode = helper.getAttrAsString(xn, "Mode", m_sMode); - m_sShortMode = helper.getAttrAsString(xn, "ShortMode", m_sShortMode); - m_sOperationMode = helper.getAttrAsString(xn, "OperationMode", m_sOperationMode); - m_sCondition = helper.getAttrAsString(xn, "Condition", m_sCondition); - return base.update(xn); + _status = _helper.GetAttrAsBool (xn, "status", _status); + _mode = _helper.GetAttrAsString(xn, "Mode", _mode); + _shortMode = _helper.GetAttrAsString(xn, "ShortMode", _shortMode); + _operationMode = _helper.GetAttrAsString(xn, "OperationMode", _operationMode); + _condition = _helper.GetAttrAsString(xn, "Condition", _condition); + return base.Update(xn); } public override bool status { - get { return m_bStatus; } + get { return _status; } set { if (id > 0) // Only send when a valid ID is found { - reportPendingRequest(); + ReportPendingRequest(); // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + "&newTargetValue="+(value ? "1" : "0"); - vera.doVeraCommandRequest(cmd, reportRequestError); + _vera.DoVeraCommandRequest(cmd, ReportRequestError); } } } public override int level { - get { return (m_bStatus ? 1 : 0); } + get { return (_status ? 1 : 0); } set { status = (value > 0); } } public override string mode { - get { return m_sMode; } + get { return _mode; } set { if (id > 0) // Only send when a valid ID is found { - reportPendingRequest(); + ReportPendingRequest(); // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ "&serviceId=urn:upnp-micasaverde-com:serviceId:Sprinkler1&action=" + (value == "Auto" ? "SetModeAuto" : (value == "Block" ? "SetModeBlock" : "SetModeManual")); - vera.doVeraCommandRequest(cmd, reportRequestError); + _vera.DoVeraCommandRequest(cmd, ReportRequestError); } } } public override string ToString() { - return name + " [" + m_sShortMode + "]"; + return name + " [" + _shortMode + "]"; } public override bool isControllable @@ -98,22 +98,22 @@ set { } } - public override string getIconName() + public override string GetIconName() { return "Humidity_Sensor"; } - public override string getStatusText() + public override string GetStatusText() { - return m_sOperationMode.Replace("_", " "); + return _operationMode.Replace("_", " "); } - public override string getExtraText() + public override string GetExtraText() { - return m_sCondition; + return _condition; } - public override string [] getCommands() + public override string [] GetCommands() { return new string [] {"Off", "On", "Auto", "Block", "Manual"}; } Modified: trunk/plugins/VeraControl/DeviceSwitch.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSwitch.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceSwitch.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -18,52 +18,52 @@ /// </summary> public class DeviceSwitch : DeviceGeneric { - private bool m_bStatus = false; - private string m_sWatt = "-"; - private string m_sKwh = "-"; + private bool _status = false; + private string _watt = "-"; + private string _kwh = "-"; - public DeviceSwitch( XmlNode xn ): base (xn) + public DeviceSwitch(XmlNode xn): base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_bStatus = helper.getAttrAsBool (xn, "status", m_bStatus); - m_sWatt = helper.getAttrAsString(xn, "watts", m_sWatt); - m_sKwh = helper.getAttrAsString(xn, "kwh", m_sKwh); + _status = _helper.GetAttrAsBool (xn, "status", _status); + _watt = _helper.GetAttrAsString(xn, "watts", _watt); + _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh); - return base.update(xn); + return base.Update(xn); } public string watts { - get { return m_sWatt; } + get { return _watt; } set { } } public override bool status { - get { return m_bStatus; } + get { return _status; } set { if (id > 0) // Only send when a valid ID is found { - reportPendingRequest(); + ReportPendingRequest(); // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + "&newTargetValue="+(value ? "1" : "0"); - vera.doVeraCommandRequest(cmd, reportRequestError); + _vera.DoVeraCommandRequest(cmd, ReportRequestError); } } } public override int level { - get { return (m_bStatus ? 1 : 0); } + get { return (_status ? 1 : 0); } set { status = (value > 0); } } @@ -75,7 +75,7 @@ public override string ToString() { - return name + " [" + getStatusText()+ "]"; + return name + " [" + GetStatusText()+ "]"; } public override bool isControllable @@ -84,17 +84,17 @@ set { } } - public override string getIconName() + public override string GetIconName() { - return "Binary_Light_" + (m_bStatus ? "100" : "0"); + return "Binary_Light_" + (_status ? "100" : "0"); } - public override string getExtraText() + public override string GetExtraText() { - return (m_sKwh != "" ? m_sKwh + "kWh" : ""); + return (_kwh != "" ? _kwh + "kWh" : ""); } - public override string getStatusText() + public override string GetStatusText() { return (status ? "On" : "Off"); } Modified: trunk/plugins/VeraControl/DeviceSystem.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSystem.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceSystem.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -21,165 +21,165 @@ { } - public VeraHelper helper = VeraHelper.Instance; + public VeraHelper _helper = VeraHelper.Instance; - public long m_lLastUpdate = 0; - public bool m_bScreenUpdateRequired = false; - private bool m_bFullReload = true; - private string m_sVersion = ""; - private string m_sModel = ""; - private bool m_zWaveHeal = false; - private bool m_bMetric = true; - private string m_sSerial = ""; - private string m_sFwd1Server = ""; - private string m_sFwd2Server = ""; - private string m_sLoadTime = "0"; - private string m_sDataVersion = "0"; - private string m_sComment = ""; - private DevState m_dsVeraState = DevState.NONE; + public long _lastUpdate = 0; + public bool _screenUpdateRequired = false; + private bool _fullReload = true; + private string _version = ""; + private string _model = ""; + private bool _zWaveHeal = false; + private bool _metric = true; + private string _serial = ""; + private string _fwd1Server = ""; + private string _fwd2Server = ""; + private string _loadTime = "0"; + private string _dataVersion = "0"; + private string _comment = ""; + private DevState _dsVeraState = DevState.NONE; public bool update(XmlNode xn) { - m_bFullReload = helper.getAttrAsBool (xn, "full", m_bFullReload); - m_sVersion = helper.getAttrAsString (xn, "version", m_sVersion); - m_sModel = helper.getAttrAsString (xn, "model", m_sModel); - m_zWaveHeal = helper.getAttrAsBool (xn, "zwave_heal", m_zWaveHeal); - m_sSerial = helper.getAttrAsString (xn, "serial_number", m_sSerial); - m_sFwd1Server = helper.getAttrAsString (xn, "fwd1", m_sFwd1Server); - m_sFwd2Server = helper.getAttrAsString (xn, "fwd2", m_sFwd2Server); - m_sLoadTime = helper.getAttrAsString (xn, "loadtime", m_sLoadTime); + _fullReload = _helper.GetAttrAsBool (xn, "full", _fullReload); + _version = _helper.GetAttrAsString (xn, "version", _version); + _model = _helper.GetAttrAsString (xn, "model", _model); + _zWaveHeal = _helper.GetAttrAsBool (xn, "zwave_heal", _zWaveHeal); + _serial = _helper.GetAttrAsString (xn, "serial_number", _serial); + _fwd1Server = _helper.GetAttrAsString (xn, "fwd1", _fwd1Server); + _fwd2Server = _helper.GetAttrAsString (xn, "fwd2", _fwd2Server); + _loadTime = _helper.GetAttrAsString (xn, "loadtime", _loadTime); // Set update flag - string tempDataversion = helper.getAttrAsString (xn, "dataversion", m_sDataVersion); - DevState tempVeraState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1)); - string tempComment = helper.getAttrAsString (xn, "comment", ""); + string tempDataversion = _helper.GetAttrAsString (xn, "dataversion", _dataVersion); + DevState tempVeraState = _helper.ToDevState(_helper.GetAttrAsInt(xn, "state", -1)); + string tempComment = _helper.GetAttrAsString (xn, "comment", ""); - if ((m_sDataVersion != tempDataversion) || m_sComment != tempComment || m_dsVeraState != tempVeraState) + if ((_dataVersion != tempDataversion) || _comment != tempComment || _dsVeraState != tempVeraState) { - m_bScreenUpdateRequired = true; - m_lLastUpdate = DateTime.Now.Ticks; + _screenUpdateRequired = true; + _lastUpdate = DateTime.Now.Ticks; } - m_sDataVersion = tempDataversion; - m_dsVeraState = tempVeraState; - m_sComment = tempComment; + _dataVersion = tempDataversion; + _dsVeraState = tempVeraState; + _comment = tempComment; - m_dsVeraState = helper.toDevState(helper.getAttrAsInt(xn, "state", -1)); - m_sComment = helper.getAttrAsString (xn, "comment", ""); - m_bMetric = (helper.getAttrAsString(xn, "temperature", "C") == "C"); + _dsVeraState = _helper.ToDevState(_helper.GetAttrAsInt(xn, "state", -1)); + _comment = _helper.GetAttrAsString (xn, "comment", ""); + _metric = (_helper.GetAttrAsString(xn, "temperature", "C") == "C"); return true; } - public void clearFullReloadFlag() + public void ClearFullReloadFlag() { - m_bFullReload = false; + _fullReload = false; } - public void setFullReloadFlag() + public void SetFullReloadFlag() { - m_bFullReload = true; + _fullReload = true; } public bool fullReload { - get { return m_bFullReload; } + get { return _fullReload; } set { } } public string versionInfo { - get { return m_sModel + " " + m_sVersion; } + get { return _model + " " + _version; } set { } } - public bool bZWaveHeal + public bool zWaveHeal { - get { return m_zWaveHeal; } + get { return _zWaveHeal; } set { } } public string serialno { - get { return m_sSerial; } + get { return _serial; } set { } } public string fwd { - get { return m_sFwd1Server; } + get { return _fwd1Server; } set { } } public string fwdBackup { - get { return m_sFwd2Server; } + get { return _fwd2Server; } set { } } public string loadtime { - get { return m_sLoadTime; } + get { return _loadTime; } set { } } public string dataversion { - get { return m_sDataVersion; } + get { return _dataVersion; } set { } } public DevState state { - get { return m_dsVeraState; } + get { return _dsVeraState; } set { } } public string comment { - get { return m_sComment; } + get { return _comment; } set { } } - public void reportConnectionError( string errmsg ) + public void ReportConnectionError(string errmsg) { - m_dsVeraState = DevState.CONNECTION_ERROR; - m_sComment = errmsg; - m_bScreenUpdateRequired = true; - m_lLastUpdate = DateTime.Now.Ticks; + _dsVeraState = DevState.CONNECTION_ERROR; + _comment = errmsg; + _screenUpdateRequired = true; + _lastUpdate = DateTime.Now.Ticks; } - public void reportCommandError( string errmsg ) + public void ReportCommandError(string errmsg) { - m_dsVeraState = DevState.COMMAND_ERROR; - m_sComment = errmsg; - m_bScreenUpdateRequired = true; - m_lLastUpdate = DateTime.Now.Ticks; + _dsVeraState = DevState.COMMAND_ERROR; + _comment = errmsg; + _screenUpdateRequired = true; + _lastUpdate = DateTime.Now.Ticks; } - public void clearConnectionError( ) + public void ClearConnectionError() { - m_dsVeraState = DevState.NONE; - m_sComment = ""; - m_bScreenUpdateRequired = true; - m_lLastUpdate = DateTime.Now.Ticks; + _dsVeraState = DevState.NONE; + _comment = ""; + _screenUpdateRequired = true; + _lastUpdate = DateTime.Now.Ticks; } - public bool isMetric() + public bool IsMetric() { - return m_bMetric; + return _metric; } - public bool newScreenUpdateWaitingAndClearFlag( ) + public bool NewScreenUpdateWaitingAndClearFlag() { // Invoking this method will clear the update ready flag -> so caller need to handle the update - bool b = m_bScreenUpdateRequired; - m_bScreenUpdateRequired = false; + bool b = _screenUpdateRequired; + _screenUpdateRequired = false; return b; } - public bool newUpdateSince(float fTimePreviousCheck) + public bool NewUpdateSince(float timePreviousCheck) { - return (fTimePreviousCheck <= m_lLastUpdate); + return (timePreviousCheck <= _lastUpdate); } } } Modified: trunk/plugins/VeraControl/DeviceTemperature.cs =================================================================== --- trunk/plugins/VeraControl/DeviceTemperature.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceTemperature.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -18,55 +18,55 @@ /// </summary> public class DeviceTemperature : DeviceGeneric { - public string m_sTemp = "0"; // public thermostat class - private bool m_bMetric = true; + public string _temperature = "0"; // public thermostat class + private bool _metric = true; - public DeviceTemperature( XmlNode xn, bool bMetric ): base (xn) + public DeviceTemperature(XmlNode xn, bool metric): base (xn) { - m_bMetric = bMetric; + _metric = metric; if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_sTemp = helper.getAttrAsString(xn, "temperature", m_sTemp); - return base.update(xn); + _temperature = _helper.GetAttrAsString(xn, "temperature", _temperature); + return base.Update(xn); } public override int level { - get { return int.Parse(m_sTemp); } + get { return int.Parse(_temperature); } set { } } public override int maxLevel { - get { return (m_bMetric ? 100 : 212); } + get { return (_metric ? 100 : 212); } set { } } public override int minLevel { - get { return (m_bMetric ? -22 : -7); } + get { return (_metric ? -22 : -7); } set { } } public override string ToString() { - return name + " [" + getStatusText() + "]"; + return name + " [" + GetStatusText() + "]"; } - public override string getIconName() + public override string GetIconName() { return "Temperature_Sensor"; } - public override string getStatusText() + public override string GetStatusText() { - return m_sTemp + (m_bMetric ? "°C" : "°F"); + return _temperature + (_metric ? "°C" : "°F"); } } Modified: trunk/plugins/VeraControl/DeviceThermostat.cs =================================================================== --- trunk/plugins/VeraControl/DeviceThermostat.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceThermostat.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -18,28 +18,28 @@ /// </summary> public class DeviceThermostat : DeviceTemperature { - private bool m_bMetric = true; - private string m_sFanMode = ""; - private string m_sHvacState = "Off"; // "Off', "Idle", "Heating", "Cooling", "FanOnly", "PendingHeat", "PendingCool", "Vent" - private string m_sMode = "Off"; // "Off', "InDeadBand", "HeatOn", "CoolOn", "AutoChangeOver", "AuxHeatOn", "EconomyHeatOn", "EmergencyHeatOn", + private bool _metric = true; + private string _fanMode = ""; + private string _hvacState = "Off"; // "Off', "Idle", "Heating", "Cooling", "FanOnly", "PendingHeat", "PendingCool", "Vent" + private string _mode = "Off"; // "Off', "InDeadBand", "HeatOn", "CoolOn", "AutoChangeOver", "AuxHeatOn", "EconomyHeatOn", "EmergencyHeatOn", // "AuxCoolOn", "EconomyCoolOn", "BuildingProtection", "EnergySavingsHeating", "EnergySavingsCooling" - public DeviceThermostat( XmlNode xn, bool bMetric ): base (xn, bMetric) + public DeviceThermostat(XmlNode xn, bool metric) : base (xn, metric) { - m_bMetric = bMetric; + _metric = metric; if (xn != null) { - update(xn); + Update(xn); } } - public override bool update(XmlNode xn) + public override bool Update(XmlNode xn) { - m_sTemp = helper.getAttrAsString(xn, "temperature", m_sTemp); - m_sFanMode = helper.getAttrAsString(xn, "fanmode", m_sFanMode); - m_sHvacState = helper.getAttrAsString(xn, "hvacstate", m_sHvacState); - m_sMode = helper.getAttrAsString(xn, "mode", m_sMode); - return base.update(xn); + _temperature = _helper.GetAttrAsString(xn, "temperature", _temperature); + _fanMode = _helper.GetAttrAsString(xn, "fanmode", _fanMode); + _hvacState = _helper.GetAttrAsString(xn, "hvacstate", _hvacState); + _mode = _helper.GetAttrAsString(xn, "mode", _mode); + return base.Update(xn); } public override bool status @@ -56,17 +56,17 @@ public override string mode { - get { return m_sMode; } + get { return _mode; } set { if (id > 0) // Only send when a valid ID is found { - reportPendingRequest(); + ReportPendingRequest(); // Do something with vera string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ "&serviceId=urn:upnp-org:serviceId:HVAC_UserOperatingMode1&action=SetModeTarget" + "&NewModeTarget="+(value == "Off" ? "Off" : (value == "Cool" ? "CoolOn" : (value == "Heat" ? "HeatOn" : "AutoChangeOver")) ); - vera.doVeraCommandRequest(cmd, reportRequestError); + _vera.DoVeraCommandRequest(cmd, ReportRequestError); } } } @@ -88,22 +88,22 @@ set { } } - public override string getStatusText() + public override string GetStatusText() { return mode; } - public override string getExtraText() + public override string GetExtraText() { - return m_sHvacState + " - Fan : " + m_sFanMode + " - " + m_sTemp + (m_bMetric ? "°C" : "°F") ; + return _hvacState + " - Fan : " + _fanMode + " - " + _temperature + (_metric ? "°C" : "°F") ; } - public override string getIconName() + public override string GetIconName() { return "Thermostat"; } - public override string [] getCommands() + public override string [] GetCommands() { return new string [] {"Off", "On", "Auto", "Heat", "Cool"}; } Modified: trunk/plugins/VeraControl/DeviceWindowCovering.cs =================================================================== --- trunk/plugins/VeraControl/DeviceWindowCovering.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DeviceWindowCovering.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -18,15 +18,15 @@ /// </summary> public class DeviceWindowCovering : DeviceDimmer { - public DeviceWindowCovering( XmlNode xn ): base (xn) + public DeviceWindowCovering(XmlNode xn) : base (xn) { if (xn != null) { - update(xn); + Update(xn); } } - public override string getIconName() + public override string GetIconName() { return "Window_Covering"; } Modified: trunk/plugins/VeraControl/DialogActionTrigger.cs =================================================================== --- trunk/plugins/VeraControl/DialogActionTrigger.cs 2012-01-21 12:45:56 UTC (rev 4417) +++ trunk/plugins/VeraControl/DialogActionTrigger.cs 2012-01-21 23:31:37 UTC (rev 4418) @@ -26,75 +26,74 @@ /// </summary> public class DialogActionTrigger : GUIDialogWindow { - [SkinControl(2)] protected GUIButtonControl btnClose = null; - [SkinControl(4)] protected GUILabelControl lblHeading = null; - [SkinControl(100)] protected GUIButtonControl btnStore = null; + [SkinControl(2)] protected GUIButtonControl _btnClose = null; + [SkinControl(4)] protected GUILabelControl _lblHeading = null; + [SkinControl(100)] protected GUIButtonControl _btnStore = null; - [SkinControlAttribute(20)] protected GUISpinButton spMusicStart = null; - [SkinControlAttribute(21)] protected GUISpinButton spMusicPause = null; - [SkinControlAttribute(22)] protected GUISpinButton spMusicResume = null; - [SkinControlAttribute(23)] protected GUISpinButton spMusicStop = null; + [SkinControlAttribute(20)] protected GUISpinButton _spMusicStart = null; + [SkinControlAttribute(21)] protected GUISpinButton _spMusicPause = null; + [SkinControlAttribute(22)] protected GUISpinButton _spMusicResume = null; + [SkinControlAttribute(23)] protected GUISpinButton _spMusicStop = null; - [SkinControlAttribute(25)] protected GUISpinButton spVideoStart = null; - [SkinControlAttribute(26)] protected GUISpinButton spVideoPause = null; - [SkinControlAttribute(27)] protected GUISpinButton spVideoResume = null; - [SkinControlAttribute(28)] protected GUISpinButton spVideoStop = null; + [SkinControlAttribute(25)] protected GUISpinButton _spVideoStart = null; + [SkinControlAttribute(26)] protected GUISpinButton _spVideoPause = null; + [SkinControlAttribute(27)] protected ... [truncated message content] |
From: <Ba...@us...> - 2012-01-23 23:04:54
|
Revision: 4424 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4424&view=rev Author: BartEv Date: 2012-01-23 23:04:46 +0000 (Mon, 23 Jan 2012) Log Message: ----------- Scene and device update improved Modified Paths: -------------- trunk/plugins/VeraControl/BaseDevice.cs trunk/plugins/VeraControl/DeviceCam.cs trunk/plugins/VeraControl/DeviceGeneric.cs trunk/plugins/VeraControl/Scene.cs trunk/plugins/VeraControl/VeraCommunication.cs trunk/plugins/VeraControl/VeraControl.cs Modified: trunk/plugins/VeraControl/BaseDevice.cs =================================================================== --- trunk/plugins/VeraControl/BaseDevice.cs 2012-01-21 23:46:35 UTC (rev 4423) +++ trunk/plugins/VeraControl/BaseDevice.cs 2012-01-23 23:04:46 UTC (rev 4424) @@ -13,142 +13,170 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of BaseDevice. - /// </summary> - public class BaseDevice - { - public long _lastUpdate = 0; - public long _lastPendingUpdate = 0; - public bool _screenUpdateRequired = false; - private string _name = "unknown device"; - private int _id = 0; - private int _room = 0; - - // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) - private DevState _dsState = DevState.NONE; - private string _comment = ""; // red(error), green(success) or blue(pending) - icon/text - - public VeraHelper _helper = VeraHelper.Instance; - public VeraCommunication _vera = VeraCommunication.Instance; - - public BaseDevice(XmlNode xn) - { - if (xn != null) - { - Update(xn); - } - } - - /// <summary> - /// Process Vera update information - /// </summary> - public virtual bool Update(XmlNode xn) - { - _name = _helper.GetAttrAsString(xn, "name", _name); - _id = _helper.GetAttrAsInt (xn, "id", _id); - _room = _helper.GetAttrAsInt (xn, "room", _room); - - string tempComment = _helper.GetAttrAsString(xn, "comment", _comment ); - DevState tempDsState = _helper.ToDevState(_helper.GetAttrAsInt(xn, "state", -1)); - if (_dsState != DevState.PENDING || tempDsState != DevState.NONE || (tempDsState == DevState.NONE && ((_lastPendingUpdate / TimeSpan.TicksPerSecond ) < (DateTime.Now.Ticks / TimeSpan.TicksPerSecond)))) - { // If state was set to pending next update should contain a new state or still pending - so do not clear pending flag for at least 10 seconds - _comment = tempComment; - _dsState = tempDsState; - } - if (_id == 0) - { - // void device no further processing needed - return false; - } - - // Set update flag - _screenUpdateRequired = true; - _lastUpdate = DateTime.Now.Ticks; - return true; - } - - public int id - { - get { return _id; } - set { } - } - - public string name - { - get { return _name; } - set { } - } + /// <summary> + /// Description of BaseDevice. + /// </summary> + public class BaseDevice + { + private long _lastUpdate = 0; + private long _lastPendingUpdate = 0; + private bool _screenUpdateRequired = false; + private string _name = "unknown device"; + private int _id = 0; + private int _room = 0; + + // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) + private DevState _dsState = DevState.NONE; + private string _comment = ""; // red(error), green(success) or blue(pending) - icon/text + + public VeraHelper _helper = VeraHelper.Instance; + public VeraCommunication _vera = VeraCommunication.Instance; + + public BaseDevice(XmlNode xn) + { + if (xn != null) + { + Update(xn); + } + } + + /// <summary> + /// Process Vera update information + /// </summary> + public virtual bool Update(XmlNode xn) + { + _name = _helper.GetAttrAsString(xn, "name", _name); + _id = _helper.GetAttrAsInt (xn, "id", _id); + _room = _helper.GetAttrAsInt (xn, "room", _room); + _comment = _helper.GetAttrAsString(xn, "comment", _comment ); + _dsState = _helper.ToDevState(_helper.GetAttrAsInt(xn, "state", -1)); + + if (_id == 0) + { + // void device no further processing needed + return false; + } + + // Set update flag + screenUpdateRequired = true; + lastUpdate = DateTime.Now.Ticks; + return true; + } + + public virtual string GetIconName() + { + return ""; + } + + public virtual string GetStatusText() + { + return ""; + } + + public int id + { + get { return _id; } + set { } + } + + public string name + { + get { return _name; } + set { } + } - public bool InRoom(int id) - { - return (_room == id); - } - - public int room - { - get { return _room; } - set { _room = value; } - } - - public DevState commstate - { - get { return _dsState; } - set { } - } - - public string comment - { - get { return (commstate != DevState.NONE ? _comment : ""); } - set { } - } - - public void ReportPendingRequest() - { - _dsState = DevState.PENDING; - _comment = "Sending command..."; - _screenUpdateRequired = true; - _lastUpdate = DateTime.Now.Ticks; - _lastPendingUpdate = _lastUpdate; - } - - /// <summary> - /// Callback function for Ansync Web Client call on to report errors... - /// </summary> - public void ReportRequestError(string message) - { - _dsState = DevState.COMMAND_ERROR; - _comment = message; - _screenUpdateRequired = true; - _lastUpdate = DateTime.Now.Ticks; - } - - public void ClearCommState() - { - _dsState = DevState.NONE; - } - - /// <summary> - /// True when an update was processed after the give time stamp - /// </summary> - public virtual bool NewUpdateSince(long timePreviousCheck) - { - return (timePreviousCheck <= _lastUpdate); - } - - /// <summary> - /// Invoking this method will clear the update ready flag -> so caller need to handle the screen update - /// </summary> - public virtual bool NewScreenUpdateWaitingAndClearFlag() - { - bool b = _screenUpdateRequired; - _screenUpdateRequired = false; - return b; - } - - public override string ToString() - { - return name; - } - } + public bool InRoom(int id) + { + return (_room == id); + } + + public int room + { + get { return _room; } + set { _room = value; } + } + + public DevState commstate + { + get { return _dsState; } + set { } + } + + public string comment + { + get { return (commstate != DevState.NONE ? _comment : ""); } + set { } + } + + public bool screenUpdateRequired + { + get { return _screenUpdateRequired; } + set { + if (value) + { // If at least one device report screen update required, Vera should take over this report + _vera.setScreenUpdateRequired(); + } + _screenUpdateRequired = value; + } + } + + public long lastUpdate + { + get { return _lastUpdate; } + set { _lastUpdate = value; } + } + + public void ReportPendingRequest() + { + _dsState = DevState.PENDING; + _comment = "Sending command..."; + screenUpdateRequired = true; + lastUpdate = DateTime.Now.Ticks; + _lastPendingUpdate = lastUpdate; + } + + /// <summary> + /// Callback function for Ansync Web Client call on to report errors... + /// </summary> + public void ReportRequestError(string message) + { + _dsState = DevState.COMMAND_ERROR; + _comment = message; + screenUpdateRequired = true; + lastUpdate = DateTime.Now.Ticks; + } + + public void ClearCommState() + { + if (_dsState != DevState.NONE) + { + _dsState = DevState.NONE; + screenUpdateRequired = true; + lastUpdate = DateTime.Now.Ticks; + } + } + + /// <summary> + /// True when an update was processed after the give time stamp + /// </summary> + public virtual bool NewUpdateSince(long timePreviousCheck) + { + return (timePreviousCheck <= lastUpdate); + } + + /// <summary> + /// Invoking this method will clear the update ready flag -> so caller need to handle the screen update + /// </summary> + public virtual bool NewScreenUpdateWaitingAndClearFlag() + { + bool b = screenUpdateRequired; + screenUpdateRequired = false; + return b; + } + + public override string ToString() + { + return name; + } + } } Modified: trunk/plugins/VeraControl/DeviceCam.cs =================================================================== --- trunk/plugins/VeraControl/DeviceCam.cs 2012-01-21 23:46:35 UTC (rev 4423) +++ trunk/plugins/VeraControl/DeviceCam.cs 2012-01-23 23:04:46 UTC (rev 4424) @@ -90,21 +90,21 @@ { // Invoking this method will clear the update ready flag -> so caller need to handle the update // A cam device requires an update every refreshRate seconds - bool b = _screenUpdateRequired || HasRefreshDelayPassed(DateTime.Now.Ticks); - _screenUpdateRequired = false; + bool b = screenUpdateRequired || HasRefreshDelayPassed(DateTime.Now.Ticks); + screenUpdateRequired = false; if (b) { - _lastUpdate = DateTime.Now.Ticks; + lastUpdate = DateTime.Now.Ticks; } return b; } public override bool NewUpdateSince(long lTimePreviousCheck) { - bool b = (lTimePreviousCheck <= _lastUpdate) || HasRefreshDelayPassed(_lastUpdate); + bool b = (lTimePreviousCheck <= lastUpdate) || HasRefreshDelayPassed(lastUpdate); if (b) { - _lastUpdate = DateTime.Now.Ticks; + lastUpdate = DateTime.Now.Ticks; } return b; } @@ -114,7 +114,7 @@ if (id == 0) { _vera.status.system.ReportCommandError("Unknown device"); - _screenUpdateRequired = true; + screenUpdateRequired = true; return; } string cmd = "?id=lu_action&DeviceNum=" + id + "&serviceId=urn:micasaverde-com:serviceId:PanTiltZoom1&action=" + direction; Modified: trunk/plugins/VeraControl/DeviceGeneric.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-21 23:46:35 UTC (rev 4423) +++ trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-23 23:04:46 UTC (rev 4424) @@ -96,12 +96,12 @@ set { } } - public virtual string GetIconName() + public override string GetIconName() { return "generic_sensor"; } - public virtual string GetStatusText() + public override string GetStatusText() { return ""; } Modified: trunk/plugins/VeraControl/Scene.cs =================================================================== --- trunk/plugins/VeraControl/Scene.cs 2012-01-21 23:46:35 UTC (rev 4423) +++ trunk/plugins/VeraControl/Scene.cs 2012-01-23 23:04:46 UTC (rev 4424) @@ -14,62 +14,60 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of Scene. - /// </summary> - public class Scene : BaseDevice - { - public Scene(XmlNode xn) : base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - private bool _active = false; - - public override bool Update(XmlNode xn) - { - _active = _helper.GetAttrAsBool(xn, "active", _active); - bool b = base.Update(xn); - - // Make sure the room exists or else make it 0 - if (room != 0 && !_vera.status.IsRoomFound(room)) - { - room = 0; - } - return b; - } - - public bool IsActive() - { - return _active; - } + /// <summary> + /// Description of Scene. + /// </summary> + public class Scene : BaseDevice + { + public Scene(XmlNode xn) : base (xn) + { + if (xn != null) + { + Update(xn); + } + } + + private bool _active = false; + + public override bool Update(XmlNode xn) + { + _active = _helper.GetAttrAsBool(xn, "active", _active); + bool b = base.Update(xn); + + // Make sure the room exists or else make it 0 + if (room != 0 && !_vera.status.IsRoomFound(room)) + { + room = 0; + } + return b; + } + + public override string GetIconName() + { + return "Scenes"; + } + + public override string GetStatusText() + { + return (room == 0 ? "" : _vera.status.GetRoomById(room).name); + } + + public bool IsActive() + { + return _active; + } - public void Run() - { - if (id == 0) - { - _vera.status.system.ReportCommandError("Unknown scene"); - _screenUpdateRequired = true; - return; - } - ReportPendingRequest(); - string cmd = "?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum="+id; - _vera.DoVeraCommandRequest(cmd, ReportRequestError); - } - - public override bool NewScreenUpdateWaitingAndClearFlag( ) - { - // Scenes are not reported Done by Vera so the will time out... - bool b = base.NewScreenUpdateWaitingAndClearFlag(); - if (commstate != DevState.NONE && (_lastUpdate < (DateTime.Now.Ticks - (10 * 10000000)))) - { - ClearCommState(); - return true; - } - return b; - } - } + public void Run() + { + if (id == 0) + { + _vera.status.system.ReportCommandError("Unknown scene"); + screenUpdateRequired = true; + return; + } + ReportPendingRequest(); + string cmd = "?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum="+id; + _vera.DoVeraCommandRequest(cmd, ReportRequestError); + } + } } Modified: trunk/plugins/VeraControl/VeraCommunication.cs =================================================================== --- trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-21 23:46:35 UTC (rev 4423) +++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-23 23:04:46 UTC (rev 4424) @@ -23,12 +23,12 @@ public class VeraStatus { - public DeviceSystem system = new DeviceSystem(); - public List<DeviceGeneric> devices = new List<DeviceGeneric>(); - public List<Scene> scenes = new List<Scene>(); - public List<Room> rooms = new List<Room>(); - public List<DevCategories> categories = new List<DevCategories>(); - public List<Section> sections = new List<Section>(); + public DeviceSystem system = new DeviceSystem(); + public List<DeviceGeneric> devices = new List<DeviceGeneric>(); + public List<Scene> scenes = new List<Scene>(); + public List<Room> rooms = new List<Room>(); + public List<DevCategories> categories = new List<DevCategories>(); + public List<Section> sections = new List<Section>(); #region Vers get by id support functions @@ -165,14 +165,14 @@ public sealed class VeraCommunication { - private static volatile VeraCommunication _instance; + private static volatile VeraCommunication _instance; private static object _syncRoot = new Object(); private VeraHelper _helper = VeraHelper.Instance; // Config data private string _veraIPAddress; private string _veraTCPIPPort; - private int _maxRefreshDelay; // Maximun delay between 2 status updates in seconds + private int _maxRefreshDelay; // Maximun delay between 2 status updates in seconds private int _minRefreshDelay = 1000; // Minimun delay between 2 status updates in miliseconds // Actual device information @@ -266,7 +266,7 @@ { _webCommandClientErrorReporter = null; status.system.ReportCommandError(e.Message); - _screenUpdateRequired = true; + setScreenUpdateRequired(); } } @@ -285,7 +285,7 @@ // Show eror in MediaPortal Vera-main window status.system.ReportCommandError("Request was canceled"); } - _screenUpdateRequired = true; + setScreenUpdateRequired(); } else if (e.Error != null) { @@ -300,7 +300,7 @@ // Show eror in MediaPortal Vera-main window status.system.ReportCommandError(e.Error.Message); } - _screenUpdateRequired = true; + setScreenUpdateRequired(); } else { @@ -317,7 +317,7 @@ // Show eror in MediaPortal Vera-main window status.system.ReportCommandError(e.Result); } - _screenUpdateRequired = true; + setScreenUpdateRequired(); } } // Communication done clear error report handler @@ -358,9 +358,9 @@ if (e.Error != null) { // Handle error here - _lastUpdateFailed = true; + _lastUpdateFailed = true; _lastUpdateErrorMessage = e.Error.Message; - _screenUpdateRequired = true; + setScreenUpdateRequired(); } else { @@ -399,7 +399,7 @@ if (_lastUpdateFailed) { _lastUpdateFailed = false; - _screenUpdateRequired = true; + setScreenUpdateRequired(); _status.system.ClearConnectionError(); } // Process system status first @@ -436,6 +436,12 @@ // Process Scenes xnList = xmlDoc.SelectNodes("/root/scenes/scene"); + // State update of Scenes are not reported done, so they have to be cleaned manualy + // if a message is still valid and/or new message will be reported below + foreach (Scene scene in _status.scenes) + { + scene.ClearCommState(); + } foreach (XmlNode xn in xnList) { Scene sc = _status.GetSceneById( int.Parse(xn.Attributes["id"].Value) ); @@ -444,9 +450,6 @@ } else { _status.scenes.Add(new Scene(xn)); } - - // At least one scene was found and thus screen update required - _screenUpdateRequired = true; } // Process Categories @@ -571,8 +574,6 @@ break; } } - // At least one device update/new was found and thus screen update required - _screenUpdateRequired = true; } } @@ -635,6 +636,10 @@ return b; } + public void setScreenUpdateRequired() + { + _screenUpdateRequired = true; + } /// <summary> /// A request is currently being handled by Vera, this request takes at least _minRefreshDelay msecs, at most _maxRefreshDelay seconds and will be finished the moment Vera detects a change. /// As soon as this function returns false a new update request should be invoked (with UpdateCurrentStatus()), Vera will take care of the Refresh delays (by keeping open the http-connection) Modified: trunk/plugins/VeraControl/VeraControl.cs =================================================================== --- trunk/plugins/VeraControl/VeraControl.cs 2012-01-21 23:46:35 UTC (rev 4423) +++ trunk/plugins/VeraControl/VeraControl.cs 2012-01-23 23:04:46 UTC (rev 4424) @@ -35,212 +35,216 @@ namespace VeraControl { - public enum Actiontrigger - { - MUSIC_START_PLAYING = 0, - MUSIC_PAUSED, - MUSIC_PAUSE_RESUMED, - MUSIC_STOPPED, - - VIDEO_START_PLAYING, - VIDEO_PAUSED, - VIDEO_PAUSE_RESUMED, - VIDEO_STOPPED, - - TV_START_PLAYING, - TV_PAUSED, - TV_PAUSE_RESUMED, - TV_STOPPED, - - RECORDING_START_PLAYING, - RECORDING_PAUSED, - RECORDING_PAUSE_RESUMED, - RECORDING_STOPPED, - - RADIO_START_PLAYING, - RADIO_PAUSED, - RADIO_PAUSE_RESUMED, - RADIO_STOPPED, - - UNKNOWN_START_PLAYING, - UNKNOWN_PAUSED, - UNKNOWN_PAUSE_RESUMED, - UNKNOWN_STOPPED, - - MP_START_UP, - MP_SHUTDOWN, - MP_EXIT, - - LAST_ACTIONTRIGGER - }; - - /// <summary> - /// Description of VeraControl. - /// </summary> - public class VeraControl : GUIInternalWindow, ISetupForm - { - [SkinControlAttribute(10)] protected GUILabelControl _title = null; - [SkinControl(20)] protected GUISpinButton _catList = null; - [SkinControl(40)] protected GUIListControl _leftList = null; - [SkinControl(50)] protected GUIListControl _rightList = null; - [SkinControl(60)] protected GUIButtonControl _actionButton = null; - [SkinControl(70)] protected GUIToggleButtonControl _actionTriggerButton = null; - - [SkinControl(30)] protected GUIImage _cmtImage = null; - [SkinControlAttribute(31)] protected GUILabelControl _comment = null; - - private int _pluginID = 1972; - private VeraCommunication _vera = VeraCommunication.Instance; - private int _selectedRoom = Int16.MaxValue; - private int _selectedCategory = Int16.MaxValue; - public Actiontrigger _lastAction = Actiontrigger.LAST_ACTIONTRIGGER; - private VeraHelper _helper = new VeraHelper(); - - public bool _enableSceneTrigger = false; - private bool _lastUpdateFailed = false; - private string _titleTxt = "Micasa Verde - Vera control"; - - public VeraControl() - { - } + public enum Actiontrigger + { + MUSIC_START_PLAYING = 0, + MUSIC_PAUSED, + MUSIC_PAUSE_RESUMED, + MUSIC_STOPPED, + + VIDEO_START_PLAYING, + VIDEO_PAUSED, + VIDEO_PAUSE_RESUMED, + VIDEO_STOPPED, + + TV_START_PLAYING, + TV_PAUSED, + TV_PAUSE_RESUMED, + TV_STOPPED, + + RECORDING_START_PLAYING, + RECORDING_PAUSED, + RECORDING_PAUSE_RESUMED, + RECORDING_STOPPED, + + RADIO_START_PLAYING, + RADIO_PAUSED, + RADIO_PAUSE_RESUMED, + RADIO_STOPPED, + + UNKNOWN_START_PLAYING, + UNKNOWN_PAUSED, + UNKNOWN_PAUSE_RESUMED, + UNKNOWN_STOPPED, + + MP_START_UP, + MP_SHUTDOWN, + MP_EXIT, + + LAST_ACTIONTRIGGER + }; + + /// <summary> + /// Description of VeraControl. + /// </summary> + public class VeraControl : GUIInternalWindow, ISetupForm + { + [SkinControlAttribute(10)] protected GUILabelControl _title = null; + [SkinControl(20)] protected GUISpinButton _catList = null; + [SkinControl(40)] protected GUIListControl _leftList = null; + [SkinControl(50)] protected GUIListControl _rightList = null; + [SkinControl(60)] protected GUIButtonControl _actionButton = null; + [SkinControl(70)] protected GUIToggleButtonControl _actionTriggerButton = null; + + [SkinControl(30)] protected GUIImage _cmtImage = null; + [SkinControlAttribute(31)] protected GUILabelControl _comment = null; + + const int ALL = Int16.MaxValue; + const int NO_SCENE_SELECTED = Int16.MaxValue; + + + private int _pluginID = 1972; + private VeraCommunication _vera = VeraCommunication.Instance; + private int _selectedRoom = ALL; + private int _selectedCategory = ALL; + public Actiontrigger _lastAction = Actiontrigger.LAST_ACTIONTRIGGER; + private VeraHelper _helper = new VeraHelper(); + + public bool _enableSceneTrigger = false; + private bool _lastUpdateFailed = false; + private string _titleTxt = "Micasa Verde - Vera control"; + + public VeraControl() + { + } - #region ISetupForm Members + #region ISetupForm Members - // Returns the name of the plugin which is shown in the plugin menu - public string PluginName() - { - return "Vera Controller"; - } + // Returns the name of the plugin which is shown in the plugin menu + public string PluginName() + { + return "Vera Controller"; + } - // Returns the description of the plugin is shown in the plugin menu - public string Description() - { - return "Micasa Verde Vera 2 controller, let Media Portal control your Z-wave devices"; - } + // Returns the description of the plugin is shown in the plugin menu + public string Description() + { + return "Micasa Verde Vera 2 controller, let Media Portal control your Z-wave devices"; + } - // Returns the author of the plugin which is shown in the plugin menu - public string Author() - { - return "Bart Eversdijk"; - } + // Returns the author of the plugin which is shown in the plugin menu + public string Author() + { + return "Bart Eversdijk"; + } - // show the setup dialog - public void ShowPlugin() - { - VeraSetupForm verasetup = new VeraSetupForm(); - verasetup.ShowDialog(); - } + // show the setup dialog + public void ShowPlugin() + { + VeraSetupForm verasetup = new VeraSetupForm(); + verasetup.ShowDialog(); + } - // Indicates whether plugin can be enabled/disabled - public bool CanEnable() - { - return true; - } + // Indicates whether plugin can be enabled/disabled + public bool CanEnable() + { + return true; + } - // Get Windows-ID - public int GetWindowId() - { - // WindowID of windowplugin belonging to this setup - // enter your own unique code - return _pluginID; - } + // Get Windows-ID + public int GetWindowId() + { + // WindowID of windowplugin belonging to this setup + // enter your own unique code + return _pluginID; + } - // Indicates if plugin is enabled by default; - public bool DefaultEnabled() - { - return true; - } + // Indicates if plugin is enabled by default; + public bool DefaultEnabled() + { + return true; + } - // indicates if a plugin has it's own setup screen - public bool HasSetup() - { - return true; - } + // indicates if a plugin has it's own setup screen + public bool HasSetup() + { + return true; + } - /// <summary> - /// If the plugin should have it's own button on the main menu of Mediaportal then it - /// should return true to this method, otherwise if it should not be on home - /// it should return false - /// </summary> - /// <param name="strButtonText">text the button should have</param> - /// <param name="strButtonImage">image for the button, or empty for default</param> - /// <param name="strButtonImageFocus">image for the button, or empty for default</param> - /// <param name="strPictureImage">subpicture for the button or empty for none</param> - /// <returns>true : plugin needs it's own button on home - /// false : plugin does not need it's own button on home</returns> + /// <summary> + /// If the plugin should have it's own button on the main menu of Mediaportal then it + /// should return true to this method, otherwise if it should not be on home + /// it should return false + /// </summary> + /// <param name="strButtonText">text the button should have</param> + /// <param name="strButtonImage">image for the button, or empty for default</param> + /// <param name="strButtonImageFocus">image for the button, or empty for default</param> + /// <param name="strPictureImage">subpicture for the button or empty for none</param> + /// <returns>true : plugin needs it's own button on home + /// false : plugin does not need it's own button on home</returns> - public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) - { - strButtonText = PluginName(); - strButtonImage = "hover_remote.png"; - strButtonImageFocus = "hover_remote.png"; - strPictureImage = "hover_remote.png"; - return true; - } + public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) + { + strButtonText = PluginName(); + strButtonImage = "hover_remote.png"; + strButtonImageFocus = "hover_remote.png"; + strPictureImage = "hover_remote.png"; + return true; + } - // With GetID it will be an window-plugin / otherwise a process-plugin - // Enter the id number here again - public override int GetID - { - get { return _pluginID; } - set { } - } + // With GetID it will be an window-plugin / otherwise a process-plugin + // Enter the id number here again + public override int GetID + { + get { return _pluginID; } + set { } + } - #endregion + #endregion - public override bool Init() - { - _selectedRoom = Int16.MaxValue; - _selectedCategory = Int16.MaxValue; + public override bool Init() + { + _selectedRoom = ALL; + _selectedCategory = ALL; - using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) - { - _enableSceneTrigger = xmlreader.GetValueAsBool("veracontroller", "enableSceneTrigger", false); - } - - GUIWindowManager.OnNewAction += new OnActionHandler(OnNewAction); - - Player.PlayBackEnded += new Player.EndedHandler(g_Player_PlayBackEnded); - Player.PlayBackStarted += new Player.StartedHandler(g_Player_PlayBackStarted); - Player.PlayBackStopped += new Player.StoppedHandler(g_Player_PlayBackStopped); + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) + { + _enableSceneTrigger = xmlreader.GetValueAsBool("veracontroller", "enableSceneTrigger", false); + } + + GUIWindowManager.OnNewAction += new OnActionHandler(OnNewAction); + + Player.PlayBackEnded += new Player.EndedHandler(g_Player_PlayBackEnded); + Player.PlayBackStarted += new Player.StartedHandler(g_Player_PlayBackStarted); + Player.PlayBackStopped += new Player.StoppedHandler(g_Player_PlayBackStopped); - // Handle MP start-up trigger - do this is a different Thread to not block MP-start up - new Thread( () => { - _vera.UpdateCurrentStatus(); - // Run startup trigger after first update - if (_enableSceneTrigger) - { - while (_vera.updatePending) - { - Thread.Sleep(1000); - } - handleActionTriggers(Actiontrigger.MP_START_UP); - } - }).Start(); - return Load(GUIGraphicsContext.Skin+@"\VeraControl.xml"); - } + // Handle MP start-up trigger - do this is a different Thread to not block MP-start up + new Thread( () => { + _vera.UpdateCurrentStatus(); + // Run startup trigger after first update + if (_enableSceneTrigger) + { + while (_vera.updatePending) + { + Thread.Sleep(1000); + } + handleActionTriggers(Actiontrigger.MP_START_UP); + } + }).Start(); + return Load(GUIGraphicsContext.Skin+@"\VeraControl.xml"); + } - protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) - { - if (control==_rightList) - OnRightlistCrtl((GUIListControl)control); - - if (control==_leftList) - OnLeftlistCrtl((GUIListControl)control); - - if (control==_catList) - OnCategoryList((GUISpinButton)control); - - if (control==_actionButton) - OnActionButton((GUIButtonControl)control); - - if (control==_actionTriggerButton) - OnActionTrigger((GUIToggleButtonControl)control); - - base.OnClicked (controlId, control, actionType); - } + protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) + { + if (control==_rightList) + OnRightlistCrtl((GUIListControl)control); + + if (control==_leftList) + OnLeftlistCrtl((GUIListControl)control); + + if (control==_catList) + OnCategoryList((GUISpinButton)control); + + if (control==_actionButton) + OnActionButton((GUIButtonControl)control); + + if (control==_actionTriggerButton) + OnActionTrigger((GUIToggleButtonControl)control); + + base.OnClicked (controlId, control, actionType); + } - /* Not valid until MP version 1.3 + /* Not valid until MP version 1.3 protected override void OnFocus(int controlId, GUIControl control, MediaPortal.GUI.Library.Action.ActionType actionType) { if (control==RightList) @@ -251,601 +255,586 @@ base.OnClicked (controlId, control, actionType); } - */ - - private void OnNewAction(Action action) - { - switch(action.wID) - { - case Action.ActionType.ACTION_PAUSE: - if (Player.Paused || Player.Playing) { - if (Player.IsMusic) { - handleActionTriggers(Player.Paused ? Actiontrigger.MUSIC_PAUSED : Actiontrigger.MUSIC_PAUSE_RESUMED); - } else if (Player.IsRadio) { - handleActionTriggers(Player.Paused ? Actiontrigger.RADIO_PAUSED : Actiontrigger.RADIO_PAUSE_RESUMED); - } else if (Player.IsTVRecording) { - handleActionTriggers(Player.Paused ? Actiontrigger.RECORDING_PAUSED : Actiontrigger.RECORDING_PAUSE_RESUMED); - } else if (Player.IsTV || Player.IsTimeShifting) { - handleActionTriggers(Player.Paused ? Actiontrigger.TV_PAUSED : Actiontrigger.TV_PAUSE_RESUMED); - } else if (Player.IsVideo ) { - handleActionTriggers(Player.Paused ? Actiontrigger.VIDEO_PAUSED : Actiontrigger.VIDEO_PAUSE_RESUMED); - } else { - handleActionTriggers(Player.Paused ? Actiontrigger.UNKNOWN_PAUSED : Actiontrigger.UNKNOWN_PAUSE_RESUMED); - } - } - break; + */ + + private void OnNewAction(Action action) + { + switch(action.wID) + { + case Action.ActionType.ACTION_PAUSE: + if (Player.Paused || Player.Playing) { + if (Player.IsMusic) { + handleActionTriggers(Player.Paused ? Actiontrigger.MUSIC_PAUSED : Actiontrigger.MUSIC_PAUSE_RESUMED); + } else if (Player.IsRadio) { + handleActionTriggers(Player.Paused ? Actiontrigger.RADIO_PAUSED : Actiontrigger.RADIO_PAUSE_RESUMED); + } else if (Player.IsTVRecording) { + handleActionTriggers(Player.Paused ? Actiontrigger.RECORDING_PAUSED : Actiontrigger.RECORDING_PAUSE_RESUMED); + } else if (Player.IsTV || Player.IsTimeShifting) { + handleActionTriggers(Player.Paused ? Actiontrigger.TV_PAUSED : Actiontrigger.TV_PAUSE_RESUMED); + } else if (Player.IsVideo ) { + handleActionTriggers(Player.Paused ? Actiontrigger.VIDEO_PAUSED : Actiontrigger.VIDEO_PAUSE_RESUMED); + } else { + handleActionTriggers(Player.Paused ? Actiontrigger.UNKNOWN_PAUSED : Actiontrigger.UNKNOWN_PAUSE_RESUMED); + } + } + break; - case Action.ActionType.ACTION_CONTEXT_MENU: - if (GUIWindowManager.ActiveWindow == GetWindowId()) - { - showInfoDialog(); - } - break; - - case Action.ActionType.ACTION_EXIT: - handleActionTriggers(Actiontrigger.MP_EXIT); - break; + case Action.ActionType.ACTION_CONTEXT_MENU: + if (GUIWindowManager.ActiveWindow == GetWindowId()) + { + showInfoDialog(); + } + break; + + case Action.ActionType.ACTION_EXIT: + handleActionTriggers(Actiontrigger.MP_EXIT); + break; - case Action.ActionType.ACTION_HIBERNATE: - case Action.ActionType.ACTION_POWER_OFF: - case Action.ActionType.ACTION_REBOOT: - case Action.ActionType.ACTION_SHUTDOWN: - case Action.ActionType.ACTION_SUSPEND: - handleActionTriggers(Actiontrigger.MP_SHUTDOWN); - break; - - // Resume ? how to determine (Plug in init?) - default: - break; - - } - } - - private void g_Player_PlayBackEnded(Player.MediaType media, string filename) - { - g_Player_PlayBackStopped(media, 0, filename); - } - - private void g_Player_PlayBackStopped(Player.MediaType media, int stoptime, string filename) - { - switch(media) - { - case Player.MediaType.Music: - handleActionTriggers(Actiontrigger.MUSIC_STOPPED); - break; - case Player.MediaType.Radio: - handleActionTriggers(Actiontrigger.RADIO_STOPPED); - break; - case Player.MediaType.Recording: - handleActionTriggers(Actiontrigger.RECORDING_STOPPED); - break; - case Player.MediaType.TV: - handleActionTriggers(Actiontrigger.TV_STOPPED); - break; - case Player.MediaType.Video: - handleActionTriggers(Actiontrigger.VIDEO_STOPPED); - break; - case Player.MediaType.Unknown: - default: - handleActionTriggers(Actiontrigger.UNKNOWN_STOPPED); - break; - } - } - - private void g_Player_PlayBackStarted(Player.MediaType media, string filename) - { - switch(media) - { - case Player.MediaType.Music: - if (_lastAction == Actiontrigger.MUSIC_PAUSED) { - handleActionTriggers(Actiontrigger.MUSIC_PAUSE_RESUMED); - } else if (_lastAction != Actiontrigger.MUSIC_PAUSE_RESUMED) { - triggerStopPlayingMedia(Actiontrigger.MUSIC_START_PLAYING); - handleActionTriggers(Actiontrigger.MUSIC_START_PLAYING); - } - break; - case Player.MediaType.Radio: - if (_lastAction == Actiontrigger.RADIO_PAUSED) { - handleActionTriggers(Actiontrigger.RADIO_PAUSE_RESUMED); - } else if (_lastAction != Actiontrigger.RADIO_PAUSE_RESUMED) { - triggerStopPlayingMedia(Actiontrigger.RADIO_START_PLAYING); - handleActionTriggers(Actiontrigger.RADIO_START_PLAYING); - } - break; - case Player.MediaType.Recording: - if (_lastAction == Actiontrigger.RECORDING_PAUSED) { - handleActionTriggers(Actiontrigger.RECORDING_PAUSE_RESUMED); - } else if (_lastAction != Actiontrigger.RECORDING_PAUSE_RESUMED) { - triggerStopPlayingMedia(Actiontrigger.RECORDING_START_PLAYING); - handleActionTriggers(Actiontrigger.RECORDING_START_PLAYING); - } - break; - case Player.MediaType.TV: - if (_lastAction == Actiontrigger.TV_PAUSED) { - handleActionTriggers(Actiontrigger.TV_PAUSE_RESUMED); - } else if (_lastAction != Actiontrigger.TV_PAUSE_RESUMED) { - triggerStopPlayingMedia(Actiontrigger.TV_START_PLAYING); - handleActionTriggers(Actiontrigger.TV_START_PLAYING); - } - break; - case Player.MediaType.Video: - if (_lastAction == Actiontrigger.VIDEO_PAUSED) { - handleActionTriggers(Actiontrigger.VIDEO_PAUSE_RESUMED); - } else if (_lastAction != Actiontrigger.VIDEO_PAUSE_RESUMED) { - triggerStopPlayingMedia(Actiontrigger.TV_START_PLAYING); - handleActionTriggers(Actiontrigger.VIDEO_START_PLAYING); - } - break; - case Player.MediaType.Unknown: - default: - if (_lastAction == Actiontrigger.UNKNOWN_PAUSED) { - handleActionTriggers(Actiontrigger.UNKNOWN_PAUSE_RESUMED); - } else if (_lastAction != Actiontrigger.UNKNOWN_PAUSE_RESUMED) { - triggerStopPlayingMedia(Actiontrigger.UNKNOWN_START_PLAYING); - handleActionTriggers(Actiontrigger.UNKNOWN_START_PLAYING); - } - break; - } - } - - private void triggerStopPlayingMedia(Actiontrigger newAction) - { - switch(_lastAction) - { - case Actiontrigger.MUSIC_START_PLAYING: - case Actiontrigger.MUSIC_PAUSED: - case Actiontrigger.MUSIC_PAUSE_RESUMED: - if (newAction != Actiontrigger.MUSIC_START_PLAYING) { - handleActionTriggers(Actiontrigger.MUSIC_STOPPED); - } - break; - case Actiontrigger.RADIO_START_PLAYING: - case Actiontrigger.RADIO_PAUSED: - case Actiontrigger.RADIO_PAUSE_RESUMED: - if (newAction != Actiontrigger.RADIO_START_PLAYING) { - handleActionTriggers(Actiontrigger.RADIO_STOPPED); - } - break; - case Actiontrigger.RECORDING_START_PLAYING: - case Actiontrigger.RECORDING_PAUSED: - case Actiontrigger.RECORDING_PAUSE_RESUMED: - if (newAction != Actiontrigger.RECORDING_START_PLAYING) { - handleActionTriggers(Actiontrigger.RECORDING_STOPPED); - } - break; - case Actiontrigger.TV_START_PLAYING: - case Actiontrigger.TV_PAUSED: - case Actiontrigger.TV_PAUSE_RESUMED: - if (newAction != Actiontrigger.TV_START_PLAYING) { - handleActionTriggers(Actiontrigger.TV_STOPPED); - } - break; - case Actiontrigger.VIDEO_START_PLAYING: - case Actiontrigger.VIDEO_PAUSED: - case Actiontrigger.VIDEO_PAUSE_RESUMED: - if (newAction != Actiontrigger.VIDEO_START_PLAYING) { - handleActionTriggers(Actiontrigger.VIDEO_STOPPED); - } - break; - case Actiontrigger.UNKNOWN_START_PLAYING: - case Actiontrigger.UNKNOWN_PAUSED: - case Actiontrigger.UNKNOWN_PAUSE_RESUMED: - if (newAction != Actiontrigger.UNKNOWN_START_PLAYING) { - handleActionTriggers(Actiontrigger.UNKNOWN_STOPPED); - } - break; - } - } - - - public void handleActionTriggers(Actiontrigger action) - { - /* - * Action handler: - * - start up --> plugin init - * - shut down/hibernate --> Action: ACTION_SHUTDOWN - * - resume from hibernate ??? - * - quit --> Action: ACTION_EXIT - * - * Music + Video + Radio + Recording + TV + Unknown - * - play --> PLayer_started && media - * - pause --> Action == Action.ActionType.ACTION_PAUSE && g_Player.Paused - * - stop --> PLayer_started && media - */ - - if (_lastAction == action || !_enableSceneTrigger) - { - // Never send the same action twice... || check if scene trigger is enabled - return; - } - //Store last action - never send the same action twice... - _lastAction = action; + case Action.ActionType.ACTION_HIBERNATE: + case Action.ActionType.ACTION_POWER_OFF: + case Action.ActionType.ACTION_REBOOT: + case Action.ActionType.ACTION_SHUTDOWN: + case Action.ActionType.ACTION_SUSPEND: + handleActionTriggers(Actiontrigger.MP_SHUTDOWN); + break; + + // Resume ? how to determine (Plug in init?) + default: + break; + + } + } + + private void g_Player_PlayBackEnded(Player.MediaType media, string filename) + { + g_Player_PlayBackStopped(media, 0, filename); + } + + private void g_Player_PlayBackStopped(Player.MediaType media, int stoptime, string filename) + { + switch(media) + { + case Player.MediaType.Music: + handleActionTriggers(Actiontrigger.MUSIC_STOPPED); + break; + case Player.MediaType.Radio: + handleActionTriggers(Actiontrigger.RADIO_STOPPED); + break; + case Player.MediaType.Recording: + handleActionTriggers(Actiontrigger.RECORDING_STOPPED); + break; + case Player.MediaType.TV: + handleActionTriggers(Actiontrigger.TV_STOPPED); + break; + case Player.MediaType.Video: + handleActionTriggers(Actiontrigger.VIDEO_STOPPED); + break; + case Player.MediaType.Unknown: + default: + handleActionTriggers(Actiontrigger.UNKNOWN_STOPPED); + break; + } + } + + private void g_Player_PlayBackStarted(Player.MediaType media, string filename) + { + switch(media) + { + case Player.MediaType.Music: + if (_lastAction == Actiontrigger.MUSIC_PAUSED) { + handleActionTriggers(Actiontrigger.MUSIC_PAUSE_RESUMED); + } else if (_lastAction != Actiontrigger.MUSIC_PAUSE_RESUMED) { + triggerStopPlayingMedia(Actiontrigger.MUSIC_START_PLAYING); + handleActionTriggers(Actiontrigger.MUSIC_START_PLAYING); + } + break; + case Player.MediaType.Radio: + if (_lastAction == Actiontrigger.RADIO_PAUSED) { + handleActionTriggers(Actiontrigger.RADIO_PAUSE_RESUMED); + } else if (_lastAction != Actiontrigger.RADIO_PAUSE_RESUMED) { + triggerStopPlayingMedia(Actiontrigger.RADIO_START_PLAYING); + handleActionTriggers(Actiontrigger.RADIO_START_PLAYING); + } + break; + case Player.MediaType.Recording: + if (_lastAction == Actiontrigger.RECORDING_PAUSED) { + handleActionTriggers(Actiontrigger.RECORDING_PAUSE_RESUMED); + } else if (_lastAction != Actiontrigger.RECORDING_PAUSE_RESUMED) { + triggerStopPlayingMedia(Actiontrigger.RECORDING_START_PLAYING); + handleActionTriggers(Actiontrigger.RECORDING_START_PLAYING); + } + break; + case Player.MediaType.TV: + if (_lastAction == Actiontrigger.TV_PAUSED) { + handleActionTriggers(Actiontrigger.TV_PAUSE_RESUMED); + } else if (_lastAction != Actiontrigger.TV_PAUSE_RESUMED) { + triggerStopPlayingMedia(Actiontrigger.TV_START_PLAYING); + handleActionTriggers(Actiontrigger.TV_START_PLAYING); + } + break; + case Player.MediaType.Video: + if (_lastAction == Actiontrigger.VIDEO_PAUSED) { + handleActionTriggers(Actiontrigger.VIDEO_PAUSE_RESUMED); + } else if (_lastAction != Actiontrigger.VIDEO_PAUSE_RESUMED) { + triggerStopPlayingMedia(Actiontrigger.TV_START_PLAYING); + handleActionTriggers(Actiontrigger.VIDEO_START_PLAYING); + } + break; + case Player.MediaType.Unknown: + default: + if (_lastAction == Actiontrigger.UNKNOWN_PAUSED) { + handleActionTriggers(Actiontrigger.UNKNOWN_PAUSE_RESUMED); + } else if (_lastAction != Actiontrigger.UNKNOWN_PAUSE_RESUMED) { + triggerStopPlayingMedia(Actiontrigger.UNKNOWN_START_PLAYING); + handleActionTriggers(Actiontrigger.UNKNOWN_START_PLAYING); + } + break; + } + } + + private void triggerStopPlayingMedia(Actiontrigger newAction) + { + switch(_lastAction) + { + case Actiontrigger.MUSIC_START_PLAYING: + case Actiontrigger.MUSIC_PAUSED: + case Actiontrigger.MUSIC_PAUSE_RESUMED: + if (newAction != Actiontrigger.MUSIC_START_PLAYING) { + handleActionTriggers(Actiontrigger.MUSIC_STOPPED); + } + break; + case Actiontrigger.RADIO_START_PLAYING: + case Actiontrigger.RADIO_PAUSED: + case Actiontrigger.RADIO_PAUSE_RESUMED: + if (newAction != Actiontrigger.RADIO_START_PLAYING) { + handleActionTriggers(Actiontrigger.RADIO_STOPPED); + } + break; + case Actiontrigger.RECORDING_START_PLAYING: + case Actiontrigger.RECORDING_PAUSED: + case Actiontrigger.RECORDING_PAUSE_RESUMED: + if (newAction != Actiontrigger.RECORDING_START_PLAYING) { + handleActionTriggers(Actiontrigger.RECORDING_STOPPED); + } + break; + case Actiontrigger.TV_START_PLAYING: + case Actiontrigger.TV_PAUSED: + case Actiontrigger.TV_PAUSE_RESUMED: + if (newAction != Actiontrigger.TV_START_PLAYING) { + handleActionTriggers(Actiontrigger.TV_STOPPED); + } + break; + case Actiontrigger.VIDEO_START_PLAYING: + case Actiontrigger.VIDEO_PAUSED: + case Actiontrigger.VIDEO_PAUSE_RESUMED: + if (newAction != Actiontrigger.VIDEO_START_PLAYING) { + handleActionTriggers(Actiontrigger.VIDEO_STOPPED); + } + break; + case Actiontrigger.UNKNOWN_START_PLAYING: + case Actiontrigger.UNKNOWN_PAUSED: + case Actiontrigger.UNKNOWN_PAUSE_RESUMED: + if (newAction != Actiontrigger.UNKNOWN_START_PLAYING) { + handleActionTriggers(Actiontrigger.UNKNOWN_STOPPED); + } + break; + } + } + + + public void handleActionTriggers(Actiontrigger action) + { + /* + * Action handler: + * - start up --> plugin init + * - shut down/hibernate --> Action: ACTION_SHUTDOWN + * - resume from hibernate ??? + * - quit --> Action: ACTION_EXIT + * + * Music + Video + Radio + Recording + TV + Unknown + * - play --> PLayer_started && media + * - pause --> Action == Action.ActionType.ACTION_PAUSE && g_Player.Paused + * - stop --> PLayer_started && media + */ + + if (_lastAction == action || !_enableSceneTrigger) + { + // Never send the same action twice... || check if scene trigger is enabled + return; + } + //Store last action - never send the same action twice... + _lastAction = action; - if ((_vera.actionTriggerTable[(int)action] > 0) && (_vera.actionTriggerTable[(int)action] < Int16.MaxValue)) - { - Scene scene = _vera.status.GetSceneById(_vera.actionTriggerTable[(int)action]); - if (scene.id > 0) - { - scene.Run(); - } - } - } - - public override void Render(float timePassed) - { - // Give a message to the user a update failed - if (_vera.lastUpdateFailed) - { - // Show message only once! - if (!_lastUpdateFailed) - { - if (_vera.status.system.dataversion == "0") - { // Give message dialog on never connected... - new Thread (() => { NoConnection(_vera.lastUpdateError);}).Start(); - } else { - // Give an error message on screen - _vera.status.system.ReportConnectionError(_vera.lastUpdateError); - } - } - _lastUpdateFailed = true; - } - else - { // Reset failed flag again - _lastUpdateFailed = false; - } - - // vera will only update when realy required - _vera.UpdateCurrentStatus(); - refreshNow(); - - base.Render(timePassed); - } + if ((_vera.actionTriggerTable[(int)action] > 0) && (_vera.actionTriggerTable[(int)action] < NO_SCENE_SELECTED)) + { + Scene scene = _vera.status.GetSceneById(_vera.actionTriggerTable[(int)action]); + if (scene.id > 0) + { + scene.Run(); + } + } + } + + public override void Render(float timePassed) + { + // Give a message to the user a update failed + if (_vera.lastUpdateFailed) + { + // Show message only once! + if (!_lastUpdateFailed) + { + if (_vera.status.system.dataversion == "0") + { // Give message dialog on never connected... + new Thread (() => { NoConnection(_vera.lastUpdateError);}).Start(); + } else { + // Give an error message on screen + _vera.status.system.ReportConnectionError(_vera.lastUpdateError); + } + } + _lastUpdateFailed = true; + } + else + { // Reset failed flag again + _lastUpdateFailed = false; + } + + // vera will only update when realy required + _vera.UpdateCurrentStatus(); + refreshNow(); + + base.Render(timePassed); + } - public void refreshNow() - { - if (_vera.NewScreenUpdateWaitingAndClearFlag()) - { - // update system status - if (_vera.status.system.NewScreenUpdateWaitingAndClearFlag()) - { - setSystemStatus(); - } - - // if full reload has been found rebuild lists - if (_vera.status.system.fullReload ) { - listRooms(_selectedCategory, _selectedRoom); - if (_selectedRoom == Int16.MaxValue) { - listScenes(); - } else { - listDevices(_selectedRoom); - } - } - else - { - // update device status - if (_selectedRoom != Int16.MaxValue) - { - foreach (GUIListItem item in _rightList.ListItems) - { - DeviceGeneric dev = _vera.status.GetDeviceById( item.ItemId ); - if (dev.NewScreenUpdateWaitingAndClearFlag()) - { - item.Label2 = dev.GetStatusText(); - item.PinImage = _helper.GetStateImage(dev.commstate); - - //Adjust color of item when option is turned off - item.IsPlayed = !dev.isControllable; - - item.IconImage = "Vera\\"+dev.GetIconName()+".png"; - item.IconImageBig = "Vera\\"+dev.GetIconName()+".png"; - item.ThumbnailImage = "Vera\\"+dev.GetIconName()+".png"; - - Utils.SetDefaultIcons(item); - } - } - } - else - { - foreach(GUIListItem item in _rightList.ListItems) - { - Scene scene = _vera.status.GetSceneById( item.ItemId ); - if (scene.NewScreenUpdateWaitingAndClearFlag()) - { - item.Label2 = (scene.room == 0 ? "" : _vera.status.GetRoomById(scene.room).name); - item.PinImage = _helper.GetStateImage(scene.commstate); - item.IsPlayed = scene.IsActive(); - Utils.SetDefaultIcons(item); - } - } - } - } - } - } - - protected override void OnPageLoad() - { - if (_selectedCategory == 0) { _selectedCategory = Int16.MaxValue; } - - listCategories(); - listRooms(_selectedCategory, _selectedRoom); - if (_selectedRoom == Int16.MaxValue) { - listScenes(); - } else { - listDevices(_selectedRoom); - } - - // Disable Page control (for left list) - _leftList.SetPageControlVisible( false ); - - setSystemStatus(); - refreshNow(); - updateSceneTrigger(); - - base.OnPageLoad(); - } - - private void setSystemStatus() - { - if (_vera.status.system.state != DevState.NONE) { - _cmtImage.Dispose(); - _cmtImage.SetFileName(_helper.GetStateImage(_vera.status.system.state)); - _cmtImage.KeepAspectRatio = true; - _cmtImage.Visibility = System.Windows.Visibility.Visible; - _cmtImage.AllocResources(); - } else{ - _cmtImage.Visibility = System.Windows.Visibility.Hidden; - } - _comment.Label = _vera.status.system.comment; - - } - - private void listCategories() - { - int iCnt = 1; - int iSelected = 0; - GUIControl.ClearControl(GetID, _catList.GetID); - - _catList.AddSpinLabel("All", Int16.MaxValue); - - foreach( Section sec in _vera.sections ) - { - _catList.AddSpinLabel(sec.name, sec.id); - iCnt++; - if (_selectedCategory == sec.id) - { - iSelected = iCnt; - } - } - _catList.SelectedItem = iSelected; - } - - private void listScenes() - { - GUIControl.ClearControl(GetID, _rightList.GetID); - - foreach( Scene scene in _vera.scenes ) - { - GUIListItem item = new GUIListItem(scene.name); - item.Label2 = (scene.room == 0 ? "" : _vera.status.GetRoomById(scene.room).name); - item.PinImage = _helper.GetStateImage(scene.commstate); - - item.IsPlayed = scene.IsActive(); - item.ItemId = scene.id; - item.IconImage = "Vera\\Scenes.png"; - item.IconImageBig = "Vera\\Scenes.png"; - item.ThumbnailImage = "Vera\\Scenes.png"; - - Utils.SetDefaultIcons(item); - _rightList.Add(item); - } - GUIControl.FocusControl(GetID, _leftList.GetID); + public void refreshNow() + { + if (_vera.NewScreenUpdateWaitingAndClearFlag()) + { + // update system status + if (_vera.status.system.NewScreenUpdateWaitingAndClearFlag()) + { + setSystemStatus(); + } + + // if full reload has been found rebuild lists + if (_vera.status.system.fullReload ) { + listRooms(_selectedCategory, _selectedRoom); + if (_selectedRoom == ALL) { + listScenes(ALL); + } else { + listDevices(_selectedRoom); + } + } + else + { + // update device status + foreach (GUIListItem item in _rightList.ListItems) + { + if (item.ItemId > 0) + { // ItemId > 0 so we have a device + DeviceGeneric dev = _vera.status.GetDeviceById(item.ItemId); + if (dev.NewScreenUpdateWaitingAndClearFlag()) + { + fillinDeviceInfo(item, dev); + } + } + else + { // ItemId < 0 so we have a scene + Scene scene = _vera.status.GetSceneById((item.ItemId * -1)); + if (scene.NewScreenUpdateWaitingAndClearFlag()) + { + fillinSceneInfo(item, scene); + } + } + } + } + } + } + + protected override void OnPageLoad() + { + if (_selectedCategory == 0) { _selectedCategory = ALL; } + + listCategories(); + listRooms(_selectedCategory, _selectedRoom); + if (_selectedRoom == ALL) { + listScenes(ALL); + } else { + listDevices(_selectedRoom); + } + + // Disable Page control (for left list) + _leftList.SetPageControlVisible( false ); + + setSystemStatus(); + refreshNow(); + updateSceneTrigger(); + + base.OnPageLoad(); + } + + private void setSystemStatus() + { + if (_vera.status.system.state != DevState.NONE) { + _cmtImage.Dispose(); + _cmtImage.SetFileName(_helper.GetStateImage(_vera.status.system.state)); + _cmtImage.KeepAspectRatio = true; + _cmtImage.Visibility = System.Windows.Visibility.Visible; + _cmtImage.AllocResources(); + } else{ + _cmtImage.Visibility = System.Windows.Visibility.Hidden; + } + _comment.Label = _vera.status.system.comment; + + } + + private void listCategories() + { + int iCnt = 1; + int iSelected = 0; + GUIControl.ClearControl(GetID, _catList.GetID); + + _catList.AddSpinLabel("All", ALL); + + foreach( Section sec in _vera.sections ) + { + _catList.AddSpinLabel(sec.name, sec.id); + iCnt++; + if (_selectedCategory == sec.id) + { + iSelected = iCnt; + } + } + _catList.SelectedItem = iSelected; + } + + private void listRooms(int showSection, int selectedRoom) + { + int cnt = 0; + int selected = 0; + // --- fill in left lisft with rooms and scene item + GUIControl.ClearControl(GetID, _leftList.GetID); + GUIListItem sceneitem = new GUIListItem("Scenes"); + sceneitem.ItemId = ALL; - // Set Current Selected Item - _rightList.SelectedListItemIndex = 0; + sceneitem.IconImage = "Vera\\Scenes.png"; + sceneitem.IconImageBig = "Vera\\Scenes.png"; + sceneitem.ThumbnailImage = "Vera\\Scenes.png"; + + Utils.SetDefaultIcons(sceneitem); + _leftList.Add(sceneitem); + + foreach(Room room in _vera.rooms) + { + if (showSection == ALL|| room.section == showSection) + { + GUIListItem item = new GUIListItem(room.name); + item.Label2 = _vera.status.GetSectionById(room.section).name; + + item.ItemId = room.id; + item.IconImage = "fastforward_enabled.png"; + item.IconImageBig = "fastforward_enabled.png"; + item.ThumbnailImage = "fastforward_enabled.png"; + + Utils.SetDefaultIcons(item); + _leftList.Add(item); - _title.Label = _titleTxt + " - Scenes"; - } - - private void listRooms(int iShowSection, int iSelectedRoom) - { - int iCnt = 0; - int iSelected = 0; - // --- fill in left lisft with rooms and scene item - GUIControl.ClearControl(GetID, _leftList.GetID); - GUIListItem sceneitem = new GUIListItem("Scenes"); - sceneitem.ItemId = Int16.MaxValue; + cnt++; + if (selectedRoom == room.id) + { + selected = cnt; + } + } + } + // Set Current Selected Item + _leftList.SelectedListItemIndex = selected; + } + + private void listScenes(int selectedRoom) + { + GUIControl.ClearControl(GetID, _rightList.GetID); + + foreach(Scene scene in _vera.scenes) + { + if (selectedRoom == ALL || scene.InRoom(selectedRoom)) + { + GUIListItem item = new GUIListItem(scene.name); + fillinSceneInfo(item, scene); + _rightList.Add(item); + } + } + GUIControl.FocusControl(GetID, _leftList.GetID); - sceneitem.IconImage = "Vera\\Scenes.png"; - sceneitem.IconImageBig = "Vera\\Scenes.png"; - sceneitem.ThumbnailImage = "Vera\\Scenes.png"; - - Utils.SetDefaultIcons(sceneitem); - _leftList.Add(scene... [truncated message content] |
From: <Ba...@us...> - 2012-01-25 23:00:25
|
Revision: 4425 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4425&view=rev Author: BartEv Date: 2012-01-25 23:00:16 +0000 (Wed, 25 Jan 2012) Log Message: ----------- First stable release Modified Paths: -------------- trunk/plugins/VeraControl/DeviceCam.cs trunk/plugins/VeraControl/DeviceSprinkler.cs trunk/plugins/VeraControl/DeviceSystem.cs trunk/plugins/VeraControl/DialogDeviceControl.cs trunk/plugins/VeraControl/DialogSceneControl.cs trunk/plugins/VeraControl/Scene.cs trunk/plugins/VeraControl/VeraCommunication.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/VeraControl.csproj trunk/plugins/VeraControl/VeraHelper.cs trunk/plugins/VeraControl/VeraSetupForm.Designer.cs trunk/plugins/VeraControl/VeraSetupForm.cs trunk/plugins/VeraControl/releases/VeraControl.xmp2 trunk/plugins/VeraControl/releases/update.xml trunk/plugins/VeraControl/skin/Default/VeraControl.xml trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml trunk/plugins/VeraControl/skin/Default/VeraDialogSceneControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogSceneControl.xml trunk/plugins/VeraControl/skin/Media/Vera/Binary_Light_0.png trunk/plugins/VeraControl/skin/Media/Vera/Binary_Light_100.png trunk/plugins/VeraControl/skin/Media/Vera/Dimmable_Light_0.png trunk/plugins/VeraControl/skin/Media/Vera/Dimmable_Light_100.png trunk/plugins/VeraControl/skin/Media/Vera/Dimmable_Light_25.png trunk/plugins/VeraControl/skin/Media/Vera/Dimmable_Light_50.png trunk/plugins/VeraControl/skin/Media/Vera/Dimmable_Light_75.png trunk/plugins/VeraControl/skin/Media/Vera/Door_Lock.png trunk/plugins/VeraControl/skin/Media/Vera/Door_Lock_0.png trunk/plugins/VeraControl/skin/Media/Vera/Door_Lock_100.png trunk/plugins/VeraControl/skin/Media/Vera/Generic_IO.png trunk/plugins/VeraControl/skin/Media/Vera/Humidity_Sensor.png trunk/plugins/VeraControl/skin/Media/Vera/IR_Transmitter.png trunk/plugins/VeraControl/skin/Media/Vera/Ip_Camera.png trunk/plugins/VeraControl/skin/Media/Vera/Light_Sensor.png trunk/plugins/VeraControl/skin/Media/Vera/Motion_Sensor_0.png trunk/plugins/VeraControl/skin/Media/Vera/Motion_Sensor_100.png trunk/plugins/VeraControl/skin/Media/Vera/Power_Meter.png trunk/plugins/VeraControl/skin/Media/Vera/Scenes.png trunk/plugins/VeraControl/skin/Media/Vera/Temperature_Sensor.png trunk/plugins/VeraControl/skin/Media/Vera/Thermostat.png trunk/plugins/VeraControl/skin/Media/Vera/USB_UIRT.png trunk/plugins/VeraControl/skin/Media/Vera/default_panel.png trunk/plugins/VeraControl/skin/Media/Vera/energy.png trunk/plugins/VeraControl/skin/Media/Vera/findvera.png trunk/plugins/VeraControl/skin/Media/Vera/generic_sensor.png trunk/plugins/VeraControl/skin/Media/Vera/location.png trunk/plugins/VeraControl/skin/Media/Vera/music_audio.png trunk/plugins/VeraControl/skin/Media/Vera/plugins.png trunk/plugins/VeraControl/skin/Media/Vera/users.png Added Paths: ----------- trunk/plugins/VeraControl/JSON.cs trunk/plugins/VeraControl/releases/VeraControl_v0.9.0.1.mpe1 trunk/plugins/VeraControl/skin/Media/Vera/OpenList.png trunk/plugins/VeraControl/skin/Media/Vera/Scenes_active.png trunk/plugins/VeraControl/skin/Media/Vera/Sprinkler.png trunk/plugins/VeraControl/skin/Media/Vera/state_command_error.png trunk/plugins/VeraControl/skin/Media/Vera/state_connection_error.png trunk/plugins/VeraControl/skin/Media/Vera/state_error.png trunk/plugins/VeraControl/skin/Media/Vera/state_pending.png trunk/plugins/VeraControl/skin/Media/Vera/state_success.png Modified: trunk/plugins/VeraControl/DeviceCam.cs =================================================================== --- trunk/plugins/VeraControl/DeviceCam.cs 2012-01-23 23:04:46 UTC (rev 4424) +++ trunk/plugins/VeraControl/DeviceCam.cs 2012-01-25 23:00:16 UTC (rev 4425) @@ -58,7 +58,7 @@ public string imgUrl { - get { return "http://" + passString + _vera.veraAddress + "/data_request?id=cam_image¶meters=get_video_frame&Device_Num=" + id + "&rand=" + DateTime.Now.Ticks; + get { return _vera.veraAddress + "/data_request?id=cam_image¶meters=get_video_frame&Device_Num=" + id + "&rand=" + DateTime.Now.Ticks; // return "http://" + passString + m_sIp + "/" + m_sUrl.Replace("%2F", "/"); } set { } Modified: trunk/plugins/VeraControl/DeviceSprinkler.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-23 23:04:46 UTC (rev 4424) +++ trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-25 23:00:16 UTC (rev 4425) @@ -100,7 +100,7 @@ public override string GetIconName() { - return "Humidity_Sensor"; + return "Sprinkler"; } public override string GetStatusText() Modified: trunk/plugins/VeraControl/DeviceSystem.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSystem.cs 2012-01-23 23:04:46 UTC (rev 4424) +++ trunk/plugins/VeraControl/DeviceSystem.cs 2012-01-25 23:00:16 UTC (rev 4425) @@ -21,30 +21,30 @@ { } - public VeraHelper _helper = VeraHelper.Instance; + public VeraHelper _helper = VeraHelper.Instance; - public long _lastUpdate = 0; + public long _lastUpdate = 0; public bool _screenUpdateRequired = false; - private bool _fullReload = true; - private string _version = ""; - private string _model = ""; - private bool _zWaveHeal = false; - private bool _metric = true; - private string _serial = ""; - private string _fwd1Server = ""; - private string _fwd2Server = ""; - private string _loadTime = "0"; - private string _dataVersion = "0"; - private string _comment = ""; - private DevState _dsVeraState = DevState.NONE; + private bool _fullReload = true; + private string _version = ""; + private string _model = ""; + private bool _zWaveHeal = false; + private bool _metric = true; + private string _serial = ""; + private string _fwd1Server = ""; + private string _fwd2Server = ""; + private string _loadTime = "0"; + private string _dataVersion = "0"; + private string _comment = ""; + private DevState _dsVeraState = DevState.NONE; public bool update(XmlNode xn) { _fullReload = _helper.GetAttrAsBool (xn, "full", _fullReload); _version = _helper.GetAttrAsString (xn, "version", _version); - _model = _helper.GetAttrAsString (xn, "model", _model); - _zWaveHeal = _helper.GetAttrAsBool (xn, "zwave_heal", _zWaveHeal); + _model = _helper.GetAttrAsString (xn, "model", _model); + _zWaveHeal = _helper.GetAttrAsBool (xn, "zwave_heal", _zWaveHeal); _serial = _helper.GetAttrAsString (xn, "serial_number", _serial); _fwd1Server = _helper.GetAttrAsString (xn, "fwd1", _fwd1Server); _fwd2Server = _helper.GetAttrAsString (xn, "fwd2", _fwd2Server); Modified: trunk/plugins/VeraControl/DialogDeviceControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-23 23:04:46 UTC (rev 4424) +++ trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-01-25 23:00:16 UTC (rev 4425) @@ -254,7 +254,7 @@ { _myDev.level = _desiredLevel; _slider.IntValue = _desiredLevel; - _lastLevelUpdate = DateTime.Now.Ticks + (TimeSpan.TicksPerSecond * 2); + _lastLevelUpdate = DateTime.Now.Ticks + (TimeSpan.TicksPerSecond * 2); } _levelUpdatePending = false; } Modified: trunk/plugins/VeraControl/DialogSceneControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogSceneControl.cs 2012-01-23 23:04:46 UTC (rev 4424) +++ trunk/plugins/VeraControl/DialogSceneControl.cs 2012-01-25 23:00:16 UTC (rev 4425) @@ -69,6 +69,11 @@ _label1.Label = _myScene.name; + _imgLogo.Dispose(); + _imgLogo.SetFileName(@"Vera\" + _myScene.GetIconName() + ".png"); + _imgLogo.AllocResources(); + _imgLogo.KeepAspectRatio = true; + // save last update ticks _lastUpdate = DateTime.Now.Ticks; } Added: trunk/plugins/VeraControl/JSON.cs =================================================================== --- trunk/plugins/VeraControl/JSON.cs (rev 0) +++ trunk/plugins/VeraControl/JSON.cs 2012-01-25 23:00:16 UTC (rev 4425) @@ -0,0 +1,497 @@ +using System; +using System.Collections; +using System.Globalization; +using System.Text; + +namespace VeraControl.Properties +{ + /// <summary> + /// This class encodes and decodes JSON strings. + /// Spec. details, see http://www.json.org/ + /// + /// JSON uses Arrays and Objects. These correspond here to the datatypes ArrayList and Hashtable. + /// All numbers are parsed to doubles. + /// </summary> + public class JSON + { + public const int TOKEN_NONE = 0; + public const int TOKEN_CURLY_OPEN = 1; + public const int TOKEN_CURLY_CLOSE = 2; + public const int TOKEN_SQUARED_OPEN = 3; + public const int TOKEN_SQUARED_CLOSE = 4; + public const int TOKEN_COLON = 5; + public const int TOKEN_COMMA = 6; + public const int TOKEN_STRING = 7; + public const int TOKEN_NUMBER = 8; + public const int TOKEN_TRUE = 9; + public const int TOKEN_FALSE = 10; + public const int TOKEN_NULL = 11; + + private const int BUILDER_CAPACITY = 2000; + + /// <summary> + /// Parses the string json into a value + /// </summary> + /// <param name="json">A JSON string.</param> + /// <returns>An ArrayList, a Hashtable, a double, a string, null, true, or false</returns> + public static object JsonDecode(string json) + { + bool success = true; + + return JsonDecode(json, ref success); + } + + /// <summary> + /// Parses the string json into a value; and fills 'success' with the successfullness of the parse. + /// </summary> + /// <param name="json">A JSON string.</param> + /// <param name="success">Successful parse?</param> + /// <returns>An ArrayList, a Hashtable, a double, a string, null, true, or false</returns> + public static object JsonDecode(string json, ref bool success) + { + success = true; + if (json != null) { + char[] charArray = json.ToCharArray(); + int index = 0; + object value = ParseValue(charArray, ref index, ref success); + return value; + } else { + return null; + } + } + + /// <summary> + /// Converts a Hashtable / ArrayList object into a JSON string + /// </summary> + /// <param name="json">A Hashtable / ArrayList</param> + /// <returns>A JSON encoded string, or null if object 'json' is not serializable</returns> + public static string JsonEncode(object json) + { + StringBuilder builder = new StringBuilder(BUILDER_CAPACITY); + bool success = SerializeValue(json, builder); + return (success ? builder.ToString() : null); + } + + protected static Hashtable ParseObject(char[] json, ref int index, ref bool success) + { + Hashtable table = new Hashtable(); + int token; + + // { + NextToken(json, ref index); + + bool done = false; + while (!done) { + token = LookAhead(json, index); + if (token == JSON.TOKEN_NONE) { + success = false; + return null; + } else if (token == JSON.TOKEN_COMMA) { + NextToken(json, ref index); + } else if (token == JSON.TOKEN_CURLY_CLOSE) { + NextToken(json, ref index); + return table; + } else { + + // name + string name = ParseString(json, ref index, ref success); + if (!success) { + success = false; + return null; + } + + // : + token = NextToken(json, ref index); + if (token != JSON.TOKEN_COLON) { + success = false; + return null; + } + + // value + object value = ParseValue(json, ref index, ref success); + if (!success) { + success = false; + return null; + } + + table[name] = value; + } + } + + return table; + } + + protected static ArrayList ParseArray(char[] json, ref int index, ref bool success) + { + ArrayList array = new ArrayList(); + + // [ + NextToken(json, ref index); + + bool done = false; + while (!done) { + int token = LookAhead(json, index); + if (token == JSON.TOKEN_NONE) { + success = false; + return null; + } else if (token == JSON.TOKEN_COMMA) { + NextToken(json, ref index); + } else if (token == JSON.TOKEN_SQUARED_CLOSE) { + NextToken(json, ref index); + break; + } else { + object value = ParseValue(json, ref index, ref success); + if (!success) { + return null; + } + + array.Add(value); + } + } + + return array; + } + + protected static object ParseValue(char[] json, ref int index, ref bool success) + { + switch (LookAhead(json, index)) { + case JSON.TOKEN_STRING: + return ParseString(json, ref index, ref success); + case JSON.TOKEN_NUMBER: + return ParseNumber(json, ref index, ref success); + case JSON.TOKEN_CURLY_OPEN: + return ParseObject(json, ref index, ref success); + case JSON.TOKEN_SQUARED_OPEN: + return ParseArray(json, ref index, ref success); + case JSON.TOKEN_TRUE: + NextToken(json, ref index); + return true; + case JSON.TOKEN_FALSE: + NextToken(json, ref index); + return false; + case JSON.TOKEN_NULL: + NextToken(json, ref index); + return null; + case JSON.TOKEN_NONE: + break; + } + + success = false; + return null; + } + + protected static string ParseString(char[] json, ref int index, ref bool success) + { + StringBuilder s = new StringBuilder(BUILDER_CAPACITY); + char c; + + EatWhitespace(json, ref index); + + // " + c = json[index++]; + + bool complete = false; + while (!complete) { + + if (index == json.Length) { + break; + } + + c = json[index++]; + if (c == '"') { + complete = true; + break; + } else if (c == '\\') { + + if (index == json.Length) { + break; + } + c = json[index++]; + if (c == '"') { + s.Append('"'); + } else if (c == '\\') { + s.Append('\\'); + } else if (c == '/') { + s.Append('/'); + } else if (c == 'b') { + s.Append('\b'); + } else if (c == 'f') { + s.Append('\f'); + } else if (c == 'n') { + s.Append('\n'); + } else if (c == 'r') { + s.Append('\r'); + } else if (c == 't') { + s.Append('\t'); + } else if (c == 'u') { + int remainingLength = json.Length - index; + if (remainingLength >= 4) { + // parse the 32 bit hex into an integer codepoint + uint codePoint; + if (!(success = UInt32.TryParse(new string(json, index, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codePoint))) { + return ""; + } + // convert the integer codepoint to a unicode char and add to string + s.Append(Char.ConvertFromUtf32((int)codePoint)); + // skip 4 chars + index += 4; + } else { + break; + } + } + + } else { + s.Append(c); + } + + } + + if (!complete) { + success = false; + return null; + } + + return s.ToString(); + } + + protected static double ParseNumber(char[] json, ref int index, ref bool success) + { + EatWhitespace(json, ref index); + + int lastIndex = GetLastIndexOfNumber(json, index); + int charLength = (lastIndex - index) + 1; + + double number; + success = Double.TryParse(new string(json, index, charLength), NumberStyles.Any, CultureInfo.InvariantCulture, out number); + + index = lastIndex + 1; + return number; + } + + protected static int GetLastIndexOfNumber(char[] json, int index) + { + int lastIndex; + + for (lastIndex = index; lastIndex < json.Length; lastIndex++) { + if ("0123456789+-.eE".IndexOf(json[lastIndex]) == -1) { + break; + } + } + return lastIndex - 1; + } + + protected static void EatWhitespace(char[] json, ref int index) + { + for (; index < json.Length; index++) { + if (" \t\n\r".IndexOf(json[index]) == -1) { + break; + } + } + } + + protected static int LookAhead(char[] json, int index) + { + int saveIndex = index; + return NextToken(json, ref saveIndex); + } + + protected static int NextToken(char[] json, ref int index) + { + EatWhitespace(json, ref index); + + if (index == json.Length) { + return JSON.TOKEN_NONE; + } + + char c = json[index]; + index++; + switch (c) { + case '{': + return JSON.TOKEN_CURLY_OPEN; + case '}': + return JSON.TOKEN_CURLY_CLOSE; + case '[': + return JSON.TOKEN_SQUARED_OPEN; + case ']': + return JSON.TOKEN_SQUARED_CLOSE; + case ',': + return JSON.TOKEN_COMMA; + case '"': + return JSON.TOKEN_STRING; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + case '-': + return JSON.TOKEN_NUMBER; + case ':': + return JSON.TOKEN_COLON; + } + index--; + + int remainingLength = json.Length - index; + + // false + if (remainingLength >= 5) { + if (json[index] == 'f' && + json[index + 1] == 'a' && + json[index + 2] == 'l' && + json[index + 3] == 's' && + json[index + 4] == 'e') { + index += 5; + return JSON.TOKEN_FALSE; + } + } + + // true + if (remainingLength >= 4) { + if (json[index] == 't' && + json[index + 1] == 'r' && + json[index + 2] == 'u' && + json[index + 3] == 'e') { + index += 4; + return JSON.TOKEN_TRUE; + } + } + + // null + if (remainingLength >= 4) { + if (json[index] == 'n' && + json[index + 1] == 'u' && + json[index + 2] == 'l' && + json[index + 3] == 'l') { + index += 4; + return JSON.TOKEN_NULL; + } + } + + return JSON.TOKEN_NONE; + } + + protected static bool SerializeValue(object value, StringBuilder builder) + { + bool success = true; + + if (value is string) { + success = SerializeString((string)value, builder); + } else if (value is Hashtable) { + success = SerializeObject((Hashtable)value, builder); + } else if (value is ArrayList) { + success = SerializeArray((ArrayList)value, builder); + } else if (IsNumeric(value)) { + success = SerializeNumber(Convert.ToDouble(value), builder); + } else if ((value is Boolean) && ((Boolean)value == true)) { + builder.Append("true"); + } else if ((value is Boolean) && ((Boolean)value == false)) { + builder.Append("false"); + } else if (value == null) { + builder.Append("null"); + } else { + success = false; + } + return success; + } + + protected static bool SerializeObject(Hashtable anObject, StringBuilder builder) + { + builder.Append("{"); + + IDictionaryEnumerator e = anObject.GetEnumerator(); + bool first = true; + while (e.MoveNext()) { + string key = e.Key.ToString(); + object value = e.Value; + + if (!first) { + builder.Append(", "); + } + + SerializeString(key, builder); + builder.Append(":"); + if (!SerializeValue(value, builder)) { + return false; + } + + first = false; + } + + builder.Append("}"); + return true; + } + + protected static bool SerializeArray(ArrayList anArray, StringBuilder builder) + { + builder.Append("["); + + bool first = true; + for (int i = 0; i < anArray.Count; i++) { + object value = anArray[i]; + + if (!first) { + builder.Append(", "); + } + + if (!SerializeValue(value, builder)) { + return false; + } + + first = false; + } + + builder.Append("]"); + return true; + } + + protected static bool SerializeString(string aString, StringBuilder builder) + { + builder.Append("\""); + + char[] charArray = aString.ToCharArray(); + for (int i = 0; i < charArray.Length; i++) { + char c = charArray[i]; + if (c == '"') { + builder.Append("\\\""); + } else if (c == '\\') { + builder.Append("\\\\"); + } else if (c == '\b') { + builder.Append("\\b"); + } else if (c == '\f') { + builder.Append("\\f"); + } else if (c == '\n') { + builder.Append("\\n"); + } else if (c == '\r') { + builder.Append("\\r"); + } else if (c == '\t') { + builder.Append("\\t"); + } else { + int codepoint = Convert.ToInt32(c); + if ((codepoint >= 32) && (codepoint <= 126)) { + builder.Append(c); + } else { + builder.Append("\\u" + Convert.ToString(codepoint, 16).PadLeft(4, '0')); + } + } + } + + builder.Append("\""); + return true; + } + + protected static bool SerializeNumber(double number, StringBuilder builder) + { + builder.Append(Convert.ToString(number, CultureInfo.InvariantCulture)); + return true; + } + + /// <summary> + /// Determines if a given object is numeric in any way + /// (can be integer, double, null, etc). + /// + /// Thanks to mtighe for pointing out Double.TryParse to me. + /// </summary> + protected static bool IsNumeric(object o) + { + double result; + + return (o == null) ? false : Double.TryParse(o.ToString(), out result); + } + } +} Modified: trunk/plugins/VeraControl/Scene.cs =================================================================== --- trunk/plugins/VeraControl/Scene.cs 2012-01-23 23:04:46 UTC (rev 4424) +++ trunk/plugins/VeraControl/Scene.cs 2012-01-25 23:00:16 UTC (rev 4425) @@ -44,7 +44,7 @@ public override string GetIconName() { - return "Scenes"; + return "Scenes" + (IsActive() ? "_active":""); } public override string GetStatusText() Modified: trunk/plugins/VeraControl/VeraCommunication.cs =================================================================== --- trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-23 23:04:46 UTC (rev 4424) +++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-01-25 23:00:16 UTC (rev 4425) @@ -17,650 +17,684 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of VeraCommunication. - /// </summary> - - public class VeraStatus - { - public DeviceSystem system = new DeviceSystem(); - public List<DeviceGeneric> devices = new List<DeviceGeneric>(); - public List<Scene> scenes = new List<Scene>(); - public List<Room> rooms = new List<Room>(); - public List<DevCategories> categories = new List<DevCategories>(); - public List<Section> sections = new List<Section>(); - - #region Vers get by id support functions + /// <summary> + /// Description of VeraCommunication. + /// </summary> + + public class VeraStatus + { + public DeviceSystem system = new DeviceSystem(); + public List<DeviceGeneric> devices = new List<DeviceGeneric>(); + public List<Scene> scenes = new List<Scene>(); + public List<Room> rooms = new List<Room>(); + public List<DevCategories> categories = new List<DevCategories>(); + public List<Section> sections = new List<Section>(); + + #region Vers get by id support functions - public void ClearAllLists() - { - devices.Clear(); - scenes.Clear(); - rooms.Clear(); - categories.Clear(); - sections.Clear(); - } - public Room GetRoomById(int id) - { - foreach(Room room in rooms) - { - if (room.id == id) - { - return room; - } - } - return new Room(null); - } - - public Section GetSectionById(int id) - { - foreach(Section section in sections) - { - if (section.id == id) - { - return section; - } - } - return new Section(null); - } - - public DeviceGeneric GetDeviceById(int id) - { - foreach(DeviceGeneric dev in devices) - { - if (dev.id == id) - { - return dev; - } - } - return new DeviceGeneric(null); - } + public void ClearAllLists() + { + devices.Clear(); + scenes.Clear(); + rooms.Clear(); + categories.Clear(); + sections.Clear(); + } + public Room GetRoomById(int id) + { + foreach(Room room in rooms) + { + if (room.id == id) + { + return room; + } + } + return new Room(null); + } + + public Section GetSectionById(int id) + { + foreach(Section section in sections) + { + if (section.id == id) + { + return section; + } + } + return new Section(null); + } + + public DeviceGeneric GetDeviceById(int id) + { + foreach(DeviceGeneric dev in devices) + { + if (dev.id == id) + { + return dev; + } + } + return new DeviceGeneric(null); + } - public Scene GetSceneById(int id) - { - foreach(Scene scene in scenes) - { - if (scene.id == id) - { - return scene; - } - } - return new Scene(null); - } - - public DevCategories GetCategoryById(int id) - { - foreach(DevCategories cat in categories) - { - if (cat.id == id) - { - return cat; - } - } - return new DevCategories(null); - } - - public bool IsSectionFound(int id) - { - foreach(Section section in sections) - { - if (section.id == id) - { - return true; - } - } - return false; - } - - public bool IsRoomFound(int id) - { - foreach(Room room in rooms) - { - if (room.id == id) - { - return true; - } - } - return false; - } - - public bool IsDeviceFound(int id) - { - foreach(DeviceGeneric dev in devices) - { - if (dev.id == id) - { - return true; - } - } - return false; - } + public Scene GetSceneById(int id) + { + foreach(Scene scene in scenes) + { + if (scene.id == id) + { + return scene; + } + } + return new Scene(null); + } + + public DevCategories GetCategoryById(int id) + { + foreach(DevCategories cat in categories) + { + if (cat.id == id) + { + return cat; + } + } + return new DevCategories(null); + } + + public bool IsSectionFound(int id) + { + foreach(Section section in sections) + { + if (section.id == id) + { + return true; + } + } + return false; + } + + public bool IsRoomFound(int id) + { + foreach(Room room in rooms) + { + if (room.id == id) + { + return true; + } + } + return false; + } + + public bool IsDeviceFound(int id) + { + foreach(DeviceGeneric dev in devices) + { + if (dev.id == id) + { + return true; + } + } + return false; + } - public bool IsSceneFound(int id) - { - foreach(Scene scene in scenes) - { - if (scene.id == id) - { - return true; - } - } - return false; - } - - public bool IsCategoryFound(int id) - { - foreach(DevCategories cat in categories) - { - if (cat.id == id) - { - return true; - } - } - return false; - } - #endregion - } - - - public sealed class VeraCommunication - { - private static volatile VeraCommunication _instance; - private static object _syncRoot = new Object(); - private VeraHelper _helper = VeraHelper.Instance; - - // Config data - private string _veraIPAddress; - private string _veraTCPIPPort; - private int _maxRefreshDelay; // Maximun delay between 2 status updates in seconds - private int _minRefreshDelay = 1000; // Minimun delay between 2 status updates in miliseconds - - // Actual device information - private VeraStatus _status = new VeraStatus(); - - // Communication status/control - private long _lastUpdate = 0; - private bool _screenUpdateRequired = false; // Only true when a new update was received AND at least one device(staus) or scene was changed - private bool _lastUpdateFailed = false; - private string _lastUpdateErrorMessage = ""; - private WebClient _webUpdateClient = new WebClient(); - private WebClient _webCommandClient = new WebClient(); - private Action<string> _webCommandClientErrorReporter = null; - - // Action control table - public int [] actionTriggerTable = new int[(int)Actiontrigger.LAST_ACTIONTRIGGER]; - - public static VeraCommunication Instance - { - get - { - if (_instance == null) - { - lock (_syncRoot) - { - if (_instance == null) - { - _instance = new VeraCommunication(); - } - } - } + public bool IsSceneFound(int id) + { + foreach(Scene scene in scenes) + { + if (scene.id == id) + { + return true; + } + } + return false; + } + + public bool IsCategoryFound(int id) + { + foreach(DevCategories cat in categories) + { + if (cat.id == id) + { + return true; + } + } + return false; + } + #endregion + } + + + public sealed class VeraCommunication + { + private static volatile VeraCommunication _instance; + private static object _syncRoot = new Object(); + private VeraHelper _helper = VeraHelper.Instance; + + // Config data + private int _maxRefreshDelay; // Maximun delay between 2 status updates in seconds + private int _minRefreshDelay = 1000; // Minimun delay between 2 status updates in miliseconds + + // Actual device information + private VeraStatus _status = new VeraStatus(); + + // Communication status/control + private long _lastUpdate = 0; + private bool _screenUpdateRequired = false; // Only true when a new update was received AND at least one device(staus) or scene was changed + private bool _lastUpdateFailed = false; + private string _lastUpdateErrorMessage = ""; + private WebClient _webUpdateClient = new WebClient(); + private WebClient _webCommandClient = new WebClient(); + private Action<string> _webCommandClientErrorReporter = null; + + // Action control table + public int [] actionTriggerTable = new int[(int)Actiontrigger.LAST_ACTIONTRIGGER]; + + public static VeraCommunication Instance + { + get + { + if (_instance == null) + { + lock (_syncRoot) + { + if (_instance == null) + { + _instance = new VeraCommunication(); + } + } + } - return _instance; - } - } - - private VeraCommunication() - { - using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) - { - _veraIPAddress = xmlreader.GetValueAsString("veracontroller", "ipaddress", "127.0.0.1"); - _veraTCPIPPort = xmlreader.GetValueAsString("veracontroller", "portnumber", "3480"); - - // Fill action table (config settings) - for (Actiontrigger i = 0; i < Actiontrigger.LAST_ACTIONTRIGGER; i++) - { - actionTriggerTable[(int)i] = xmlreader.GetValueAsInt("veracontroller", i.ToString(), 0); - } - _maxRefreshDelay = int.Parse(xmlreader.GetValueAsString("veracontroller", "maxrefreshdelay", "60")); - - // Set DownloadStringCompleted handler - _webUpdateClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnCompletedUpdateStatusRequest); - _webCommandClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnCompletedCommandRequest); - } - } - - public bool IsVeraAlive(string ip, string port) - { - string response = RetrieveURL("http://" + ip + ":" + port + "/data_request?id=lu_alive&time=" + DateTime.Now.Ticks); - return (response == "OK"); - } + return _instance; + } + } + + private VeraCommunication() + { + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) + { + // Fill action table (config settings) + for (Actiontrigger i = 0; i < Actiontrigger.LAST_ACTIONTRIGGER; i++) + { + actionTriggerTable[(int)i] = xmlreader.GetValueAsInt("veracontroller", i.ToString(), 0); + } + _maxRefreshDelay = int.Parse(xmlreader.GetValueAsString("veracontroller", "maxrefreshdelay", "60")); + + // Set DownloadStringCompleted handler + _webUpdateClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnCompletedUpdateStatusRequest); + _webCommandClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnCompletedCommandRequest); + } + } + + public bool IsVeraAlive(string ip, string port) + { + string response = RetrieveURL("http://" + ip + ":" + port + "/data_request?id=lu_alive&time=" + DateTime.Now.Ticks); + return (response == "OK"); + } - private string RetrieveURL(string url) - { - // No callback thus Synchronised call (wait for response) - try { - WebClient wc = new WebClient(); - wc.CancelAsync(); // Cancel any current pending Async calls... - return wc.DownloadString(url); - } catch( Exception ) - { - return "ERROR"; - } - } - - public void DoVeraCommandRequest(string param, Action<string> errorReporter) - { - if (_webCommandClient.IsBusy) - { - // TODO: What to do ? cancel pending request or queue new request? - for now just cancel the previous request (user is informed about the progress) - } - string url = "http://" + veraAddress + "/data_request" + param + "&time=" + DateTime.Now.Ticks; - - // Callback thus ASynchronised call (do NOT wait for response) - try { - _webCommandClientErrorReporter = errorReporter; - _webCommandClient.CancelAsync(); // Cancel any current pending Async calls... - _webCommandClient.DownloadStringAsync(new Uri(url)); - - } catch( Exception e ) - { - _webCommandClientErrorReporter = null; - status.system.ReportCommandError(e.Message); - setScreenUpdateRequired(); - } - } - - public void OnCompletedCommandRequest(object sender, DownloadStringCompletedEventArgs e) - { - if (e.Cancelled) - { - // Communication cancel for some reason, no valid data to be expected - if (_webCommandClientErrorReporter != null) - { - // Send error to dialog message handler - _webCommandClientErrorReporter("Request was canceled"); - } - else - { - // Show eror in MediaPortal Vera-main window - status.system.ReportCommandError("Request was canceled"); - } - setScreenUpdateRequired(); - } - else if (e.Error != null) - { - // Handle error here - if (_webCommandClientErrorReporter != null) - { - // Send error to dialog message handler - _webCommandClientErrorReporter(e.Error.Message); - } - else - { - // Show eror in MediaPortal Vera-main window - status.system.ReportCommandError(e.Error.Message); - } - setScreenUpdateRequired(); - } - else - { - // Communication succes full -> no parse Vera response... - if (!e.Result.ToUpper().Contains("<OK>OK</OK>") && !e.Result.ToUpper().Contains("<JOBID>")) - { - if (_webCommandClientErrorReporter != null) - { - // Send error to dialog message handler - _webCommandClientErrorReporter(e.Result); - } - else - { - // Show eror in MediaPortal Vera-main window - status.system.ReportCommandError(e.Result); - } - setScreenUpdateRequired(); - } - } - // Communication done clear error report handler - _webCommandClientErrorReporter = null; - } - - public void UpdateCurrentStatus() - { - /* Keep updating with webClient timeout 180 sec, even when last time did fail or connection was lost....*/ - if (!_webUpdateClient.IsBusy) - { - string url = "http://" + veraAddress + "/data_request" + - "?id=lu_sdata&loadtime=" + _status.system.loadtime + - "&dataversion=" + _status.system.dataversion + - "&minimumdelay=" + _minRefreshDelay + - "&timeout=" + _maxRefreshDelay + - "&output_format=xml" + - "&time=" + DateTime.Now.Ticks; - - // Callback thus ASynchronised call (do NOT wait for response) - try { - _webUpdateClient.CancelAsync(); // Cancel any current pending Async calls... - _webUpdateClient.DownloadStringAsync(new Uri(url)); - } catch( Exception e ) - { - _lastUpdateFailed = true; - _lastUpdateErrorMessage = e.Message; - } - _lastUpdate = _helper.GetSecondsSince1970(); - } - } - - public void OnCompletedUpdateStatusRequest(object sender, DownloadStringCompletedEventArgs e) - { - if (!e.Cancelled) - { - // Communication cancel for some reason, no valid data to be expected - if (e.Error != null) - { - // Handle error here - _lastUpdateFailed = true; - _lastUpdateErrorMessage = e.Error.Message; - setScreenUpdateRequired(); - } - else - { - ParseUpdateInfo(e.Result); - // ParseUpdateInfo(m_webClient.DownloadString(@"C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\testdata\text.xml")); - } - } - - // update timer again (took some time to get the data) - _lastUpdate = _helper.GetSecondsSince1970(); - } - - public void ParseUpdateInfo(string veraresponse) - { - var xmlDoc = new XmlDocument(); - try { - xmlDoc.LoadXml(veraresponse); - } catch (Exception) - { - // Parser failed so incorrect data received (could be an interrupted data transfer) - return; - } - // Parse header - XmlNode rootnode = xmlDoc.SelectSingleNode("/root"); - if (rootnode == null) - { - // Not a status update, just return - return; - } - - if (!_screenUpdateRequired) - { - // Clear flag, only when previous update was already handled (might be some new or remove devices/scenes to be displayed) - _status.system.ClearFullReloadFlag(); - } - if (_lastUpdateFailed) - { - _lastUpdateFailed = false; - setScreenUpdateRequired(); - _status.system.ClearConnectionError(); - } - // Process system status first - _status.system.update(rootnode); - if (_status.system.fullReload) - { - // We have a full refresh -> Clear all lists (to get clear of removed devices/scenes/catgories/rooms/etc...) - _status.ClearAllLists(); - } - - // Process Sections - XmlNodeList xnList = xmlDoc.SelectNodes("/root/sections/section"); - foreach (XmlNode xn in xnList) - { - Section sc = _status.GetSectionById( int.Parse(xn.Attributes["id"].Value) ); - if (sc.id != 0) { - sc.Update(xn); - } else { - _status.sections.Add(new Section(xn)); - } - } - - // Process Rooms - xnList = xmlDoc.SelectNodes("/root/rooms/room"); - foreach (XmlNode xn in xnList) - { - Room room = _status.GetRoomById( int.Parse(xn.Attributes["id"].Value) ); - if (room.id != 0) { - room.Update(xn); - } else { - _status.rooms.Add(new Room(xn)); - } - } - - // Process Scenes - xnList = xmlDoc.SelectNodes("/root/scenes/scene"); - // State update of Scenes are not reported done, so they have to be cleaned manualy - // if a message is still valid and/or new message will be reported below - foreach (Scene scene in _status.scenes) - { - scene.ClearCommState(); - } - foreach (XmlNode xn in xnList) - { - Scene sc = _status.GetSceneById( int.Parse(xn.Attributes["id"].Value) ); - if (sc.id != 0) { - sc.Update(xn); - } else { - _status.scenes.Add(new Scene(xn)); - } - } - - // Process Categories - xnList = xmlDoc.SelectNodes("/root/categories/categorie"); - foreach (XmlNode xn in xnList) - { - DevCategories cat = _status.GetCategoryById( int.Parse(xn.Attributes["id"].Value) ); - if (cat.id != 0) { - cat.Update(xn); - } else { - _status.categories.Add(new DevCategories(xn)); - } - } - - // Process Devices - xnList = xmlDoc.SelectNodes("/root/devices/device"); - foreach (XmlNode xn in xnList) - { - DeviceGeneric dev = _status.GetDeviceById( int.Parse(xn.Attributes["id"].Value) ); - if (dev.id != 0) { - // update existing device - dev.Update(xn); - } else { - _status.system.SetFullReloadFlag(); - - // catids: http://wiki.micasaverde.com/index.php/Luup_UPNP_Files - switch (xn.Attributes["category"].Value) - { - //case "1": // TODO: Implement interface device ? - // m_status.devices.Add(new DeviceInterface(xn)); - // break; - - case "2": - _status.devices.Add(new DeviceDimmer(xn)); - break; - - case "3": - case "11": // Generic IO - _status.devices.Add(new DeviceSwitch(xn)); - break; - - case "4": // Generic Sensor - case "12": // Motion Sensor - _status.devices.Add(new DeviceSecurity(xn)); - break; - - case "5": - _status.devices.Add(new DeviceThermostat(xn, _status.system.IsMetric())); - break; - - case "6": - _status.devices.Add(new DeviceCam(xn)); - break; - - case "7": - _status.devices.Add(new DeviceDoorlock(xn)); - break; - - case "8": - _status.devices.Add(new DeviceWindowCovering(xn)); - break; - - //case "9": - // m_status.devices.Add(new DeviceRemoteControl(xn)); - // break; - - //case "10": - // m_status.devices.Add(new DeviceIrTx(xn)); - // break; - - //case "13": - // m_status.devices.Add(new DeviceSerialPort(xn)); - // break - - case "14": - _status.devices.Add(new DeviceSceneController(xn)); - break; - - // case "15": - // m_status.devices.Add(new DeviceAV(xn)); - // break; - - case "16": - _status.devices.Add(new DeviceHumidity(xn)); - break; - - case "17": - _status.devices.Add(new DeviceTemperature(xn, _status.system.IsMetric())); - break; - - case "18": - _status.devices.Add(new DeviceLightSensor(xn)); - break; - - //case "19": - // m_status.devices.Add(new DeviceZwaveInt(xn)); - // break - //case "20": - // m_status.devices.Add(new DeviceInsteonInt(xn)); - // break - - case "21": - _status.devices.Add(new DevicePowerMeter(xn)); - break; - - case "0": - default: - // Check for Google Weather Device - if (xn.Attributes["WindCondition"] != null || xn.Attributes["windcondition"] != null) - { - _status.devices.Add(new DeviceGWeather(xn)); - break; - } - // Check for Bart's sprinkler Device - if (xn.Attributes["OperationMode"] != null) - { - _status.devices.Add(new DeviceSprinkler(xn)); - break; - } - /* Falltrough */ - _status.devices.Add(new DeviceGeneric(xn)); - break; - } - } - } - } - - public long SecondsSinceLastUpdate - { - get { return (_helper.GetSecondsSince1970() - _lastUpdate); } - set { } - } + private string RetrieveURL(string url) + { + // No callback thus Synchronised call (wait for response) + try { + WebClient wc = new WebClient(); + wc.CancelAsync(); // Cancel any current pending Async calls... + return wc.DownloadString(url); + } catch( Exception ) + { + return "ERROR"; + } + } + + public void DoVeraCommandRequest(string param, Action<string> errorReporter) + { + if (_webCommandClient.IsBusy) + { + // TODO: What to do ? cancel pending request or queue new request? - for now just cancel the previous request (user is informed about the progress) + } + string url = veraAddress + "/data_request" + param + "&time=" + DateTime.Now.Ticks; + + // Callback thus ASynchronised call (do NOT wait for response) + try { + _webCommandClientErrorReporter = errorReporter; + _webCommandClient.CancelAsync(); // Cancel any current pending Async calls... + _webCommandClient.DownloadStringAsync(new Uri(url)); + + } catch( Exception e ) + { + _webCommandClientErrorReporter = null; + status.system.ReportCommandError(e.Message); + setScreenUpdateRequired(); + } + } + + public void OnCompletedCommandRequest(object sender, DownloadStringCompletedEventArgs e) + { + if (e.Cancelled) + { + // Communication cancel for some reason, no valid data to be expected + if (_webCommandClientErrorReporter != null) + { + // Send error to dialog message handler + _webCommandClientErrorReporter("Request was canceled"); + } + else + { + // Show eror in MediaPortal Vera-main window + status.system.ReportCommandError("Request was canceled"); + } + setScreenUpdateRequired(); + } + else if (e.Error != null) + { + // Handle error here + if (_webCommandClientErrorReporter != null) + { + // Send error to dialog message handler + _webCommandClientErrorReporter(e.Error.Message); + } + else + { + // Show eror in MediaPortal Vera-main window + status.system.ReportCommandError(e.Error.Message); + } + setScreenUpdateRequired(); + } + else + { + // Communication succes full -> no parse Vera response... + if (!e.Result.ToUpper().Contains("<OK>OK</OK>") && !e.Result.ToUpper().Contains("<JOBID>")) + { + if (_webCommandClientErrorReporter != null) + { + // Send error to dialog message handler + _webCommandClientErrorReporter(e.Result); + } + else + { + // Show eror in MediaPortal Vera-main window + status.system.ReportCommandError(e.Result); + } + setScreenUpdateRequired(); + } + } + // Communication done clear error report handler + _webCommandClientErrorReporter = null; + } + + public void UpdateCurrentStatus() + { + /* Keep updating with webClient timeout 180 sec, even when last time did fail or connection was lost....*/ + if (!_webUpdateClient.IsBusy) + { + string url = veraAddress + "/data_request" + + "?id=lu_sdata&loadtime=" + _status.system.loadtime + + "&dataversion=" + _status.system.dataversion + + "&minimumdelay=" + _minRefreshDelay + + "&timeout=" + _maxRefreshDelay + + "&output_format=xml" + + "&time=" + DateTime.Now.Ticks; + + // Callback thus ASynchronised call (do NOT wait for response) + try { + _webUpdateClient.CancelAsync(); // Cancel any current pending Async calls... + _webUpdateClient.DownloadStringAsync(new Uri(url)); + } catch( Exception e ) + { + _lastUpdateFailed = true; + _lastUpdateErrorMessage = e.Message; + } + _lastUpdate = _helper.GetSecondsSince1970(); + } + } + + public void OnCompletedUpdateStatusRequest(object sender, DownloadStringCompletedEventArgs e) + { + if (!e.Cancelled) + { + // Communication cancel for some reason, no valid data to be expected + if (e.Error != null) + { + // Handle error here + _lastUpdateFailed = true; + _lastUpdateErrorMessage = e.Error.Message; + setScreenUpdateRequired(); + } + else + { + ParseUpdateInfo(e.Result); + // WebClient wc = new WebClient(); + // if (_status.system.dataversion == "0") + // { + //ParseUpdateInfo( wc.DownloadString(@"C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\testdata\text.xml")); + // } + } + } + + // update timer again (took some time to get the data) + _lastUpdate = _helper.GetSecondsSince1970(); + } + + public void ParseUpdateInfo(string veraresponse) + { + var xmlDoc = new XmlDocument(); + try { + xmlDoc.LoadXml(veraresponse); + } catch (Exception) + { + // Parser failed so incorrect data received (could be an interrupted data transfer) + return; + } + // Parse header + XmlNode rootnode = xmlDoc.SelectSingleNode("/root"); + if (rootnode == null) + { + // Not a status update, just return + return; + } + + if (!_screenUpdateRequired) + { + // Clear flag, only when previous update was already handled (might be some new or remove devices/scenes to be displayed) + _status.system.ClearFullReloadFlag(); + } + if (_lastUpdateFailed) + { + _lastUpdateFailed = false; + setScreenUpdateRequired(); + _status.system.ClearConnectionError(); + } + // Process system status first + _status.system.update(rootnode); + if (_status.system.fullReload) + { + // We have a full refresh -> Clear all lists (to get clear of removed devices/scenes/catgories/rooms/etc...) + _status.ClearAllLists(); + } + + // Process Sections + XmlNodeList xnList = xmlDoc.SelectNodes("/root/sections/section"); + foreach (XmlNode xn in xnList) + { + Section sc = _status.GetSectionById( int.Parse(xn.Attributes["id"].Value) ); + if (sc.id != 0) { + sc.Update(xn); + } else { + _status.sections.Add(new Section(xn)); + } + } + + // Process Rooms + xnList = xmlDoc.SelectNodes("/root/rooms/room"); + foreach (XmlNode xn in xnList) + { + Room room = _status.GetRoomById( int.Parse(xn.Attributes["id"].Value) ); + if (room.id != 0) { + room.Update(xn); + } else { + _status.rooms.Add(new Room(xn)); + } + } + + // Process Scenes + xnList = xmlDoc.SelectNodes("/root/scenes/scene"); + // State update of Scenes are not reported done, so they have to be cleaned manualy + // if a message is still valid and/or new message will be reported below + foreach (Scene scene in _status.scenes) + { + scene.ClearCommState(); + } + foreach (XmlNode xn in xnList) + { + Scene sc = _status.GetSceneById( int.Parse(xn.Attributes["id"].Value) ); + if (sc.id != 0) { + sc.Update(xn); + } else { + _status.scenes.Add(new Scene(xn)); + } + } + + // Process Categories + xnList = xmlDoc.SelectNodes("/root/categories/categorie"); + foreach (XmlNode xn in xnList) + { + DevCategories cat = _status.GetCategoryById( int.Parse(xn.Attributes["id"].Value) ); + if (cat.id != 0) { + cat.Update(xn); + } else { + _status.categories.Add(new DevCategories(xn)); + } + } + + // Process Devices + xnList = xmlDoc.SelectNodes("/root/devices/device"); + foreach (XmlNode xn in xnList) + { + DeviceGeneric dev = _status.GetDeviceById( int.Parse(xn.Attributes["id"].Value) ); + if (dev.id != 0) { + // update existing device + dev.Update(xn); + } else { + _status.system.SetFullReloadFlag(); + + // catids: http://wiki.micasaverde.com/index.php/Luup_UPNP_Files + switch (xn.Attributes["category"].Value) + { + //case "1": // TODO: Implement interface device ? + // m_status.devices.Add(new DeviceInterface(xn)); + // break; + + case "2": + _status.devices.Add(new DeviceDimmer(xn)); + break; + + case "3": + case "11": // Generic IO + _status.devices.Add(new DeviceSwitch(xn)); + break; + + case "4": // Generic Sensor + case "12": // Motion Sensor + _status.devices.Add(new DeviceSecurity(xn)); + break; + + case "5": + _status.devices.Add(new DeviceThermostat(xn, _status.system.IsMetric())); + break; + + case "6": + _status.devices.Add(new DeviceCam(xn)); + break; + + case "7": + _status.devices.Add(new DeviceDoorlock(xn)); + break; + + case "8": + _status.devices.Add(new DeviceWindowCovering(xn)); + break; + + //case "9": + // m_status.devices.Add(new DeviceRemoteControl(xn)); + // break; + + //case "10": + // m_status.devices.Add(new DeviceIrTx(xn)); + // break; + + //case "13": + // m_status.devices.Add(new DeviceSerialPort(xn)); + // break + + case "14": + _status.devices.Add(new DeviceSceneController(xn)); + break; + + // case "15": + // m_status.devices.Add(new DeviceAV(xn)); + // break; + + case "16": + _status.devices.Add(new DeviceHumidity(xn)); + break; + + case "17": + _status.devices.Add(new DeviceTemperature(xn, _status.system.IsMetric())); + break; + + case "18": + _status.devices.Add(new DeviceLightSensor(xn)); + break; + + //case "19": + // m_status.devices.Add(new DeviceZwaveInt(xn)); + // break + //case "20": + // m_status.devices.Add(new DeviceInsteonInt(xn)); + // break + + case "21": + _status.devices.Add(new DevicePowerMeter(xn)); + break; + + case "0": + default: + // Check for Google Weather Device + if (xn.Attributes["WindCondition"] != null || xn.Attributes["windcondition"] != null) + { + _status.devices.Add(new DeviceGWeather(xn)); + break; + } + // Check for Bart's sprinkler Device + if (xn.Attributes["OperationMode"] != null) + { + _status.devices.Add(new DeviceSprinkler(xn)); + break; + } + /* Falltrough */ + _status.devices.Add(new DeviceGeneric(xn)); + break; + } + } + } + } + + public long SecondsSinceLastUpdate + { + get { return (_helper.GetSecondsSince1970() - _lastUpdate); } + set { } + } - public List<Scene> scenes - { - get { return _status.scenes; } - set { } - } - - public List<DeviceGeneric> devices - { - get { return _status.devices; } - set { } - } + public List<Scene> scenes + { + get { return _status.scenes; } + set { } + } + + public List<DeviceGeneric> devices + { + get { return _status.devices; } + set { } + } - public List<Room> rooms - { - get { return _status.rooms; } - set { } - } + public List<Room> rooms + { + get { return _status.rooms; } + set { } + } - public List<DevCategories> categories - { - get { return _status.categories; } - set { } - } - - public List<Section> sections - { - get { return _status.sections; } - set { } - } - - public bool lastUpdateFailed - { - get { return _lastUpdateFailed; } - set { _lastUpdateFailed = value; } - } - - public string lastUpdateError - { - get { return _lastUpdateErrorMessage; } - set { } - } - - /// <summary> - /// Invoking this method will clear the update ready flag -> so caller need to handle the screen update - /// </summary> - /// <returns>When true a screen update shall be preformed by the caller</returns> - public bool NewScreenUpdateWaitingAndClearFlag() - { - bool b = _screenUpdateRequired; - _screenUpdateRequired = false; - return b; - } - - public void setScreenUpdateRequired() - { - _screenUpdateRequired = true; - } - /// <summary> - /// A request is currently being handled by Vera, this request takes at least _minRefreshDelay msecs, at most _maxRefreshDelay seconds and will be finished the moment Vera detects a change. - /// As soon as this function returns false a new update request should be invoked (with UpdateCurrentStatus()), Vera will take care of the Refresh delays (by keeping open the http-connection) - /// </summary> - public bool updatePending - { - get { return _webUpdateClient.IsBusy; } - set { } - } - - public VeraStatus status - { - get { return _status; } - set { } - } - - public string veraAddress - { - // TODO: handle FWD server address here, when configured so - get { return _veraIPAddress + ":" +_veraTCPIPPort; } - set { } - } - } + public List<DevCategories> categories + { + get { return _status.categories; } + set { } + } + + public List<Section> sections + { + get { return _status.sections; } + set { } + } + + public bool lastUpdateFailed + { + get { return _lastUpdateFailed; } + set { _lastUpdateFailed = value; } + } + + public string lastUpdateError + { + get { return _lastUpdateErrorMessage; } + set { } + } + + /// <summary> + /// Invoking this method will clear the update ready flag -> so caller need to handle the screen update + /// </summary> + /// <returns>When true a screen update shall be preformed by the caller</returns> + public bool NewScreenUpdateWaitingAndClearFlag() + { + bool b = _screenUpdateRequired; + _screenUpdateRequired = false; + return b; + } + + public void setScreenUpdateRequired() + { + _screenUpdateRequired = true; + } + /// <summary> + /// A request is currently being handled by Vera, this request takes at least _minRefreshDelay msecs, at most _maxRefreshDelay seconds and will be finished the moment Vera detects a change. + /// As soon as this function returns false a new update request should be invoked (with UpdateCurrentStatus()), Vera will take care of the Refresh delays (by keeping open the http-connection) + /// </summary> + public bool updatePending + { + get { return _webUpdateClient.IsBusy; } + set { } + } + + public VeraStatus status + { + get { return _status; } + set { } + } + + public string discreteVeraAddress + { + get { + if (_discreteVeraAddress == null) + { // Accessing this variable will set the discrete value aswell + string dum = veraAddress; + } + return _discreteVeraAddress; + } + } + private string _discreteVeraAddress = null; + + public string veraAddress + { + get { + if (_realVeraAddress == null) + { + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) + { + if (xmlreader.GetValueAsBool("veracontroller", "remoteConnected", false)) + { + string user = xmlreader.GetValueAsString("veracontroller", "miosusername", ""); + string pass = xmlreader.GetValueAsString("veracontroller", "miospassword", ... [truncated message content] |
From: <Ba...@us...> - 2012-01-28 20:18:52
|
Revision: 4428 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4428&view=rev Author: BartEv Date: 2012-01-28 20:18:43 +0000 (Sat, 28 Jan 2012) Log Message: ----------- Added RC command controls and help screen Got clear of all the TAB's Modified Paths: -------------- trunk/plugins/VeraControl/BaseDevice.cs trunk/plugins/VeraControl/DevCategories.cs trunk/plugins/VeraControl/DeviceCam.cs trunk/plugins/VeraControl/DeviceDimmer.cs trunk/plugins/VeraControl/DeviceDoorlock.cs trunk/plugins/VeraControl/DeviceGWeather.cs trunk/plugins/VeraControl/DeviceGeneric.cs trunk/plugins/VeraControl/DeviceHumidity.cs trunk/plugins/VeraControl/DeviceLightSensor.cs trunk/plugins/VeraControl/DevicePowerMeter.cs trunk/plugins/VeraControl/DeviceSceneController.cs trunk/plugins/VeraControl/DeviceSecurity.cs trunk/plugins/VeraControl/DeviceSprinkler.cs trunk/plugins/VeraControl/DeviceSwitch.cs trunk/plugins/VeraControl/DeviceSystem.cs trunk/plugins/VeraControl/DeviceTemperature.cs trunk/plugins/VeraControl/DeviceThermostat.cs trunk/plugins/VeraControl/DeviceWindowCovering.cs trunk/plugins/VeraControl/DialogActionTrigger.cs trunk/plugins/VeraControl/DialogDeviceControl.cs trunk/plugins/VeraControl/DialogSceneControl.cs trunk/plugins/VeraControl/JSON.cs trunk/plugins/VeraControl/Room.cs trunk/plugins/VeraControl/Scene.cs trunk/plugins/VeraControl/Section.cs trunk/plugins/VeraControl/VeraCommunication.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/VeraHelper.cs Modified: trunk/plugins/VeraControl/BaseDevice.cs =================================================================== --- trunk/plugins/VeraControl/BaseDevice.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/BaseDevice.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -18,19 +18,19 @@ /// </summary> public class BaseDevice { - private long _lastUpdate = 0; - private long _lastPendingUpdate = 0; + private long _lastUpdate = 0; + private long _lastPendingUpdate = 0; private bool _screenUpdateRequired = false; - private string _name = "unknown device"; - private int _id = 0; - private int _room = 0; + private string _name = "unknown device"; + private int _id = 0; + private int _room = 0; // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) private DevState _dsState = DevState.NONE; - private string _comment = ""; // red(error), green(success) or blue(pending) - icon/text + private string _comment = ""; // red(error), green(success) or blue(pending) - icon/text - public VeraHelper _helper = VeraHelper.Instance; - public VeraCommunication _vera = VeraCommunication.Instance; + public VeraHelper _helper = VeraHelper.Instance; + public VeraCommunication _vera = VeraCommunication.Instance; public BaseDevice(XmlNode xn) { @@ -40,7 +40,7 @@ } } - /// <summary> + /// <summary> /// Process Vera update information /// </summary> public virtual bool Update(XmlNode xn) @@ -58,8 +58,8 @@ } // Set update flag - screenUpdateRequired = true; - lastUpdate = DateTime.Now.Ticks; + screenUpdateRequired = true; + lastUpdate = DateTime.Now.Ticks; return true; } @@ -75,14 +75,14 @@ public int id { - get { return _id; } - set { } + get { return _id; } + set { } } public string name { - get { return _name; } - set { } + get { return _name; } + set { } } public bool InRoom(int id) @@ -93,19 +93,19 @@ public int room { get { return _room; } - set { _room = value; } + set { _room = value; } } public DevState commstate { get { return _dsState; } - set { } + set { } } public string comment { get { return (commstate != DevState.NONE ? _comment : ""); } - set { } + set { } } public bool screenUpdateRequired @@ -128,11 +128,11 @@ public void ReportPendingRequest() { - _dsState = DevState.PENDING; - _comment = "Sending command..."; + _dsState = DevState.PENDING; + _comment = "Sending command..."; screenUpdateRequired = true; lastUpdate = DateTime.Now.Ticks; - _lastPendingUpdate = lastUpdate; + _lastPendingUpdate = lastUpdate; } /// <summary> @@ -140,19 +140,19 @@ /// </summary> public void ReportRequestError(string message) { - _dsState = DevState.COMMAND_ERROR; - _comment = message; + _dsState = DevState.COMMAND_ERROR; + _comment = message; screenUpdateRequired = true; - lastUpdate = DateTime.Now.Ticks; + lastUpdate = DateTime.Now.Ticks; } public void ClearCommState() { if (_dsState != DevState.NONE) { - _dsState = DevState.NONE; - screenUpdateRequired = true; - lastUpdate = DateTime.Now.Ticks; + _dsState = DevState.NONE; + screenUpdateRequired = true; + lastUpdate = DateTime.Now.Ticks; } } Modified: trunk/plugins/VeraControl/DevCategories.cs =================================================================== --- trunk/plugins/VeraControl/DevCategories.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DevCategories.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -13,45 +13,45 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DevCategories. - /// </summary> - public class DevCategories - { - public DevCategories(XmlNode xn) - { - if (xn != null) - { - Update(xn); - } - } - - private string _name = "unknown category"; - private int _id = 0; - public VeraHelper _helper = VeraHelper.Instance; - - public bool Update(XmlNode xn) - { - _name = _helper.GetAttrAsString(xn, "name", _name); - _id = _helper.GetAttrAsInt (xn, "id", _id); - return true; - } - - public int id - { - get { return _id; } - set { } - } - - public string name - { - get { return _name; } - set { } - } + /// <summary> + /// Description of DevCategories. + /// </summary> + public class DevCategories + { + public DevCategories(XmlNode xn) + { + if (xn != null) + { + Update(xn); + } + } + + private string _name = "unknown category"; + private int _id = 0; + public VeraHelper _helper = VeraHelper.Instance; + + public bool Update(XmlNode xn) + { + _name = _helper.GetAttrAsString(xn, "name", _name); + _id = _helper.GetAttrAsInt (xn, "id", _id); + return true; + } + + public int id + { + get { return _id; } + set { } + } + + public string name + { + get { return _name; } + set { } + } - public override string ToString() - { - return name; - } - } + public override string ToString() + { + return name; + } + } } Modified: trunk/plugins/VeraControl/DeviceCam.cs =================================================================== --- trunk/plugins/VeraControl/DeviceCam.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DeviceCam.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -11,139 +11,145 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DeviceCam. - /// </summary> - public class DeviceCam : DeviceGeneric - { - private string _ip = "127.0.0.1"; - private string _url = "/"; - private string _stream = ""; - private string _videoUrl = ""; - private int _refreshRate = 2; - private string _user = ""; - private string _pass = ""; - - public DeviceCam(XmlNode xn): base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - public override bool Update(XmlNode xn) - { - _ip = _helper.GetAttrAsString(xn, "ip", _ip); - _url = _helper.GetAttrAsString(xn, "url", _url); - _stream = _helper.GetAttrAsString(xn, "streaming", _stream); - _videoUrl = _helper.GetAttrAsString(xn, "videourls", _videoUrl); - _user = _helper.GetAttrAsString(xn, "username", ""); - _pass = _helper.GetAttrAsString(xn, "password", ""); - - return base.Update(xn); - } - - private string passString - { - get { - if (_user == "") - { - return ""; - } - return _user + ":" + _pass + "@"; - } - set { } - } - - public string imgUrl - { - get { return _vera.veraAddress + "/data_request?id=cam_image¶meters=get_video_frame&Device_Num=" + id + "&rand=" + DateTime.Now.Ticks; - // return "http://" + passString + m_sIp + "/" + m_sUrl.Replace("%2F", "/"); - } - set { } - } - - public string streamUrl - { - get { return "http://" + passString + _ip + "/" + _stream.Replace("%2F", "/"); } - set { } - } - - public int refreshRate - { - get { return _refreshRate; } - set { _refreshRate = value; } - } - - private bool HasRefreshDelayPassed(long lastcheck) - { - return ((_helper.GetSecondsSince1970() - refreshRate) > (lastcheck / TimeSpan.TicksPerSecond)); - } - - public override string GetIconName() - { - return "Ip_Camera"; - } - - public override bool NewScreenUpdateWaitingAndClearFlag( ) - { - // Invoking this method will clear the update ready flag -> so caller need to handle the update - // A cam device requires an update every refreshRate seconds - bool b = screenUpdateRequired || HasRefreshDelayPassed(DateTime.Now.Ticks); - screenUpdateRequired = false; - if (b) - { - lastUpdate = DateTime.Now.Ticks; - } - return b; - } - - public override bool NewUpdateSince(long lTimePreviousCheck) - { - bool b = (lTimePreviousCheck <= lastUpdate) || HasRefreshDelayPassed(lastUpdate); - if (b) - { - lastUpdate = DateTime.Now.Ticks; - } - return b; - } - - private void Move(string direction) - { - if (id == 0) - { - _vera.status.system.ReportCommandError("Unknown device"); - screenUpdateRequired = true; - return; - } - string cmd = "?id=lu_action&DeviceNum=" + id + "&serviceId=urn:micasaverde-com:serviceId:PanTiltZoom1&action=" + direction; - _vera.DoVeraCommandRequest(cmd, ReportRequestError); - } - - public override void MoveUp() - { - Move("MoveUp"); - } - public override void MoveLeft() - { - Move("MoveLeft"); - } - public override void MoveRight() - { - Move("MoveRight"); - } - public override void MoveDown() - { - Move("MoveDown"); - } - public override void ZoomIn() - { - Move("ZoomIn"); - } - public override void ZoomOut() - { - Move("ZoomOut"); - } - } + /// <summary> + /// Description of DeviceCam. + /// </summary> + public class DeviceCam : DeviceGeneric + { + private string _ip = "127.0.0.1"; + private string _url = "/"; + private string _stream = ""; + private string _videoUrl = ""; + private int _refreshRate = 2; + private string _user = ""; + private string _pass = ""; + + public DeviceCam(XmlNode xn): base (xn) + { + if (xn != null) + { + Update(xn); + } + } + + public override bool Update(XmlNode xn) + { + _ip = _helper.GetAttrAsString(xn, "ip", _ip); + _url = _helper.GetAttrAsString(xn, "url", _url); + _stream = _helper.GetAttrAsString(xn, "streaming", _stream); + _videoUrl = _helper.GetAttrAsString(xn, "videourls", _videoUrl); + _user = _helper.GetAttrAsString(xn, "username", ""); + _pass = _helper.GetAttrAsString(xn, "password", ""); + + return base.Update(xn); + } + + private string passString + { + get { + if (_user == "") + { + return ""; + } + return _user + ":" + _pass + "@"; + } + set { } + } + + public string imgUrl + { + get { return _vera.veraAddress + "/data_request?id=cam_image¶meters=get_video_frame&Device_Num=" + id + "&rand=" + DateTime.Now.Ticks; + // return "http://" + passString + m_sIp + "/" + m_sUrl.Replace("%2F", "/"); + } + set { } + } + + public string streamUrl + { + get { return "http://" + passString + _ip + "/" + _stream.Replace("%2F", "/"); } + set { } + } + + public int refreshRate + { + get { return _refreshRate; } + set { _refreshRate = value; } + } + + private bool HasRefreshDelayPassed(long lastcheck) + { + return ((_helper.GetSecondsSince1970() - refreshRate) > (lastcheck / TimeSpan.TicksPerSecond)); + } + + public override bool isControllable + { + get { return true; } + set { } + } + + public override string GetIconName() + { + return "Ip_Camera"; + } + + public override bool NewScreenUpdateWaitingAndClearFlag( ) + { + // Invoking this method will clear the update ready flag -> so caller need to handle the update + // A cam device requires an update every refreshRate seconds + bool b = screenUpdateRequired || HasRefreshDelayPassed(DateTime.Now.Ticks); + screenUpdateRequired = false; + if (b) + { + lastUpdate = DateTime.Now.Ticks; + } + return b; + } + + public override bool NewUpdateSince(long lTimePreviousCheck) + { + bool b = (lTimePreviousCheck <= lastUpdate) || HasRefreshDelayPassed(lastUpdate); + if (b) + { + lastUpdate = DateTime.Now.Ticks; + } + return b; + } + + private void Move(string direction) + { + if (id == 0) + { + _vera.status.system.ReportCommandError("Unknown device"); + screenUpdateRequired = true; + return; + } + string cmd = "?id=lu_action&DeviceNum=" + id + "&serviceId=urn:micasaverde-com:serviceId:PanTiltZoom1&action=" + direction; + _vera.DoVeraCommandRequest(cmd, ReportRequestError); + } + + public override void MoveUp() + { + Move("MoveUp"); + } + public override void MoveLeft() + { + Move("MoveLeft"); + } + public override void MoveRight() + { + Move("MoveRight"); + } + public override void MoveDown() + { + Move("MoveDown"); + } + public override void ZoomIn() + { + Move("ZoomIn"); + } + public override void ZoomOut() + { + Move("ZoomOut"); + } + } } Modified: trunk/plugins/VeraControl/DeviceDimmer.cs =================================================================== --- trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DeviceDimmer.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -13,107 +13,104 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DeviceDimmer. - /// </summary> - public class DeviceDimmer : DeviceGeneric - { - private int _level = 0; - private string _watt = "-"; - private string _kwh = "-"; - - public DeviceDimmer(XmlNode xn): base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - public override bool Update(XmlNode xn) - { - _level = _helper.GetAttrAsInt (xn, "level", _level); - _watt = _helper.GetAttrAsString(xn, "watts", _watt); - _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh); - - return base.Update(xn); - } - - public string watts - { - get { return _watt; } - set { } - } - - public override bool status - { - get { return (_level > 0); } - set { - - } - } - - public override int level - { - get { return _level; } - set - { - int newValue = value; - if (newValue > 100) { - newValue = 100; - } else { - if (newValue < 0) { newValue = 0; } - } - if (id > 0) // Only send when a valid ID is found - { - ReportPendingRequest(); - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString() + - "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget" + - "&newLoadlevelTarget=" + value; - _vera.DoVeraCommandRequest(cmd, ReportRequestError); - } - _level = newValue; - } - } - - public override int maxLevel - { - get { return 100; } - set { } - } - - public override string ToString() - { - return name + " [" + GetStatusText() + "]"; - } - - public override bool isControllable - { - get { return true; } - set { } - } - - public override string GetIconName() - { - string leveltxt = "0"; - if (level > 0) { leveltxt = "25"; } - if (level > 25) { leveltxt = "50"; } - if (level > 50) { leveltxt = "75"; } - if (level > 75) { leveltxt = "100"; } - - return "Dimmable_Light_" + leveltxt; - } - - - public override string GetExtraText() - { - return (_kwh != "" ? _kwh + "kWh" : ""); - } - - public override string GetStatusText() - { - return (status ? level.ToString() + "%" : "Off"); - } - } + /// <summary> + /// Description of DeviceDimmer. + /// </summary> + public class DeviceDimmer : DeviceGeneric + { + private int _level = 0; + private string _watt = "-"; + private string _kwh = "-"; + + public DeviceDimmer(XmlNode xn): base (xn) + { + if (xn != null) + { + Update(xn); + } + } + + public override bool Update(XmlNode xn) + { + _level = _helper.GetAttrAsInt (xn, "level", _level); + _watt = _helper.GetAttrAsString(xn, "watts", _watt); + _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh); + + return base.Update(xn); + } + + public string watts + { + get { return _watt; } + set { } + } + + public override bool status + { + get { return (_level > 0); } + set { level = (value ? maxLevel : minLevel); } + } + + public override int level + { + get { return _level; } + set + { + int newValue = value; + if (newValue > maxLevel) { + newValue = maxLevel; + } else { + if (newValue < minLevel) { newValue = minLevel; } + } + if (id > 0) // Only send when a valid ID is found + { + ReportPendingRequest(); + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString() + + "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget" + + "&newLoadlevelTarget=" + value; + _vera.DoVeraCommandRequest(cmd, ReportRequestError); + } + _level = newValue; + } + } + + public override int maxLevel + { + get { return 100; } + set { } + } + + public override string ToString() + { + return name + " [" + GetStatusText() + "]"; + } + + public override bool isControllable + { + get { return true; } + set { } + } + + public override string GetIconName() + { + string leveltxt = "0"; + if (level > 0) { leveltxt = "25"; } + if (level > 25) { leveltxt = "50"; } + if (level > 50) { leveltxt = "75"; } + if (level > 75) { leveltxt = "100"; } + + return "Dimmable_Light_" + leveltxt; + } + + public override string GetExtraText() + { + return (_kwh != "" ? _kwh + "kWh" : ""); + } + + public override string GetStatusText() + { + return (status ? level.ToString() + "%" : "Off"); + } + } } Modified: trunk/plugins/VeraControl/DeviceDoorlock.cs =================================================================== --- trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -13,79 +13,78 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DeviceDoorlock. - /// </summary> - public class DeviceDoorlock : DeviceGeneric - { - private bool _status = false; - - public DeviceDoorlock( XmlNode xn ): base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - public override bool Update(XmlNode xn) - { - _status = _helper.GetAttrAsBool(xn, "status", _status); - - return base.Update(xn); - } - - public override bool status - { - get { return _status; } - set { - if (id > 0) // Only send when a valid ID is found - { - ReportPendingRequest(); - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget" + - "&newTargetValue="+(value ? "1" : "0"); - _vera.DoVeraCommandRequest(cmd, ReportRequestError); - } - } - } - - public override int level - { - get { return (_status ? 1 : 0); } - set - { - status = (value > 0); - } - } - - public override int maxLevel - { - get { return 1; } - set { } - } - - public override string ToString() - { - return name + " [" + GetStatusText() + "]"; - } - - public override bool isControllable - { - get { return true; } - set { } - } - - public override string GetIconName() - { - return "Door_" + (_status ? "LOCKED" : "UNLOCKED"); - } - - public override string GetStatusText() - { - return (status ? "Locked" : "Unlocked"); - } - - } + /// <summary> + /// Description of DeviceDoorlock. + /// </summary> + public class DeviceDoorlock : DeviceGeneric + { + private bool _status = false; + + public DeviceDoorlock( XmlNode xn ): base (xn) + { + if (xn != null) + { + Update(xn); + } + } + + public override bool Update(XmlNode xn) + { + _status = _helper.GetAttrAsBool(xn, "status", _status); + + return base.Update(xn); + } + + public override bool status + { + get { return _status; } + set { + if (id > 0) // Only send when a valid ID is found + { + ReportPendingRequest(); + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget" + + "&newTargetValue="+(value ? "1" : "0"); + _vera.DoVeraCommandRequest(cmd, ReportRequestError); + } + } + } + + public override int level + { + get { return (_status ? 1 : 0); } + set + { + status = (value > 0); + } + } + + public override int maxLevel + { + get { return 1; } + set { } + } + + public override string ToString() + { + return name + " [" + GetStatusText() + "]"; + } + + public override bool isControllable + { + get { return true; } + set { } + } + + public override string GetIconName() + { + return "Door_" + (_status ? "LOCKED" : "UNLOCKED"); + } + + public override string GetStatusText() + { + return (status ? "Locked" : "Unlocked"); + } + } } Modified: trunk/plugins/VeraControl/DeviceGWeather.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGWeather.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DeviceGWeather.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -13,49 +13,50 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DeviceGWeather. - /// </summary> - public class DeviceGWeather : DeviceGeneric - { - private string _condition = "-"; - private string _windCondition = "-"; - - public DeviceGWeather(XmlNode xn): base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - public override bool Update(XmlNode xn) - { - _condition = _helper.GetAttrAsString(xn, "Condition", _condition); // Google Weather Plugin - _condition = _helper.GetAttrAsString(xn, "condition", _condition); // World Weather plugin - _windCondition = _helper.GetAttrAsString(xn, "WindCondition", _windCondition); - _windCondition = _helper.GetAttrAsString(xn, "windcondition", _windCondition); - - return base.Update(xn); - } - - public override string ToString() - { - return name + " [" + GetStatusText() + "]"; - } - - public override string GetStatusText() - { - return _condition.Replace("_", " "); - } - public override string GetExtraText() - { - return _windCondition; - } - - public override string GetIconName() - { - return "location"; - } - } + /// <summary> + /// Description of DeviceGWeather. + /// </summary> + public class DeviceGWeather : DeviceGeneric + { + private string _condition = "-"; + private string _windCondition = "-"; + + public DeviceGWeather(XmlNode xn): base (xn) + { + if (xn != null) + { + Update(xn); + } + } + + public override bool Update(XmlNode xn) + { + _condition = _helper.GetAttrAsString(xn, "Condition", _condition); // Google Weather Plugin + _condition = _helper.GetAttrAsString(xn, "condition", _condition); // World Weather plugin + _windCondition = _helper.GetAttrAsString(xn, "WindCondition", _windCondition); + _windCondition = _helper.GetAttrAsString(xn, "windcondition", _windCondition); + + return base.Update(xn); + } + + public override string ToString() + { + return name + " [" + GetStatusText() + "]"; + } + + public override string GetStatusText() + { + return _condition.Replace("_", " "); + } + + public override string GetExtraText() + { + return _windCondition; + } + + public override string GetIconName() + { + return "location"; + } + } } Modified: trunk/plugins/VeraControl/DeviceGeneric.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DeviceGeneric.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -14,132 +14,157 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DeviceGeneric. - /// </summary> - public class DeviceGeneric : BaseDevice - { - private string _altId = ""; - private int _category = 0; - - public DeviceGeneric(XmlNode xn): base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - public override bool Update(XmlNode xn) - { - _altId = _helper.GetAttrAsString(xn, "altid", _altId); - _category = _helper.GetAttrAsInt (xn, "category", _category); - - bool b = base.Update(xn); - // Make sure the room exists - if (room == 0 || !_vera.status.IsRoomFound(room)) - { - if (!_vera.status.IsRoomFound(0)) - { // create dummy room to attach to - _vera.rooms.Add(new Room(null)); - } - room = 0; - } + /// <summary> + /// Description of DeviceGeneric. + /// </summary> + public class DeviceGeneric : BaseDevice + { + private string _altId = ""; + private int _category = 0; + private int _stepsize = 0; + + public DeviceGeneric(XmlNode xn): base (xn) + { + if (xn != null) + { + Update(xn); + if (maxLevel > 0 && minLevel >= 0) + { + _stepsize = (int)Math.Max(1, Math.Round((decimal)((maxLevel - minLevel) / 10))); + } + } + } + + public override bool Update(XmlNode xn) + { + _altId = _helper.GetAttrAsString(xn, "altid", _altId); + _category = _helper.GetAttrAsInt (xn, "category", _category); + + bool b = base.Update(xn); + // Make sure the room exists + if (room == 0 || !_vera.status.IsRoomFound(room)) + { + if (!_vera.status.IsRoomFound(0)) + { // create dummy room to attach to + _vera.rooms.Add(new Room(null)); + } + room = 0; + } + return b; + } + + public string altid + { + get { return _altId; } + } + + public int category + { + get { return _category; } + } + + public virtual bool isControllable + { + get { return false; } + set { } + } + + public virtual bool status + { + get { return false; } + set { } + } + + public virtual int level + { + get { return 0; } + set { } + } - return b; - } - - public string altid - { - get { return _altId; } - set { } - } - - public int category - { - get { return _category; } - set { } - } - - public virtual bool isControllable - { - get { return false; } - set { } - } - - public virtual bool status - { - get { return false; } - set { } - } - - public virtual int level - { - get { return 0; } - set { } - } - - public virtual string mode - { - get { return ""; } - set { } - } - - public virtual int maxLevel - { - get { return -1; } - set { } - } - public virtual int minLevel - { - get { return 0; } - set { } - } - - public override string GetIconName() - { - return "generic_sensor"; - } - - public override string GetStatusText() - { - return ""; - } - - public virtual string GetExtraText() - { - return ""; - } + public virtual int stepSize + { + get { return _stepsize; } + set { _stepsize = value; } + } - public virtual string [] GetCommands() - { - return new string [] {"Off", "On"}; - } - - // Overridables for Cam Device - public virtual void MoveUp() - { - // do nothing - } - public virtual void MoveLeft() - { - // do nothing - } - public virtual void MoveRight() - { - // do nothing - } - public virtual void MoveDown() - { - // do nothing - } - public virtual void ZoomIn() - { - // do nothing - } - public virtual void ZoomOut() - { - // do nothing - } - } + public virtual void IncreaseLevel() + { + if (stepSize > 0) + { + level += stepSize; + } + } + + public virtual void DecreaseLevel() + { + if (stepSize > 0) + { + level -= stepSize; + } + } + + public virtual string mode + { + get { return ""; } + set { } + } + + public virtual int maxLevel + { + get { return -1; } + set { } + } + + public virtual int minLevel + { + get { return 0; } + set { } + } + + public override string GetIconName() + { + return "generic_sensor"; + } + + public override string GetStatusText() + { + return ""; + } + + public virtual string GetExtraText() + { + return ""; + } + + public virtual string [] GetCommands() + { + return new string [] {"Off", "On"}; + } + + // Overridables for Cam Device + public virtual void MoveUp() + { + // do nothing + } + public virtual void MoveLeft() + { + // do nothing + } + public virtual void MoveRight() + { + // do nothing + } + public virtual void MoveDown() + { + // do nothing + } + public virtual void ZoomIn() + { + // do nothing + } + public virtual void ZoomOut() + { + // do nothing + } + } } Modified: trunk/plugins/VeraControl/DeviceHumidity.cs =================================================================== --- trunk/plugins/VeraControl/DeviceHumidity.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DeviceHumidity.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -13,52 +13,52 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DeviceHumidity. - /// </summary> - public class DeviceHumidity : DeviceGeneric - { - private int _level = 0; - - public DeviceHumidity(XmlNode xn): base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - public override bool Update(XmlNode xn) - { - _level = _helper.GetAttrAsInt(xn, "humidity", _level); - return base.Update(xn); - } - - public override int level - { - get { return _level; } - set {} - } - - public override int maxLevel - { - get { return 100; } - set { } - } - - public override string ToString() - { - return name + " [" + level.ToString() + "%]"; - } - - public override string GetIconName() - { - return "Humidity_Sensor"; - } - - public override string GetStatusText() - { - return level + "%"; - } - } + /// <summary> + /// Description of DeviceHumidity. + /// </summary> + public class DeviceHumidity : DeviceGeneric + { + private int _level = 0; + + public DeviceHumidity(XmlNode xn) : base (xn) + { + if (xn != null) + { + Update(xn); + } + } + + public override bool Update(XmlNode xn) + { + _level = _helper.GetAttrAsInt(xn, "humidity", _level); + return base.Update(xn); + } + + public override int level + { + get { return _level; } + set {} + } + + public override int maxLevel + { + get { return 100; } + set { } + } + + public override string ToString() + { + return name + " [" + level.ToString() + "%]"; + } + + public override string GetIconName() + { + return "Humidity_Sensor"; + } + + public override string GetStatusText() + { + return level + "%"; + } + } } Modified: trunk/plugins/VeraControl/DeviceLightSensor.cs =================================================================== --- trunk/plugins/VeraControl/DeviceLightSensor.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DeviceLightSensor.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -13,59 +13,59 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DeviceLightSensor. - /// </summary> - public class DeviceLightSensor : DeviceGeneric - { - private int _level = 0; - - public DeviceLightSensor(XmlNode xn): base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - public override bool Update(XmlNode xn) - { - _level = _helper.GetAttrAsInt(xn, "level", _level); - _level = _helper.GetAttrAsInt(xn, "light", _level); - return base.Update(xn); - } - - public override bool status - { - get { return (_level > 0); } - set { } - } - - public override int level - { - get { return _level; } - set { } - } - - public override int maxLevel - { - get { return 100; } - set { } - } + /// <summary> + /// Description of DeviceLightSensor. + /// </summary> + public class DeviceLightSensor : DeviceGeneric + { + private int _level = 0; + + public DeviceLightSensor(XmlNode xn) : base (xn) + { + if (xn != null) + { + Update(xn); + } + } + + public override bool Update(XmlNode xn) + { + _level = _helper.GetAttrAsInt(xn, "level", _level); + _level = _helper.GetAttrAsInt(xn, "light", _level); + return base.Update(xn); + } + + public override bool status + { + get { return (_level > 0); } + set { } + } + + public override int level + { + get { return _level; } + set { } + } + + public override int maxLevel + { + get { return 100; } + set { } + } - public override string ToString() - { - return name + " [" + GetStatusText() + "]"; - } - - public override string GetIconName() - { - return "Light_Sensor"; - } - - public override string GetStatusText() - { - return level.ToString() + "%"; - } - } + public override string ToString() + { + return name + " [" + GetStatusText() + "]"; + } + + public override string GetIconName() + { + return "Light_Sensor"; + } + + public override string GetStatusText() + { + return level.ToString() + "%"; + } + } } Modified: trunk/plugins/VeraControl/DevicePowerMeter.cs =================================================================== --- trunk/plugins/VeraControl/DevicePowerMeter.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DevicePowerMeter.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -13,71 +13,71 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DevicePowerMeter. - /// </summary> - public class DevicePowerMeter : DeviceGeneric - { - private int _level = 0; - private string _kwh = ""; - - public DevicePowerMeter(XmlNode xn): base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - public override bool Update(XmlNode xn) - { - _level = _helper.GetAttrAsInt (xn, "watts", _level); - _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh); - return base.Update(xn); - } - - public string watts - { - get { return _level.ToString(); } - set { } - } - - public override bool status - { - get { return (_level > 0); } - set { } - } - - public override int level - { - get { return _level; } - set { } - } - - public override int maxLevel - { - get { return 1000; } - set { } - } - - public override string ToString() - { - return name + " [" + GetStatusText() + "]"; - } - - public override string GetIconName() - { - return "Power_Meter"; - } - - public override string GetExtraText() - { - return (_kwh != "" ? _kwh + "kWh" : ""); - } - - public override string GetStatusText() - { - return level.ToString() + "W"; - } - } + /// <summary> + /// Description of DevicePowerMeter. + /// </summary> + public class DevicePowerMeter : DeviceGeneric + { + private int _level = 0; + private string _kwh = ""; + + public DevicePowerMeter(XmlNode xn) : base (xn) + { + if (xn != null) + { + Update(xn); + } + } + + public override bool Update(XmlNode xn) + { + _level = _helper.GetAttrAsInt (xn, "watts", _level); + _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh); + return base.Update(xn); + } + + public string watts + { + get { return _level.ToString(); } + set { } + } + + public override bool status + { + get { return (_level > 0); } + set { } + } + + public override int level + { + get { return _level; } + set { } + } + + public override int maxLevel + { + get { return 1000; } + set { } + } + + public override string ToString() + { + return name + " [" + GetStatusText() + "]"; + } + + public override string GetIconName() + { + return "Power_Meter"; + } + + public override string GetExtraText() + { + return (_kwh != "" ? _kwh + "kWh" : ""); + } + + public override string GetStatusText() + { + return level.ToString() + "W"; + } + } } Modified: trunk/plugins/VeraControl/DeviceSceneController.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSceneController.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DeviceSceneController.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -11,60 +11,60 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DeviceSceneController. - /// </summary> - public class DeviceSceneController: DeviceGeneric - { - private bool _isTripped = false; - - public DeviceSceneController( XmlNode xn ): base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - public override bool Update(XmlNode xn) - { - _isTripped = _helper.GetAttrAsBool(xn, "status", _isTripped); - _isTripped = _helper.GetAttrAsBool(xn, "tripped", _isTripped); - return base.Update(xn); - } - - public override bool status - { - get { return _isTripped; } - set { } - } - - public bool isTripped - { - get { return _isTripped; } - set { } - } - - public override int level - { - get { return (_isTripped ? 1 : 0); } - set { } - } - - public override string ToString() - { - return name + " [" + GetStatusText() + "]"; - } - - public override string GetIconName() - { - return "Motion_Sensor_" + (_isTripped ? "100" : "0"); - } - - public override string GetStatusText() - { - return (status ? "ACTIVE" : "standby"); - } + /// <summary> + /// Description of DeviceSceneController. + /// </summary> + public class DeviceSceneController: DeviceGeneric + { + private bool _isTripped = false; + + public DeviceSceneController( XmlNode xn ) : base (xn) + { + if (xn != null) + { + Update(xn); + } + } + + public override bool Update(XmlNode xn) + { + _isTripped = _helper.GetAttrAsBool(xn, "status", _isTripped); + _isTripped = _helper.GetAttrAsBool(xn, "tripped", _isTripped); + return base.Update(xn); + } + + public override bool status + { + get { return _isTripped; } + set { } + } + + public bool isTripped + { + get { return _isTripped; } + set { } + } + + public override int level + { + get { return (_isTripped ? 1 : 0); } + set { } + } + + public override string ToString() + { + return name + " [" + GetStatusText() + "]"; + } + + public override string GetIconName() + { + return "Motion_Sensor_" + (_isTripped ? "100" : "0"); + } + + public override string GetStatusText() + { + return (status ? "ACTIVE" : "standby"); + } - } + } } Modified: trunk/plugins/VeraControl/DeviceSecurity.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSecurity.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DeviceSecurity.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -14,85 +14,87 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DeviceSecurity. - /// </summary> - public class DeviceSecurity : DeviceGeneric - { - private bool _isTripped = false; - private bool _isArmed = true; - - public DeviceSecurity(XmlNode xn): base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - public override bool Update(XmlNode xn) - { - _isTripped = _helper.GetAttrAsBool(xn, "tripped", _isTripped); - _isArmed = _helper.GetAttrAsBool(xn, "armed", _isArmed); - return base.Update(xn); - } - - public override bool status - { - get { return _isArmed; } - set { - if (id > 0) // Only send when a valid ID is found - { - ReportPendingRequest(); - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&action=SetArmed" + - "&newArmedValue=" + (value ? "1" : "0"); - _vera.DoVeraCommandRequest(cmd, ReportRequestError); - } - } - } - - public bool isTripped - { - get { return _isTripped; } - set { } - } - - public override int level - { - get { return (_isArmed ? 1 : 0); } - set { status = (value > 0); } - } - - public override int maxLevel - { - get { return 1; } - set { } - } - public override bool isControllable - { - get { return true; } - set { } - } - public override string ToString() - { - return name + " [" + GetStatusText() + "]"; - } - - public override string GetIconName() - { - return "Motion_Sensor_" + (_isTripped ? "100" : "0"); - } - - public override string GetStatusText() - { - return (status ? ( isTripped ? "TRIPPED" : "standby") : "bypass"); - } + /// <summary> + /// Description of DeviceSecurity. + /// </summary> + public class DeviceSecurity : DeviceGeneric + { + private bool _isTripped = false; + private bool _isArmed = true; + + public DeviceSecurity(XmlNode xn) : base (xn) + { + if (xn != null) + { + Update(xn); + } + } + + public override bool Update(XmlNode xn) + { + _isTripped = _helper.GetAttrAsBool(xn, "tripped", _isTripped); + _isArmed = _helper.GetAttrAsBool(xn, "armed", _isArmed); + return base.Update(xn); + } + + public override bool status + { + get { return _isArmed; } + set { + if (id > 0) // Only send when a valid ID is found + { + ReportPendingRequest(); + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&action=SetArmed" + + "&newArmedValue=" + (value ? "1" : "0"); + _vera.DoVeraCommandRequest(cmd, ReportRequestError); + } + } + } + + public bool isTripped + { + get { return _isTripped; } + set { } + } + + public override int level + { + get { return (_isArmed ? 1 : 0); } + set { status = (value > 0); } + } + + public override int maxLevel + { + get { return 1; } + set { } + } - public override string [] GetCommands() - { - return new string [] {"Bypass", "Arm"}; - } - } + public override bool isControllable + { + get { return true; } + set { } + } + + public override string ToString() + { + return name + " [" + GetStatusText() + "]"; + } + + public override string GetIconName() + { + return "Motion_Sensor_" + (_isTripped ? "100" : "0"); + } + + public override string GetStatusText() + { + return (status ? ( isTripped ? "TRIPPED" : "standby") : "bypass"); + } + + public override string [] GetCommands() + { + return new string [] {"Bypass", "Arm"}; + } + } } Modified: trunk/plugins/VeraControl/DeviceSprinkler.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -14,108 +14,108 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DeviceSprinkler. - /// </summary> - public class DeviceSprinkler : DeviceGeneric - { - private bool _status = false; - private string _mode = "-"; - private string _shortMode = "-"; - private string _operationMode = "-"; - private string _condition = "-"; - - public DeviceSprinkler(XmlNode xn): base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - public override bool Update(XmlNode xn) - { - _status = _helper.GetAttrAsBool (xn, "status", _status); - _mode = _helper.GetAttrAsString(xn, "Mode", _mode); - _shortMode = _helper.GetAttrAsString(xn, "ShortMode", _shortMode); - _operationMode = _helper.GetAttrAsString(xn, "OperationMode", _operationMode); - _condition = _helper.GetAttrAsString(xn, "Condition", _condition); - return base.Update(xn); - } - - public override bool status - { - get { return _status; } - set { - if (id > 0) // Only send when a valid ID is found - { - ReportPendingRequest(); - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + - "&newTargetValue="+(value ? "1" : "0"); - _vera.DoVeraCommandRequest(cmd, ReportRequestError); - } - } - } - - public override int level - { - get { return (_status ? 1 : 0); } - set { status = (value > 0); } - } + /// <summary> + /// Description of DeviceSprinkler. + /// </summary> + public class DeviceSprinkler : DeviceGeneric + { + private bool _status = false; + private string _mode = "-"; + private string _shortMode = "-"; + private string _operationMode = "-"; + private string _condition = "-"; + + public DeviceSprinkler(XmlNode xn) : base (xn) + { + if (xn != null) + { + Update(xn); + } + } + + public override bool Update(XmlNode xn) + { + _status = _helper.GetAttrAsBool (xn, "status", _status); + _mode = _helper.GetAttrAsString(xn, "Mode", _mode); + _shortMode = _helper.GetAttrAsString(xn, "ShortMode", _shortMode); + _operationMode = _helper.GetAttrAsString(xn, "OperationMode", _operationMode); + _condition = _helper.GetAttrAsString(xn, "Condition", _condition); + return base.Update(xn); + } + + public override bool status + { + get { return _status; } + set { + if (id > 0) // Only send when a valid ID is found + { + ReportPendingRequest(); + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + + "&newTargetValue="+(value ? "1" : "0"); + _vera.DoVeraCommandRequest(cmd, ReportRequestError); + } + } + } + + public override int level + { + get { return (_status ? 1 : 0); } + set { status = (value > 0); } + } - public override string mode - { - get { return _mode; } - set { - if (id > 0) // Only send when a valid ID is found - { - ReportPendingRequest(); - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:upnp-micasaverde-com:serviceId:Sprinkler1&action=" + - (value == "Auto" ? "SetModeAuto" : (value == "Block" ? "SetModeBlock" : "SetModeManual")); - _vera.DoVeraCommandRequest(cmd, ReportRequestError); - } - } - } - - public override string ToString() - { - return name + " [" + _shortMode + "]"; - } - - public override bool isControllable - { - get { return true; } - set { } - } - - public override int maxLevel - { - get { return 1; } - set { } - } - - public override string GetIconName() - { - return "Sprinkler"; - } - - public override string GetStatusText() - { - return _operationMode.Replace("_", " "); - } - - public override string GetExtraText() - { - return _condition; - } + public override string mode + { + get { return _mode; } + set { + if (id > 0) // Only send when a valid ID is found + { + ReportPendingRequest(); + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:upnp-micasaverde-com:serviceId:Sprinkler1&action=" + + (value == "Auto" ? "SetModeAuto" : (value == "Block" ? "SetModeBlock" : "SetModeManual")); + _vera.DoVeraCommandRequest(cmd, ReportRequestError); + } + } + } + + public override string ToString() + { + return name + " [" + _shortMode + "]"; + } + + public override bool isControllable + { + get { return true; } + set { } + } + + public override int maxLevel + { + get { return 1; } + set { } + } + + public override string GetIconName() + { + return "Sprinkler"; + } + + public override string GetStatusText() + { + return _operationMode.Replace("_", " "); + } + + public override string GetExtraText() + { + return _condition; + } - public override string [] GetCommands() - { - return new string [] {"Off", "On", "Auto", "Block", "Manual"}; - } - } + public override string [] GetCommands() + { + return new string [] {"Off", "On", "Auto", "Block", "Manual"}; + } + } } Modified: trunk/plugins/VeraControl/DeviceSwitch.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSwitch.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DeviceSwitch.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -13,90 +13,90 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DeviceSwitch. - /// </summary> - public class DeviceSwitch : DeviceGeneric - { - private bool _status = false; - private string _watt = "-"; - private string _kwh = "-"; - - public DeviceSwitch(XmlNode xn): base (xn) - { - if (xn != null) - { - Update(xn); - } - } - - public override bool Update(XmlNode xn) - { - _status = _helper.GetAttrAsBool (xn, "status", _status); - _watt = _helper.GetAttrAsString(xn, "watts", _watt); - _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh); - - return base.Update(xn); - } - - public string watts - { - get { return _watt; } - set { } - } - - public override bool status - { - get { return _status; } - set { - if (id > 0) // Only send when a valid ID is found - { - ReportPendingRequest(); - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + - "&newTargetValue="+(value ? "1" : "0"); - _vera.DoVeraCommandRequest(cmd, ReportRequestError); - } - } - } - - public override int level - { - get { return (_status ? 1 : 0); } - set { status = (value > 0); } - } - - public override int maxLevel - { - get { return 1; } - set { } - } - - public override string ToString() - { - return name + " [" + GetStatusText()+ "]"; - } - - public override bool isControllable - { - get { return true; } - set { } - } - - public override string GetIconName() - { - return "Binary_Light_" + (_status ? "100" : "0"); - } - - public override string GetExtraText() - { - return (_kwh != "" ? _kwh + "kWh" : ""); - } - - public override string GetStatusText() - { - return (status ? "On" : "Off"); - } - } + /// <summary> + /// Description of DeviceSwitch. + /// </summary> + public class DeviceSwitch : DeviceGeneric + { + private bool _status = false; + private string _watt = "-"; + private string _kwh = "-"; + + public DeviceSwitch(XmlNode xn) : base (xn) + { + if (xn != null) + { + Update(xn); + } + } + + public override bool Update(XmlNode xn) + { + _status = _helper.GetAttrAsBool (xn, "status", _status); + _watt = _helper.GetAttrAsString(xn, "watts", _watt); + _kwh = _helper.GetAttrAsString(xn, "kwh", _kwh); + + return base.Update(xn); + } + + public string watts + { + get { return _watt; } + set { } + } + + public override bool status + { + get { return _status; } + set { + if (id > 0) // Only send when a valid ID is found + { + ReportPendingRequest(); + // Do something with vera + string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + + "&newTargetValue="+(value ? "1" : "0"); + _vera.DoVeraCommandRequest(cmd, ReportRequestError); + } + } + } + + public override int level + { + get { return (_status ? 1 : 0); } + set { status = (value > 0); } + } + + public override int maxLevel + { + get { return 1; } + set { } + } + + public override string ToString() + { + return name + " [" + GetStatusText()+ "]"; + } + + public override bool isControllable + { + get { return true; } + set { } + } + + public override string GetIconName() + { + return "Binary_Light_" + (_status ? "100" : "0"); + } + + public override string GetExtraText() + { + return (_kwh != "" ? _kwh + "kWh" : ""); + } + + public override string GetStatusText() + { + return (status ? "On" : "Off"); + } + } } Modified: trunk/plugins/VeraControl/DeviceSystem.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSystem.cs 2012-01-28 09:50:54 UTC (rev 4427) +++ trunk/plugins/VeraControl/DeviceSystem.cs 2012-01-28 20:18:43 UTC (rev 4428) @@ -12,174 +12,174 @@ namespace VeraControl.Properties { - /// <summary> - /// Description of DeviceSystem. - /// </summary> - public class DeviceSystem - { - public DeviceSystem() - { - } - - public VeraHelper _helper = VeraHelper.Instance; - - public long _lastUpdate = 0; - public bool _screenUpdateRequired = false; - private bool _fullReload = true; - private string _version = ""; - private string _model = ""; - private bool _zWaveHeal = false; - private bool _metric = true; - private string _serial = ""; - private string _fwd1Server = ""; - private string _fwd2Server = ""; - private string _loadTime = "0"; - private string _dataVersion = "0"; - private string _comment = ""; - private DevState _dsVeraState = DevState.NONE; - - - public bool update(XmlNode xn) - { - _fullReload = _helper.GetAttrAsBool (xn, "full", _fullReload); - _version = _helper.GetAttrAsString (xn, "version", _version); - _model = _helper.GetAttrAsString (xn, "model", _model); - _zWaveHeal = _helper.GetAttrAsBool (xn, "zwave_heal", _zWaveHeal); - _serial = _helper.GetAttrAsString (xn, "serial_number", _serial); - _fwd1Server = _helper.GetAttrAsString (xn, "fwd1", _fwd1Server); - _fwd2Server = _helper.GetAttrAsString (xn, "fwd2", _fwd2Server); - _loadTime = _helper.GetAttrAsString (xn, "loadtime", _loadTime); - - // Set update flag - string tempDataversion = _helper.GetAttrAsString (xn, "dataversion", _dataVersion); - DevState tempVeraState = _helper.ToDevState(_helper.GetAttrAsInt(xn, "state", -1)); - string tempComment = _helper.GetAttrAsString (xn, "comment", ""); - - if ((_dataVersion != tempDataversion) || _comment != tempComment || _dsVeraState != tempVeraState) - { - _screenUpdateRequired = true; - _lastUpdate = DateTime.Now.Ticks; - } - _dataVersion = tempDataversion; - _dsVeraState = tempVeraState; - _comment = tempComment; - - _dsVeraState = _helper.ToDevState(_helper.GetAttrAsInt(xn, "state", -1)); - _comment = _helper.GetAttrAsString (xn, "comment", ""); - _metric = (_helper.GetAttrAsString(xn, "temperature", "C") == "C"); - - return true; - } - - public void ClearFullReloadFlag() - { - _fullReload = false; - } - - public void SetFullReloadFlag() - { - _fullReload = true; - } - public bool fullReload - { - get { return _fullReload; } - set { } - } - - public string versionInfo - { - get { return _model + " " + _version; } - set { } - } - - public bool zWaveHeal - { - get { return _zWaveHeal; } - set { } - } - - public string serialno - { - get { return _serial; } - set { } - } + /// <summary> + /// Description of DeviceSystem. + /// </summary> + public class DeviceSystem + { + public DeviceSystem() + { + } + + public VeraHelper _helper = VeraHelper.Instance; + + public long _lastUpdate = 0; + public bool _screenUpdateRequired = false; + private bool _fullReload = true; + private string _version = ""; + private string _model = ""; + private bool _zWaveHeal = false; + private bool _metric = true; + private string _serial = ""; + private string _fwd1Server = ""; + private string _fwd2Server = ""; + private string _loadTime = "0"; + ... [truncated message content] |
From: <Ba...@us...> - 2012-02-02 20:07:18
|
Revision: 4436 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4436&view=rev Author: BartEv Date: 2012-02-02 20:07:07 +0000 (Thu, 02 Feb 2012) Log Message: ----------- version 0.9.0.3 - Show device status of selected item also on main screen, - Added the ability to show devices automatically when selecting a new room (= extra config option) - bug fix: wrong scene dialog was shown in DefautWide skin Modified Paths: -------------- trunk/plugins/VeraControl/DeviceSystem.cs trunk/plugins/VeraControl/DialogDeviceControl.cs trunk/plugins/VeraControl/DialogSceneControl.cs trunk/plugins/VeraControl/VeraCommunication.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/VeraSetupForm.Designer.cs trunk/plugins/VeraControl/VeraSetupForm.cs trunk/plugins/VeraControl/releases/VeraControl.xmp2 trunk/plugins/VeraControl/releases/update.xml trunk/plugins/VeraControl/skin/Default/VeraControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml Added Paths: ----------- trunk/plugins/VeraControl/releases/VeraControl_v0.9.0.3.mpe1 Modified: trunk/plugins/VeraControl/DeviceSystem.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSystem.cs 2012-02-02 11:43:11 UTC (rev 4435) +++ trunk/plugins/VeraControl/DeviceSystem.cs 2012-02-02 20:07:07 UTC (rev 4436) @@ -80,6 +80,14 @@ { _fullReload = true; } + + public bool FullReloadWaitingAndClearFlag() + { + // Invoking this method will clear the update ready flag -> so caller need to handle the update + bool b = fullReload; + ClearFullReloadFlag(); + return b; + } public bool fullReload { get { return _fullReload; } Modified: trunk/plugins/VeraControl/DialogDeviceControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-02-02 11:43:11 UTC (rev 4435) +++ trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-02-02 20:07:07 UTC (rev 4436) @@ -77,14 +77,16 @@ return Load(GUIGraphicsContext.Skin + @"\VeraDialogDeviceControl.xml"); } - public void InitDialog(string headerText, DeviceGeneric dev) + public void ShowDialog(string headerText, DeviceGeneric dev) { + Reset(); //LoadSkin(); AllocResources(); InitControls(); _lblHeading.Label = headerText; _myDev = dev; + //Clean up the old camUpdateThread (if not finished yet) if (_camUpdater != null) { @@ -121,6 +123,7 @@ _imgLogo.Visibility = System.Windows.Visibility.Hidden; StartCamImageUpdater(((DeviceCam)dev).imgUrl); } + DoModal(GUIWindowManager.ActiveWindow); } public void UpdateStatus() Modified: trunk/plugins/VeraControl/DialogSceneControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogSceneControl.cs 2012-02-02 11:43:11 UTC (rev 4435) +++ trunk/plugins/VeraControl/DialogSceneControl.cs 2012-02-02 20:07:07 UTC (rev 4436) @@ -51,8 +51,9 @@ return Load(GUIGraphicsContext.Skin + @"\VeraDialogSceneControl.xml"); } - public void InitDialog(string headerText, Scene scene) + public void ShowDialog(string headerText, Scene scene) { + Reset(); //LoadSkin(); AllocResources(); InitControls(); @@ -61,6 +62,7 @@ _myScene = scene; UpdateStatus(); + DoModal(GUIWindowManager.ActiveWindow); } public void UpdateStatus() Modified: trunk/plugins/VeraControl/VeraCommunication.cs =================================================================== --- trunk/plugins/VeraControl/VeraCommunication.cs 2012-02-02 11:43:11 UTC (rev 4435) +++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-02-02 20:07:07 UTC (rev 4436) @@ -360,11 +360,11 @@ else { ParseUpdateInfo(e.Result); - // WebClient wc = new WebClient(); - // if (_status.system.dataversion == "0") - // { - //ParseUpdateInfo( wc.DownloadString(@"C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\testdata\text.xml")); - // } +// WebClient wc = new WebClient(); +// if (_status.system.dataversion == "0") +// { +// ParseUpdateInfo( wc.DownloadString(@"C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\testdata\text.xml")); +// } } } @@ -407,6 +407,7 @@ { // We have a full refresh -> Clear all lists (to get clear of removed devices/scenes/catgories/rooms/etc...) _status.ClearAllLists(); + } // Process Sections @@ -568,7 +569,6 @@ _status.devices.Add(new DeviceSprinkler(xn)); break; } - /* Falltrough */ _status.devices.Add(new DeviceGeneric(xn)); break; } Modified: trunk/plugins/VeraControl/VeraControl.cs =================================================================== --- trunk/plugins/VeraControl/VeraControl.cs 2012-02-02 11:43:11 UTC (rev 4435) +++ trunk/plugins/VeraControl/VeraControl.cs 2012-02-02 20:07:07 UTC (rev 4436) @@ -81,30 +81,34 @@ /// </summary> public class VeraControl : GUIInternalWindow, ISetupForm { - [SkinControlAttribute(10)] protected GUILabelControl _title = null; - [SkinControl(20)] protected GUISpinButton _catList = null; - [SkinControl(40)] protected GUIListControl _leftList = null; - [SkinControl(50)] protected GUIListControl _rightList = null; - [SkinControl(60)] protected GUIButtonControl _actionButton = null; - [SkinControl(70)] protected GUIToggleButtonControl _actionTriggerButton = null; + [SkinControlAttribute(10)] protected GUILabelControl _title = null; + [SkinControl(20)] protected GUISpinButton _catList = null; + [SkinControl(40)] protected GUIListControl _leftList = null; + [SkinControl(50)] protected GUIListControl _rightList = null; + [SkinControl(60)] protected GUIButtonControl _actionButton = null; + [SkinControl(70)] protected GUIToggleButtonControl _actionTriggerButton = null; - [SkinControl(30)] protected GUIImage _cmtImage = null; - [SkinControlAttribute(31)] protected GUILabelControl _comment = null; + [SkinControl(30)] protected GUIImage _systemStatusImage = null; + [SkinControlAttribute(31)] protected GUILabelControl _systemStatusText = null; + [SkinControl(32)] protected GUIImage _deviceStatusImage = null; + [SkinControlAttribute(33)] protected GUILabelControl _deviceStatusText = null; - const int ALL = Int16.MaxValue; - const int NO_SCENE_SELECTED = Int16.MaxValue; + const int ALL = Int16.MaxValue; + const int NO_SCENE_SELECTED = Int16.MaxValue; + private int _pluginID = 1972; + private VeraCommunication _vera = VeraCommunication.Instance; - private int _pluginID = 1972; - private VeraCommunication _vera = VeraCommunication.Instance; - private int _selectedRoom = ALL; - private int _selectedCategory = ALL; - public Actiontrigger _lastAction = Actiontrigger.LAST_ACTIONTRIGGER; - private VeraHelper _helper = new VeraHelper(); + private int _selectedRoom = ALL; + private int _selectedCategory = ALL; + public Actiontrigger _lastAction = Actiontrigger.LAST_ACTIONTRIGGER; + private VeraHelper _helper = new VeraHelper(); + private int _lastSelectedItemId = 0; - public bool _enableSceneTrigger = false; - private bool _lastUpdateFailed = false; - private string _titleTxt = "Micasa Verde - Vera control"; + public bool _enableSceneTrigger = false; + private bool _autoSelectRoom = true; + private bool _lastUpdateFailed = false; + private string _titleTxt = "Micasa Verde - Vera control"; public VeraControl() { @@ -201,7 +205,8 @@ using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { - _enableSceneTrigger = xmlreader.GetValueAsBool("veracontroller", "enableSceneTrigger", false); + _enableSceneTrigger = xmlreader.GetValueAsBool("veracontroller", "enableSceneTrigger", false); + _autoSelectRoom = xmlreader.GetValueAsBool("veracontroller", "AutoSelectRoom", true); } GUIWindowManager.OnNewAction += new OnActionHandler(OnNewAction); @@ -223,6 +228,7 @@ handleActionTriggers(Actiontrigger.MP_START_UP); } }).Start(); + return Load(GUIGraphicsContext.Skin+@"\VeraControl.xml"); } @@ -305,10 +311,16 @@ { switch(action.wID) { + case Action.ActionType.ACTION_MOUSE_MOVE: + break; + case Action.ActionType.ACTION_CONTEXT_MENU: case Action.ActionType.ACTION_SHOW_INFO: showInfoDialog(); break; + + default: + break; } } } @@ -510,13 +522,32 @@ _vera.UpdateCurrentStatus(); refreshNow(); + // Auto update right side list + if (_autoSelectRoom && (_selectedRoom != _leftList.SelectedListItem.ItemId)) + { + OnLeftlistCrtl(_leftList); + } + base.Render(timePassed); } public void refreshNow() { - if (_vera.NewScreenUpdateWaitingAndClearFlag()) + int selectedItem = 0; + if (_rightList.SelectedListItem != null) + { // Prevent Eception in case we have an empty room + selectedItem = _rightList.SelectedListItem.ItemId; + } + else if (_lastSelectedItemId != 0) { + // Clear message if we have an empty list for the first time + setDeviceStatus(DevState.NONE, ""); + } + bool newSelectedItem = (selectedItem != _lastSelectedItemId) && (selectedItem != 0); + _lastSelectedItemId = selectedItem; + + if (_vera.NewScreenUpdateWaitingAndClearFlag() || newSelectedItem) + { // update system status if (_vera.status.system.NewScreenUpdateWaitingAndClearFlag()) { @@ -524,7 +555,7 @@ } // if full reload has been found rebuild lists - if (_vera.status.system.fullReload ) { + if (_vera.status.system.FullReloadWaitingAndClearFlag() ) { listRooms(_selectedCategory, _selectedRoom); if (_selectedRoom == ALL) { listScenes(ALL); @@ -540,7 +571,7 @@ if (item.ItemId > 0) { // ItemId > 0 so we have a device DeviceGeneric dev = _vera.status.GetDeviceById(item.ItemId); - if (dev.NewScreenUpdateWaitingAndClearFlag()) + if (dev.NewScreenUpdateWaitingAndClearFlag() || (newSelectedItem && _lastSelectedItemId == item.ItemId)) { fillinDeviceInfo(item, dev); } @@ -548,7 +579,7 @@ else { // ItemId < 0 so we have a scene Scene scene = _vera.status.GetSceneById((item.ItemId * -1)); - if (scene.NewScreenUpdateWaitingAndClearFlag()) + if (scene.NewScreenUpdateWaitingAndClearFlag() || (newSelectedItem && _lastSelectedItemId == item.ItemId)) { fillinSceneInfo(item, scene); } @@ -583,17 +614,31 @@ private void setSystemStatus() { if (_vera.status.system.state != DevState.NONE) { - _cmtImage.Dispose(); - _cmtImage.SetFileName(_helper.GetStateImage(_vera.status.system.state)); - _cmtImage.KeepAspectRatio = true; - _cmtImage.Visibility = System.Windows.Visibility.Visible; - _cmtImage.AllocResources(); + _systemStatusImage.Dispose(); + _systemStatusImage.SetFileName(_helper.GetStateImage(_vera.status.system.state)); + _systemStatusImage.KeepAspectRatio = true; + _systemStatusImage.Visibility = System.Windows.Visibility.Visible; + _systemStatusImage.AllocResources(); } else{ - _cmtImage.Visibility = System.Windows.Visibility.Hidden; + _systemStatusImage.Visibility = System.Windows.Visibility.Hidden; } - _comment.Label = _vera.status.system.comment; - + _systemStatusText.Label = _vera.status.system.comment; } + + private void setDeviceStatus(DevState state, string text) + { + if (state != DevState.NONE) { + _deviceStatusImage.Dispose(); + _deviceStatusImage.SetFileName(_helper.GetStateImage(state)); + _deviceStatusImage.KeepAspectRatio = true; + _deviceStatusImage.Visibility = System.Windows.Visibility.Visible; + _deviceStatusImage.AllocResources(); + } else{ + _deviceStatusImage.Visibility = System.Windows.Visibility.Hidden; + } + _deviceStatusText.Label = text; + } + private void listCategories() { @@ -689,6 +734,11 @@ item.ThumbnailImage = "Vera\\" + scene.GetIconName() + ".png"; Utils.SetDefaultIcons(item); + + if (_lastSelectedItemId == (scene.id * -1)) + { + setDeviceStatus(scene.commstate, scene.comment); + } } private void listDevices(int selectedRoom) @@ -720,6 +770,11 @@ item.ThumbnailImage = "Vera\\" + dev.GetIconName() + ".png"; Utils.SetDefaultIcons(item); + + if (_lastSelectedItemId == dev.id) + { + setDeviceStatus(dev.commstate, dev.comment); + } } private void OnLeftlistCrtl(GUIListControl control) @@ -775,16 +830,15 @@ break; case Action.ActionType.ACTION_SELECT_ITEM: - DialogSceneControl dlg = (DialogSceneControl)GUIWindowManager.GetWindow((int)1975); - dlg.InitDialog("Scene control", scene); - dlg.DoModal(GUIWindowManager.ActiveWindow); + DialogSceneControl sceneDlg = (DialogSceneControl)GUIWindowManager.GetWindow((int)1975); + sceneDlg.ShowDialog("Scene control", scene); break; } } } else { // We have a device as selected item - DeviceGeneric dev = _vera.status.GetDeviceById(control.SelectedListItem.ItemId); + DeviceGeneric dev = _vera.status.GetDeviceById(control.SelectedListItem.ItemId); switch (actionType) { @@ -807,9 +861,8 @@ break; case Action.ActionType.ACTION_SELECT_ITEM: - DialogDeviceControl dlg = (DialogDeviceControl)GUIWindowManager.GetWindow((int)1973); - dlg.InitDialog(_vera.status.GetRoomById(dev.room).name, dev); - dlg.DoModal(GUIWindowManager.ActiveWindow); + DialogDeviceControl deviceDlg = (DialogDeviceControl)GUIWindowManager.GetWindow((int)1973); + deviceDlg.ShowDialog(_vera.status.GetRoomById(dev.room).name, dev); break; } } @@ -875,7 +928,7 @@ "When navigating through the right side menu the following RC keys are available:\n" + " [Play] will run the selected scene\n" + " [Next]/[Prev] will switch off/on the selected device\n" + - " [Fwd] / [Rew] will decrease/increase the level of the selected devive\n" + + " [Fwd] / [Rwd] will decrease/increase the level of the selected devive\n" + " [i] show this info panel"); dlg.DoModal(GUIWindowManager.ActiveWindow); } Modified: trunk/plugins/VeraControl/VeraSetupForm.Designer.cs =================================================================== --- trunk/plugins/VeraControl/VeraSetupForm.Designer.cs 2012-02-02 11:43:11 UTC (rev 4435) +++ trunk/plugins/VeraControl/VeraSetupForm.Designer.cs 2012-02-02 20:07:07 UTC (rev 4436) @@ -48,6 +48,7 @@ this.portnumber = new System.Windows.Forms.TextBox(); this.refreshdelay = new System.Windows.Forms.TextBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.autoSelectRoom = new System.Windows.Forms.CheckBox(); this.enableSceneTrigger = new System.Windows.Forms.CheckBox(); this.label1 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); @@ -57,7 +58,7 @@ // btnOK // this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.btnOK.Location = new System.Drawing.Point(31, 297); + this.btnOK.Location = new System.Drawing.Point(31, 345); this.btnOK.Name = "btnOK"; this.btnOK.Size = new System.Drawing.Size(75, 23); this.btnOK.TabIndex = 12; @@ -69,7 +70,7 @@ // this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(231, 297); + this.btnCancel.Location = new System.Drawing.Point(231, 345); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.TabIndex = 13; @@ -273,16 +274,28 @@ // // groupBox2 // + this.groupBox2.Controls.Add(this.autoSelectRoom); this.groupBox2.Controls.Add(this.enableSceneTrigger); this.groupBox2.Controls.Add(this.refreshdelay); this.groupBox2.Controls.Add(this.label1); this.groupBox2.Location = new System.Drawing.Point(12, 203); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(309, 82); + this.groupBox2.Size = new System.Drawing.Size(309, 110); this.groupBox2.TabIndex = 8; this.groupBox2.TabStop = false; this.groupBox2.Text = "Plug in settings"; // + // autoSelectRoom + // + this.autoSelectRoom.Checked = true; + this.autoSelectRoom.CheckState = System.Windows.Forms.CheckState.Checked; + this.autoSelectRoom.Location = new System.Drawing.Point(20, 77); + this.autoSelectRoom.Name = "autoSelectRoom"; + this.autoSelectRoom.Size = new System.Drawing.Size(270, 24); + this.autoSelectRoom.TabIndex = 12; + this.autoSelectRoom.Text = "Show devices in selected room immediately"; + this.autoSelectRoom.UseVisualStyleBackColor = true; + // // enableSceneTrigger // this.enableSceneTrigger.Location = new System.Drawing.Point(20, 47); @@ -307,7 +320,7 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(332, 332); + this.ClientSize = new System.Drawing.Size(332, 380); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Controls.Add(this.btnCancel); @@ -322,6 +335,7 @@ this.groupBox2.PerformLayout(); this.ResumeLayout(false); } + private System.Windows.Forms.CheckBox autoSelectRoom; private System.Windows.Forms.Button buttonFind; private System.Windows.Forms.RadioButton radioLocal; private System.Windows.Forms.RadioButton radioRemote; Modified: trunk/plugins/VeraControl/VeraSetupForm.cs =================================================================== --- trunk/plugins/VeraControl/VeraSetupForm.cs 2012-02-02 11:43:11 UTC (rev 4435) +++ trunk/plugins/VeraControl/VeraSetupForm.cs 2012-02-02 20:07:07 UTC (rev 4436) @@ -47,10 +47,11 @@ { using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { - IPaddress.Text = xmlreader.GetValueAsString("veracontroller", "ipaddress", "127.0.0.1"); - portnumber.Text = xmlreader.GetValueAsString("veracontroller", "portnumber", " 3480"); - refreshdelay.Text = xmlreader.GetValueAsString("veracontroller", "maxrefreshdelay", "60"); - enableSceneTrigger.Checked = xmlreader.GetValueAsBool("veracontroller", "enableSceneTrigger", false); + IPaddress.Text = xmlreader.GetValueAsString("veracontroller", "ipaddress", "127.0.0.1"); + portnumber.Text = xmlreader.GetValueAsString("veracontroller", "portnumber", "3480"); + refreshdelay.Text = xmlreader.GetValueAsString("veracontroller", "maxrefreshdelay", "60"); + enableSceneTrigger.Checked = xmlreader.GetValueAsBool("veracontroller", "enableSceneTrigger", false); + autoSelectRoom.Checked = xmlreader.GetValueAsBool("veracontroller", "AutoSelectRoom", true); radioRemote.Checked = xmlreader.GetValueAsBool("veracontroller", "remoteConnected", false); radioLocal.Checked = !radioRemote.Checked; @@ -67,16 +68,17 @@ { using (MediaPortal.Profile.Settings xmlWriter = new MediaPortal.Profile.MPSettings()) { - xmlWriter.SetValue("veracontroller", "ipaddress", IPaddress.Text); - xmlWriter.SetValue("veracontroller", "portnumber", portnumber.Text); - xmlWriter.SetValue("veracontroller", "maxrefreshdelay", refreshdelay.Text); + xmlWriter.SetValue("veracontroller", "ipaddress", IPaddress.Text); + xmlWriter.SetValue("veracontroller", "portnumber", portnumber.Text); + xmlWriter.SetValue("veracontroller", "maxrefreshdelay", refreshdelay.Text); xmlWriter.SetValueAsBool("veracontroller", "enableSceneTrigger", enableSceneTrigger.Checked); + xmlWriter.SetValueAsBool("veracontroller", "AutoSelectRoom", autoSelectRoom.Checked); xmlWriter.SetValueAsBool("veracontroller", "remoteConnected", radioRemote.Checked); - xmlWriter.SetValue("veracontroller", "miosusername", Username.Text); - xmlWriter.SetValue("veracontroller", "miospassword", Password.Text); - xmlWriter.SetValue("veracontroller", "serialnumber", SerialNumber.Text); + xmlWriter.SetValue("veracontroller", "miosusername", Username.Text); + xmlWriter.SetValue("veracontroller", "miospassword", Password.Text); + xmlWriter.SetValue("veracontroller", "serialnumber", SerialNumber.Text); } } Modified: trunk/plugins/VeraControl/releases/VeraControl.xmp2 =================================================================== --- trunk/plugins/VeraControl/releases/VeraControl.xmp2 2012-02-02 11:43:11 UTC (rev 4435) +++ trunk/plugins/VeraControl/releases/VeraControl.xmp2 2012-02-02 20:07:07 UTC (rev 4436) @@ -62,7 +62,7 @@ <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> <Param1 /> <UpdateOption>OverwriteIfOlder</UpdateOption> - <LocalFileName>..\skin\Default\VeraDialogSceneControl.xml</LocalFileName> + <LocalFileName>..\skin\DefaultWide\VeraDialogSceneControl.xml</LocalFileName> <ZipFileName>Installer{CopyFile}\{cced0cd3-b45e-4cf1-af86-d268fa728b06}-VeraDialogSceneControl.xml</ZipFileName> <DestinationFilename>%Skin%\DefaultWide\VeraDialogSceneControl.xml</DestinationFilename> </FileItem> @@ -865,7 +865,7 @@ <Major>0</Major> <Minor>9</Minor> <Build>0</Build> - <Revision>2</Revision> + <Revision>3</Revision> </Version> <ExtensionDescription>Control your Vera controller from MediaPortal. @@ -885,37 +885,53 @@ - Vera 2 v1.1.1267 + - Vera 2 v1.1.1362 + - Vera 2 v1.5.255 - - - - - - - - - - </ExtensionDescription> <VersionDescription>[9.0.0.1] + - Real time Vera status update + -Threated communication (no-screen-lockups) + - IP Cam support + - Improved error handling + - Improved Cam image updater + - Clean up code (coding standard complience) + - Supports remote connection (via fwd1.mios.com) + - New image set + - Improved config screen (Vera-box look) + - first: stable release -[9.0.0.2] + + +[0.9.0.2] + - Added a help screen (! button = context menu) -- Added RC commands to control devices/scenes without the need of opening the dialog</VersionDescription> + +- Added RC commands to control devices/scenes without the need of opening the dialog + + + +[0.9.0.3] + + - Show device status of selected item also on main screen, + + - Added the ability to show devices automatically when selecting a new room (= extra config option) + + - bug fix: wrong scene dialog was shown in DefautWide skin</VersionDescription> <DevelopmentStatus>Stable</DevelopmentStatus> - <OnlineLocation>https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/VeraControl/releases/VeraControl_v0.9.0.2.mpe1</OnlineLocation> - <ReleaseDate>2012-01-28T22:51:05</ReleaseDate> + <OnlineLocation>https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/VeraControl/releases/VeraControl_v0.9.0.3.mpe1</OnlineLocation> + <ReleaseDate>2012-01-30T22:51:05</ReleaseDate> <Tags>home automation, z-wave, micasaverde, @@ -1007,10 +1023,17 @@ <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> <Param1 /> <UpdateOption>OverwriteIfOlder</UpdateOption> - <LocalFileName>..\skin\Default\VeraDialogSceneControl.xml</LocalFileName> + <LocalFileName>..\skin\DefaultWide\VeraDialogSceneControl.xml</LocalFileName> <ZipFileName>Installer{CopyFile}\{cced0cd3-b45e-4cf1-af86-d268fa728b06}-VeraDialogSceneControl.xml</ZipFileName> <DestinationFilename>%Skin%\DefaultWide\VeraDialogSceneControl.xml</DestinationFilename> </FileItem> + <FileItem InstallType="CopyFile" SystemFile="false" Modified="true"> + <Param1 /> + <UpdateOption>OverwriteIfOlder</UpdateOption> + <LocalFileName>..\skin\Default\VeraDialogSceneControl.xml</LocalFileName> + <ZipFileName>Installer{CopyFile}\{77a408e1-11da-4375-83bb-6b197c362f88}-VeraDialogSceneControl.xml</ZipFileName> + <DestinationFilename>%Skin%\Default\VeraDialogSceneControl.xml</DestinationFilename> + </FileItem> <FileItem InstallType="CopyFile" SystemFile="false" Modified="false"> <Param1 /> <UpdateOption>OverwriteIfOlder</UpdateOption> Added: trunk/plugins/VeraControl/releases/VeraControl_v0.9.0.3.mpe1 =================================================================== (Binary files differ) Property changes on: trunk/plugins/VeraControl/releases/VeraControl_v0.9.0.3.mpe1 ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/plugins/VeraControl/releases/update.xml =================================================================== --- trunk/plugins/VeraControl/releases/update.xml 2012-02-02 11:43:11 UTC (rev 4435) +++ trunk/plugins/VeraControl/releases/update.xml 2012-02-02 20:07:07 UTC (rev 4436) @@ -1177,5 +1177,152 @@ </ProjectSettings> <IsSkin>false</IsSkin> </PackageClass> + <PackageClass> + <Version>2.0</Version> + <Groups> + <Items> + <GroupItem Name="Default"> + <DisplayName>Default</DisplayName> + <DefaulChecked>true</DefaulChecked> + <Description>Default</Description> + <Files> + <Items /> + </Files> + </GroupItem> + <GroupItem Name="IconsDefault"> + <DisplayName>IconsDefault</DisplayName> + <DefaulChecked>true</DefaulChecked> + <Description>IconsDefault</Description> + <Files> + <Items /> + </Files> + </GroupItem> + <GroupItem Name="IconsDefaultWide"> + <DisplayName>IconsDefaultWide</DisplayName> + <DefaulChecked>true</DefaulChecked> + <Description>IconsDefaultWide</Description> + <Files> + <Items /> + </Files> + </GroupItem> + </Items> + </Groups> + <Sections> + <Items /> + </Sections> + <Dependencies> + <Items> + <DependencyItem> + <Type>MediaPortal</Type> + <Id /> + <MinVersion> + <Major>1</Major> + <Minor>1</Minor> + <Build>6</Build> + <Revision>27644</Revision> + </MinVersion> + <MaxVersion> + <Major>1</Major> + <Minor>1</Minor> + <Build>6</Build> + <Revision>27644</Revision> + </MaxVersion> + <WarnOnly>false</WarnOnly> + <Message>requires MediaPortal version 1.1.6.27644 to 1.1.6.27644</Message> + <Name>MediaPortal</Name> + </DependencyItem> + </Items> + </Dependencies> + <PluginDependencies> + <Items> + <PluginDependencyItem AssemblyName="VeraControl.dll"> + <CompatibleVersion> + <Items> + <CompatibleVersionItem> + <MinRequiredVersion>1.1.6.27644</MinRequiredVersion> + <DesignedForVersion>1.1.6.27644</DesignedForVersion> + </CompatibleVersionItem> + </Items> + </CompatibleVersion> + <SubSystemsUsed> + <Items> + <SubSystemItem Name="MP.SkinEngine" /> + <SubSystemItem Name="MP.Config" /> + </Items> + </SubSystemsUsed> + </PluginDependencyItem> + </Items> + </PluginDependencies> + <GeneralInfo> + <Name>Vera Controller</Name> + <Id>ebb6b1af-6fb9-44e5-a859-9d32ffe20a9e</Id> + <Author>Bart Eversdijk</Author> + <HomePage>http://www.team-mediaportal.com/extensions/micasaverde-vera-controller</HomePage> + <ForumPage>http://forum.team-mediaportal.com/mediaportal-plugins-47/plugin-micasaverde-vera-controller-104337/</ForumPage> + <UpdateUrl>https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/VeraControl/releases/update.xml</UpdateUrl> + <Version> + <Major>0</Major> + <Minor>9</Minor> + <Build>0</Build> + <Revision>3</Revision> + </Version> + <ExtensionDescription>Control your Vera controller from MediaPortal. + +Supports Scene triggers for starting, hibernating and exiting MediaPortal; Also starting, pausing and stopping media streams. So dim your lights and close the curtains automatically when MediaPortal starts a movie... + +Vera is a Z-wave home automation controller from MicasaVerde. + +This version is tested with: + - Vera 1 v1.1.1338 + - Vera 2 v1.1.1267 + - Vera 2 v1.1.1362 + - Vera 2 v1.5.255 +</ExtensionDescription> + <VersionDescription> - Show device status of selected item also on main screen, + - Added the ability to show devices automatically when selecting a new room (= extra config option) + - bug fix: wrong scene dialog was shown in DefautWide skin</VersionDescription> + <DevelopmentStatus>Stable</DevelopmentStatus> + <OnlineLocation>https://mp-plugins.svn.sourceforge.net/svnroot/mp-plugins/trunk/plugins/VeraControl/releases/VeraControl_v0.9.0.3.mpe1</OnlineLocation> + <ReleaseDate>2012-02-02T22:51:05</ReleaseDate> + <Tags>home automation, +z-wave, +micasaverde, +vera</Tags> + <Location>C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\releases\VeraControl_v0.9.0.3.mpe1</Location> + <Params> + <Items> + <SectionParam Name="Online Icon"> + <Value /> + <ValueType>String</ValueType> + <Description>The icon file of the package stored online (jpg,png,bmp)</Description> + </SectionParam> + <SectionParam Name="Configuration file"> + <Value /> + <ValueType>Template</ValueType> + <Description>The file used to configure the extension. + If have .exe extension the will be executed + If have .dll extension used like MP plugin configuration</Description> + </SectionParam> + <SectionParam Name="Online Screenshots"> + <Value /> + <ValueType>String</ValueType> + <Description>Online stored screenshot urls separated by ; </Description> + </SectionParam> + <SectionParam Name="Force to uninstall on update"> + <Value>yes</Value> + <ValueType>Bool</ValueType> + <Description>Show dialog and force to uninstall previous version when updating an extension. Should only be disabled if you are using an NSIS/MSI installer.</Description> + </SectionParam> + </Items> + </Params> + </GeneralInfo> + <UniqueFileList> + <Items /> + </UniqueFileList> + <ProjectSettings> + <FolderGroups /> + </ProjectSettings> + <IsSkin>false</IsSkin> + </PackageClass> </Items> </ExtensionCollection> Modified: trunk/plugins/VeraControl/skin/Default/VeraControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/Default/VeraControl.xml 2012-02-02 11:43:11 UTC (rev 4435) +++ trunk/plugins/VeraControl/skin/Default/VeraControl.xml 2012-02-02 20:07:07 UTC (rev 4436) @@ -47,6 +47,27 @@ <textcolor>90FFFFFF</textcolor> </control> + <control> + <type>image</type> + <id>32</id> + <posX>300</posX> + <posY>500</posY> + <width>20</width> + <height>20</height> + <texture></texture> + <visible>no</visible> + </control> + + <control> + <description>commment label</description> + <type>label</type> + <id>33</id> + <posX>320</posX> + <posY>500</posY> + <label>comment</label> + <font>font13</font> + <textcolor>90FFFFFF</textcolor> + </control> <control> Modified: trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml 2012-02-02 11:43:11 UTC (rev 4435) +++ trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml 2012-02-02 20:07:07 UTC (rev 4436) @@ -46,6 +46,28 @@ <font>font11</font> <textcolor>90FFFFFF</textcolor> </control> + + <control> + <type>image</type> + <id>32</id> + <posX>600</posX> + <posY>610</posY> + <width>30</width> + <height>30</height> + <texture></texture> + <visible>no</visible> + </control> + + <control> + <description>commment label</description> + <type>label</type> + <id>33</id> + <posX>640</posX> + <posY>610</posY> + <label>comment</label> + <font>font11</font> + <textcolor>90FFFFFF</textcolor> + </control> <control> <type>button</type> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Ba...@us...> - 2012-02-17 23:12:58
|
Revision: 4456 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4456&view=rev Author: BartEv Date: 2012-02-17 23:12:46 +0000 (Fri, 17 Feb 2012) Log Message: ----------- - Added multi box support - Added fallback to remote connectionType - Move scene trigger to side action menu - Added sort options - Added filter options - Add vie by category option Modified Paths: -------------- trunk/plugins/VeraControl/BaseDevice.cs trunk/plugins/VeraControl/DevCategories.cs trunk/plugins/VeraControl/DeviceCam.cs trunk/plugins/VeraControl/DeviceDimmer.cs trunk/plugins/VeraControl/DeviceDoorlock.cs trunk/plugins/VeraControl/DeviceGWeather.cs trunk/plugins/VeraControl/DeviceGeneric.cs trunk/plugins/VeraControl/DeviceHumidity.cs trunk/plugins/VeraControl/DeviceLightSensor.cs trunk/plugins/VeraControl/DevicePowerMeter.cs trunk/plugins/VeraControl/DeviceSceneController.cs trunk/plugins/VeraControl/DeviceSecurity.cs trunk/plugins/VeraControl/DeviceSprinkler.cs trunk/plugins/VeraControl/DeviceSwitch.cs trunk/plugins/VeraControl/DeviceSystem.cs trunk/plugins/VeraControl/DeviceTemperature.cs trunk/plugins/VeraControl/DeviceThermostat.cs trunk/plugins/VeraControl/DeviceWindowCovering.cs trunk/plugins/VeraControl/DialogActionTrigger.cs trunk/plugins/VeraControl/DialogDeviceControl.cs trunk/plugins/VeraControl/Room.cs trunk/plugins/VeraControl/Scene.cs trunk/plugins/VeraControl/Section.cs trunk/plugins/VeraControl/VeraCommunication.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/VeraControl.csproj trunk/plugins/VeraControl/VeraSetupForm.Designer.cs trunk/plugins/VeraControl/VeraSetupForm.cs trunk/plugins/VeraControl/skin/Default/VeraControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml Modified: trunk/plugins/VeraControl/BaseDevice.cs =================================================================== --- trunk/plugins/VeraControl/BaseDevice.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/BaseDevice.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -18,22 +18,23 @@ /// </summary> public class BaseDevice { - private long _lastUpdate = 0; - private long _lastPendingUpdate = 0; - private bool _screenUpdateRequired = false; - private string _name = "unknown device"; - private int _id = 0; - private int _room = 0; + private long _lastUpdate = 0; + private long _lastPendingUpdate = 0; + private bool _screenUpdateRequired = false; + private string _name = "unknown device"; + private int _id = 0; + private int _room = 0; // not connected (-2), none (-1), pending (0,1,5,6), success(4), error (2,3) - private DevState _dsState = DevState.NONE; - private string _comment = ""; // red(error), green(success) or blue(pending) - icon/text + private DevState _dsState = DevState.NONE; + private string _comment = ""; // red(error), green(success) or blue(pending) - icon/text - public VeraHelper _helper = VeraHelper.Instance; - public VeraCommunication _vera = VeraCommunication.Instance; + public VeraHelper _helper = VeraHelper.Instance; + public VeraBox _myVeraBox = null; - public BaseDevice(XmlNode xn) + public BaseDevice(XmlNode xn, int veraid) { + _myVeraBox = VeraCommunication.Instance.boxes[veraid]; if (xn != null) { Update(xn); @@ -49,7 +50,7 @@ _id = _helper.GetAttrAsInt (xn, "id", _id); _room = _helper.GetAttrAsInt (xn, "room", _room); _comment = _helper.GetAttrAsString(xn, "comment", _comment ); - _dsState = _helper.ToDevState(_helper.GetAttrAsInt(xn, "state", -1)); + _dsState = _helper.ToDevState (_helper.GetAttrAsInt(xn, "state", -1)); if (_id == 0) { @@ -57,6 +58,16 @@ return false; } + if (room == _myVeraBox.zeroId || !_myVeraBox.status.IsRoomFound(room)) + { + room = _myVeraBox.zeroId; + if (!_myVeraBox.status.IsRoomFound(room)) + { // create dummy room to attach to + _myVeraBox.rooms.Add(new Room(null, _myVeraBox.myId)); + _myVeraBox.rooms[_myVeraBox.rooms.Count - 1].section = _myVeraBox.rooms[0].section; + } + } + // Set update flag screenUpdateRequired = true; lastUpdate = DateTime.Now.Ticks; @@ -75,37 +86,69 @@ public int id { - get { return _id; } - set { } + get + { + if (_myVeraBox == null) + { + return 0; + } + return (VeraCommunication.IDMASK * _myVeraBox.myId) + _id; + } } + public int internalId + { + get { return _id; } + } + + /// <summary> + /// Unique id based on Vera's serial id, so wil also stand on vera config/id changes. Should be used when id is stored over MP session (like in config files) + /// </summary> + public long configChangeProofId + { + get + { + if (_myVeraBox == null) + { + return 0; + } + return (long)((long)VeraCommunication.IDMASK * (long)_myVeraBox.status.system.serialno) + (long)_id; + } + } + public string name { - get { return _name; } - set { } + get { return _name; } } public bool InRoom(int id) { - return (_room == id); + return (room == id); } public int room { - get { return _room; } - set { _room = value; } + get { + if (_myVeraBox == null) + { + return 0; + } + return _room + (VeraCommunication.IDMASK * _myVeraBox.myId); + } + set + { + _room = value % VeraCommunication.IDMASK; + } } public DevState commstate { get { return _dsState; } - set { } } public string comment { get { return (commstate != DevState.NONE ? _comment : ""); } - set { } } public bool screenUpdateRequired @@ -114,7 +157,7 @@ set { if (value) { // If at least one device report screen update required, Vera should take over this report - _vera.setScreenUpdateRequired(); + _myVeraBox.setScreenUpdateRequired(); } _screenUpdateRequired = value; } Modified: trunk/plugins/VeraControl/DevCategories.cs =================================================================== --- trunk/plugins/VeraControl/DevCategories.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DevCategories.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -4,8 +4,8 @@ * Date: 22-12-2011 * Time: 14:14 * - * Copyright: 2012 GPL - Bart Eversdijk - * MediaPort plugin - MicasaVerde (TM) Vera Controller + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller * E-mail: ba...@ev... */ using System; @@ -20,16 +20,28 @@ { public DevCategories(XmlNode xn) { - if (xn != null) + if (xn != null) { Update(xn); } } - private string _name = "unknown category"; - private int _id = 0; - public VeraHelper _helper = VeraHelper.Instance; + public DevCategories(int id) + { + _id = id; + } + public DevCategories(int id, string nm) + { + _id = id; + _name = nm; + } + + private string _name = "unknown category"; + private int _id = 0; + public VeraHelper _helper = VeraHelper.Instance; + + public bool Update(XmlNode xn) { _name = _helper.GetAttrAsString(xn, "name", _name); @@ -40,15 +52,90 @@ public int id { get { return _id; } - set { } } - + public string name { - get { return _name; } - set { } + get { return _name; } + set { _name = value; } } + + public string GetIconName() + { + switch (id) + { + case 1: // Interface + return "USB_UIRT"; + + case 2: // Dimmer + return "Dimmable_Light_100"; + + case 3: // Switch + return "Binary_Light_100"; + + case 4: // Generic Sensor + return "generic_sensor"; + + case 5: // Thermostat + return "Thermostat"; + + case 6: // Web Cam + return "Ip_Camera"; + + case 7: + return "Door_Lock_100"; + + case 8: // Window covering + return "Window_Covering"; + + case 9: // Remote control + case 10: // Ir TX + return "IR_Transmitter"; + + case 12: // Motion Sensor + return "Motion_Sensor_100"; + + case 11: // Generic IO + case 13: // Serial port + return "Generic_IO"; + + case 14: // Scene controller + return "Scenes_active"; + + case 15: // AV + return "music_audio"; + + case 16: // Humidity + return "Humidity_Sensor"; + + case 17: // Temperature + return "Temperature_Sensor"; + + case 18: // Light sensor + return "Light_Sensor"; + + case 19: // Z-wave + return "Zwave"; + + case 20: // Insteon + return "Insteon"; + + case 21: // Power meter + return "Power_Meter"; + + case 101: // Special Sprinkler device not support by Vera's UI + return "Sprinkler"; + + case 102: // Special (Google) Weather device not support by Vera's UI + return "location"; + + case 0: + default: + return "generic_sensor"; + } + } + public override string ToString() { return name; Modified: trunk/plugins/VeraControl/DeviceCam.cs =================================================================== --- trunk/plugins/VeraControl/DeviceCam.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceCam.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -24,7 +24,7 @@ private string _user = ""; private string _pass = ""; - public DeviceCam(XmlNode xn): base (xn) + public DeviceCam(XmlNode xn, int verabox): base (xn, verabox) { if (xn != null) { @@ -53,21 +53,18 @@ } return _user + ":" + _pass + "@"; } - set { } } public string imgUrl { - get { return _vera.veraAddress + "/data_request?id=cam_image¶meters=get_video_frame&Device_Num=" + id + "&rand=" + DateTime.Now.Ticks; + get { return _myVeraBox.veraAddress + "/data_request?id=cam_image¶meters=get_video_frame&Device_Num=" + internalId.ToString() + "&rand=" + DateTime.Now.Ticks; // return "http://" + passString + m_sIp + "/" + m_sUrl.Replace("%2F", "/"); } - set { } } public string streamUrl { get { return "http://" + passString + _ip + "/" + _stream.Replace("%2F", "/"); } - set { } } public int refreshRate @@ -84,14 +81,8 @@ public override bool isControllable { get { return true; } - set { } } - public override string GetIconName() - { - return "Ip_Camera"; - } - public override bool NewScreenUpdateWaitingAndClearFlag( ) { // Invoking this method will clear the update ready flag -> so caller need to handle the update @@ -119,12 +110,12 @@ { if (id == 0) { - _vera.status.system.ReportCommandError("Unknown device"); + _myVeraBox.status.system.ReportCommandError("Unknown device"); screenUpdateRequired = true; return; } - string cmd = "?id=lu_action&DeviceNum=" + id + "&serviceId=urn:micasaverde-com:serviceId:PanTiltZoom1&action=" + direction; - _vera.DoVeraCommandRequest(cmd, ReportRequestError); + string cmd = "?id=lu_action&DeviceNum=" + internalId + "&serviceId=urn:micasaverde-com:serviceId:PanTiltZoom1&action=" + direction; + _myVeraBox.DoVeraCommandRequest(cmd, ReportRequestError); } public override void MoveUp() Modified: trunk/plugins/VeraControl/DeviceDimmer.cs =================================================================== --- trunk/plugins/VeraControl/DeviceDimmer.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceDimmer.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -22,7 +22,7 @@ private string _watt = "-"; private string _kwh = "-"; - public DeviceDimmer(XmlNode xn): base (xn) + public DeviceDimmer(XmlNode xn, int verabox): base (xn, verabox) { if (xn != null) { @@ -42,7 +42,6 @@ public string watts { get { return _watt; } - set { } } public override bool status @@ -66,10 +65,10 @@ { ReportPendingRequest(); // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString() + + string cmd = "?id=lu_action&DeviceNum="+internalId.ToString() + "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget" + "&newLoadlevelTarget=" + value; - _vera.DoVeraCommandRequest(cmd, ReportRequestError); + _myVeraBox.DoVeraCommandRequest(cmd, ReportRequestError); } _level = newValue; } @@ -78,7 +77,6 @@ public override int maxLevel { get { return 100; } - set { } } public override string ToString() @@ -89,7 +87,6 @@ public override bool isControllable { get { return true; } - set { } } public override string GetIconName() @@ -105,12 +102,49 @@ public override string GetExtraText() { - return (_kwh != "" ? _kwh + "kWh" : ""); + return ((_kwh != "" && _kwh != "-") ? "Power usage " + _kwh + " kWh" : ""); } public override string GetStatusText() { return (status ? level.ToString() + "%" : "Off"); } + + public override string mode + { + get { + string strmode = "Off"; + if (level > 0) { strmode = "25%"; } + if (level > 25) { strmode = "50%"; } + if (level > 50) { strmode = "75%"; } + if (level > 75) { strmode = "0n"; } + return strmode; + } + set { + switch (value) + { + case "Off": + level = 0; + break; + case "25%": + level = 25; + break; + case "50%": + level = 50; + break; + case "75%": + level = 75; + break; + case "On": + level = 100; + break; + } + } + } + + public override string [] GetCommands() + { + return new string [] {"Off", "On", "25%", "75%", "50%"}; + } } } Modified: trunk/plugins/VeraControl/DeviceDoorlock.cs =================================================================== --- trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceDoorlock.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -20,7 +20,7 @@ { private bool _status = false; - public DeviceDoorlock( XmlNode xn ): base (xn) + public DeviceDoorlock( XmlNode xn, int verabox ): base (xn, verabox) { if (xn != null) { @@ -43,10 +43,10 @@ { ReportPendingRequest(); // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + string cmd = "?id=lu_action&DeviceNum="+internalId.ToString()+ "&serviceId=urn:micasaverde-com:serviceId:DoorLock1&action=SetTarget" + "&newTargetValue="+(value ? "1" : "0"); - _vera.DoVeraCommandRequest(cmd, ReportRequestError); + _myVeraBox.DoVeraCommandRequest(cmd, ReportRequestError); } } } @@ -63,7 +63,6 @@ public override int maxLevel { get { return 1; } - set { } } public override string ToString() @@ -74,7 +73,6 @@ public override bool isControllable { get { return true; } - set { } } public override string GetIconName() Modified: trunk/plugins/VeraControl/DeviceGWeather.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGWeather.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceGWeather.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -21,7 +21,7 @@ private string _condition = "-"; private string _windCondition = "-"; - public DeviceGWeather(XmlNode xn): base (xn) + public DeviceGWeather(XmlNode xn, int verabox): base (xn, verabox) { if (xn != null) { @@ -35,8 +35,15 @@ _condition = _helper.GetAttrAsString(xn, "condition", _condition); // World Weather plugin _windCondition = _helper.GetAttrAsString(xn, "WindCondition", _windCondition); _windCondition = _helper.GetAttrAsString(xn, "windcondition", _windCondition); + + bool ret = base.Update(xn); + category = 102; // Override Vera's Cateogry with Speical ID code - return base.Update(xn); + if (!_myVeraBox.status.IsCategoryFound(category)) + { // create this category if it does not exists + _myVeraBox.categories.Add(new DevCategories(category, "Weather")); + } + return ret; } public override string ToString() Modified: trunk/plugins/VeraControl/DeviceGeneric.cs =================================================================== --- trunk/plugins/VeraControl/DeviceGeneric.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceGeneric.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -10,6 +10,7 @@ */ using System; using System.Xml; +using System.Collections; using System.Collections.Generic; namespace VeraControl.Properties @@ -23,7 +24,7 @@ private int _category = 0; private int _stepsize = 0; - public DeviceGeneric(XmlNode xn): base (xn) + public DeviceGeneric(XmlNode xn, int verabox): base (xn, verabox) { if (xn != null) { @@ -40,33 +41,53 @@ _altId = _helper.GetAttrAsString(xn, "altid", _altId); _category = _helper.GetAttrAsInt (xn, "category", _category); - bool b = base.Update(xn); - // Make sure the room exists - if (room == 0 || !_vera.status.IsRoomFound(room)) + return base.Update(xn); + } + + public bool PassesFilter(VeraFilterStyle filter) + { + switch (filter) { - if (!_vera.status.IsRoomFound(0)) - { // create dummy room to attach to - _vera.rooms.Add(new Room(null)); - } - room = 0; + case VeraFilterStyle.UNKNOWN_DEVICES: + return isControllable|| !new ArrayList(new int [] {0}).Contains(category); + + case VeraFilterStyle.GENERIC_DEVICES: + return isControllable || !new ArrayList(new int [] {0,1,11,12}).Contains(category); + + case VeraFilterStyle.REMOTE_DEVICES: + return isControllable || !new ArrayList(new int [] {0,1,10,11,12,13,15,19,20}).Contains(category); + + case VeraFilterStyle.SCENE_CONTROLLERS: + return isControllable || !new ArrayList(new int [] {0,1,10,11,12,13,14,15,19,20}).Contains(category); + + case VeraFilterStyle.CONTROLABLE_ONLY: + return isControllable; + + default: + case VeraFilterStyle.NONE: + return true; } - return b; } - + public string altid { get { return _altId; } } - + + public bool InCategory(int id) + { + return (category == id); + } + public int category { get { return _category; } + set { _category = value; } } public virtual bool isControllable { get { return false; } - set { } } public virtual bool status @@ -92,7 +113,7 @@ if (stepSize > 0) { level += stepSize; - } + } } public virtual void DecreaseLevel() @@ -100,7 +121,7 @@ if (stepSize > 0) { level -= stepSize; - } + } } public virtual string mode @@ -123,7 +144,7 @@ public override string GetIconName() { - return "generic_sensor"; + return new DevCategories(category).GetIconName(); } public override string GetStatusText() Modified: trunk/plugins/VeraControl/DeviceHumidity.cs =================================================================== --- trunk/plugins/VeraControl/DeviceHumidity.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceHumidity.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -20,7 +20,7 @@ { private int _level = 0; - public DeviceHumidity(XmlNode xn) : base (xn) + public DeviceHumidity(XmlNode xn, int verabox) : base (xn, verabox) { if (xn != null) { @@ -37,13 +37,11 @@ public override int level { get { return _level; } - set {} } public override int maxLevel { get { return 100; } - set { } } public override string ToString() @@ -51,11 +49,6 @@ return name + " [" + level.ToString() + "%]"; } - public override string GetIconName() - { - return "Humidity_Sensor"; - } - public override string GetStatusText() { return level + "%"; Modified: trunk/plugins/VeraControl/DeviceLightSensor.cs =================================================================== --- trunk/plugins/VeraControl/DeviceLightSensor.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceLightSensor.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -20,7 +20,7 @@ { private int _level = 0; - public DeviceLightSensor(XmlNode xn) : base (xn) + public DeviceLightSensor(XmlNode xn, int verabox) : base (xn, verabox) { if (xn != null) { @@ -38,19 +38,16 @@ public override bool status { get { return (_level > 0); } - set { } } public override int level { get { return _level; } - set { } } public override int maxLevel { get { return 100; } - set { } } public override string ToString() Modified: trunk/plugins/VeraControl/DevicePowerMeter.cs =================================================================== --- trunk/plugins/VeraControl/DevicePowerMeter.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DevicePowerMeter.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -21,7 +21,7 @@ private int _level = 0; private string _kwh = ""; - public DevicePowerMeter(XmlNode xn) : base (xn) + public DevicePowerMeter(XmlNode xn, int verabox) : base (xn, verabox) { if (xn != null) { @@ -39,25 +39,21 @@ public string watts { get { return _level.ToString(); } - set { } } public override bool status { get { return (_level > 0); } - set { } } public override int level { get { return _level; } - set { } } public override int maxLevel { get { return 1000; } - set { } } public override string ToString() @@ -65,14 +61,9 @@ return name + " [" + GetStatusText() + "]"; } - public override string GetIconName() - { - return "Power_Meter"; - } - public override string GetExtraText() { - return (_kwh != "" ? _kwh + "kWh" : ""); + return ((_kwh != "" && _kwh != "-") ? "Power usage " + _kwh + " kWh" : ""); } public override string GetStatusText() Modified: trunk/plugins/VeraControl/DeviceSceneController.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSceneController.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceSceneController.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -18,7 +18,7 @@ { private bool _isTripped = false; - public DeviceSceneController( XmlNode xn ) : base (xn) + public DeviceSceneController( XmlNode xn, int verabox ) : base (xn, verabox) { if (xn != null) { @@ -36,19 +36,16 @@ public override bool status { get { return _isTripped; } - set { } } public bool isTripped { get { return _isTripped; } - set { } } public override int level { get { return (_isTripped ? 1 : 0); } - set { } } public override string ToString() @@ -58,7 +55,7 @@ public override string GetIconName() { - return "Motion_Sensor_" + (_isTripped ? "100" : "0"); + return "Scenes" + (_isTripped ? "_active" : ""); } public override string GetStatusText() Modified: trunk/plugins/VeraControl/DeviceSecurity.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSecurity.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceSecurity.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -22,7 +22,7 @@ private bool _isTripped = false; private bool _isArmed = true; - public DeviceSecurity(XmlNode xn) : base (xn) + public DeviceSecurity(XmlNode xn, int verabox) : base (xn, verabox) { if (xn != null) { @@ -45,10 +45,10 @@ { ReportPendingRequest(); // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + string cmd = "?id=lu_action&DeviceNum=" + internalId.ToString() + "&serviceId=urn:micasaverde-com:serviceId:SecuritySensor1&action=SetArmed" + "&newArmedValue=" + (value ? "1" : "0"); - _vera.DoVeraCommandRequest(cmd, ReportRequestError); + _myVeraBox.DoVeraCommandRequest(cmd, ReportRequestError); } } } @@ -56,7 +56,6 @@ public bool isTripped { get { return _isTripped; } - set { } } public override int level @@ -68,13 +67,11 @@ public override int maxLevel { get { return 1; } - set { } } public override bool isControllable { get { return true; } - set { } } public override string ToString() Modified: trunk/plugins/VeraControl/DeviceSprinkler.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -4,8 +4,8 @@ * Date: 3-1-2012 * Time: 16:26 * - * Copyright: 2012 GPL - Bart Eversdijk - * MediaPort plugin - MicasaVerde (TM) Vera Controller + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller * E-mail: ba...@ev... */ using System; @@ -25,7 +25,7 @@ private string _operationMode = "-"; private string _condition = "-"; - public DeviceSprinkler(XmlNode xn) : base (xn) + public DeviceSprinkler(XmlNode xn, int verabox) : base (xn, verabox) { if (xn != null) { @@ -33,29 +33,39 @@ } } - public override bool Update(XmlNode xn) + public override bool Update(XmlNode xn) { _status = _helper.GetAttrAsBool (xn, "status", _status); _mode = _helper.GetAttrAsString(xn, "Mode", _mode); _shortMode = _helper.GetAttrAsString(xn, "ShortMode", _shortMode); _operationMode = _helper.GetAttrAsString(xn, "OperationMode", _operationMode); _condition = _helper.GetAttrAsString(xn, "Condition", _condition); - return base.Update(xn); + + bool ret = base.Update(xn); + category = 101; // Override Vera's Cateogry with Speical ID code + + if (!_myVeraBox.status.IsCategoryFound(category)) + { + // create this category if it does not exists + _myVeraBox.categories.Add(new DevCategories(category, "Sprinklers")); + } + + return ret; } public override bool status { get { return _status; } - set { - if (id > 0) // Only send when a valid ID is found - { - ReportPendingRequest(); - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + - "&newTargetValue="+(value ? "1" : "0"); - _vera.DoVeraCommandRequest(cmd, ReportRequestError); - } + set { + if (id > 0) // Only send when a valid ID is found + { + ReportPendingRequest(); + // Do something with vera + string cmd = "?id=lu_action&DeviceNum=" + internalId.ToString() + + "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + + "&newTargetValue="+(value ? "1" : "0"); + _myVeraBox.DoVeraCommandRequest(cmd, ReportRequestError); + } } } @@ -68,16 +78,16 @@ public override string mode { get { return _mode; } - set { - if (id > 0) // Only send when a valid ID is found - { - ReportPendingRequest(); - // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ - "&serviceId=urn:upnp-micasaverde-com:serviceId:Sprinkler1&action=" + - (value == "Auto" ? "SetModeAuto" : (value == "Block" ? "SetModeBlock" : "SetModeManual")); - _vera.DoVeraCommandRequest(cmd, ReportRequestError); - } + set { + if (id > 0) // Only send when a valid ID is found + { + ReportPendingRequest(); + // Do something with vera + string cmd = "?id=lu_action&DeviceNum=" + internalId.ToString() + + "&serviceId=urn:upnp-micasaverde-com:serviceId:Sprinkler1&action=" + + (value == "Auto" ? "SetModeAuto" : (value == "Block" ? "SetModeBlock" : "SetModeManual")); + _myVeraBox.DoVeraCommandRequest(cmd, ReportRequestError); + } } } @@ -89,19 +99,12 @@ public override bool isControllable { get { return true; } - set { } } public override int maxLevel { get { return 1; } - set { } } - - public override string GetIconName() - { - return "Sprinkler"; - } public override string GetStatusText() { Modified: trunk/plugins/VeraControl/DeviceSwitch.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSwitch.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceSwitch.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -22,7 +22,7 @@ private string _watt = "-"; private string _kwh = "-"; - public DeviceSwitch(XmlNode xn) : base (xn) + public DeviceSwitch(XmlNode xn, int verabox) : base (xn, verabox) { if (xn != null) { @@ -42,7 +42,6 @@ public string watts { get { return _watt; } - set { } } public override bool status @@ -53,10 +52,10 @@ { ReportPendingRequest(); // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + string cmd = "?id=lu_action&DeviceNum=" + internalId.ToString() + "&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget" + "&newTargetValue="+(value ? "1" : "0"); - _vera.DoVeraCommandRequest(cmd, ReportRequestError); + _myVeraBox.DoVeraCommandRequest(cmd, ReportRequestError); } } } @@ -70,7 +69,6 @@ public override int maxLevel { get { return 1; } - set { } } public override string ToString() @@ -81,7 +79,6 @@ public override bool isControllable { get { return true; } - set { } } public override string GetIconName() @@ -91,7 +88,7 @@ public override string GetExtraText() { - return (_kwh != "" ? _kwh + "kWh" : ""); + return ((_kwh != "" && _kwh != "-") ? "Power usage " + _kwh + " kWh" : ""); } public override string GetStatusText() Modified: trunk/plugins/VeraControl/DeviceSystem.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSystem.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceSystem.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -26,12 +26,12 @@ public long _lastUpdate = 0; public bool _screenUpdateRequired = false; private bool _fullReload = true; - private string _version = ""; + private string _version = "-"; private string _model = ""; private bool _zWaveHeal = false; private bool _metric = true; - private string _serial = ""; - private string _fwd1Server = ""; + private int _serial = -1; + private string _fwd1Server = "-"; private string _fwd2Server = ""; private string _loadTime = "0"; private string _dataVersion = "0"; @@ -43,22 +43,22 @@ { _fullReload = _helper.GetAttrAsBool (xn, "full", _fullReload); _version = _helper.GetAttrAsString(xn, "version", _version); + _serial = _helper.GetAttrAsInt (xn, "serial_number", _serial); _model = _helper.GetAttrAsString(xn, "model", _model); _zWaveHeal = _helper.GetAttrAsBool (xn, "zwave_heal", _zWaveHeal); - _serial = _helper.GetAttrAsString(xn, "serial_number", _serial); _fwd1Server = _helper.GetAttrAsString(xn, "fwd1", _fwd1Server); _fwd2Server = _helper.GetAttrAsString(xn, "fwd2", _fwd2Server); _loadTime = _helper.GetAttrAsString(xn, "loadtime", _loadTime); // Set update flag - string tempDataversion = _helper.GetAttrAsString (xn, "dataversion", _dataVersion); - DevState tempVeraState = _helper.ToDevState(_helper.GetAttrAsInt(xn, "state", -1)); - string tempComment = _helper.GetAttrAsString (xn, "comment", ""); + string tempDataversion = _helper.GetAttrAsString (xn, "dataversion", _dataVersion); + DevState tempVeraState = _helper.ToDevState(_helper.GetAttrAsInt(xn, "state", -1)); + string tempComment = _helper.GetAttrAsString (xn, "comment", ""); if ((_dataVersion != tempDataversion) || _comment != tempComment || _dsVeraState != tempVeraState) { _screenUpdateRequired = true; - _lastUpdate = DateTime.Now.Ticks; + _lastUpdate = DateTime.Now.Ticks; } _dataVersion = tempDataversion; _dsVeraState = tempVeraState; @@ -91,61 +91,51 @@ public bool fullReload { get { return _fullReload; } - set { } } public string versionInfo { get { return _model + " " + _version; } - set { } } public bool zWaveHeal { get { return _zWaveHeal; } - set { } } - public string serialno + public int serialno { get { return _serial; } - set { } } public string fwd { get { return _fwd1Server; } - set { } } public string fwdBackup { get { return _fwd2Server; } - set { } } public string loadtime { get { return _loadTime; } - set { } } public string dataversion { get { return _dataVersion; } - set { } } public DevState state { - get { return _dsVeraState; } - set { } + get { return (serialno == -1 ? DevState.CONNECTION_ERROR :_dsVeraState); } } public string comment { - get { return _comment; } - set { } + get { return (serialno == -1 ? "Unable to connect" : _comment); } } public void ReportConnectionError(string errmsg) Modified: trunk/plugins/VeraControl/DeviceTemperature.cs =================================================================== --- trunk/plugins/VeraControl/DeviceTemperature.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceTemperature.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -21,7 +21,7 @@ public string _temperature = "0"; // public thermostat class private bool _metric = true; - public DeviceTemperature(XmlNode xn, bool metric) : base (xn) + public DeviceTemperature(XmlNode xn, int verabox, bool metric) : base (xn, verabox) { _metric = metric; if (xn != null) @@ -39,31 +39,23 @@ public override int level { get { return int.Parse(_temperature); } - set { } } public override int maxLevel { get { return (_metric ? 100 : 212); } - set { } } public override int minLevel { get { return (_metric ? -22 : -7); } - set { } } public override string ToString() { return name + " [" + GetStatusText() + "]"; } - - public override string GetIconName() - { - return "Temperature_Sensor"; - } - + public override string GetStatusText() { return _temperature + (_metric ? "°C" : "°F"); Modified: trunk/plugins/VeraControl/DeviceThermostat.cs =================================================================== --- trunk/plugins/VeraControl/DeviceThermostat.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceThermostat.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -24,7 +24,7 @@ private string _mode = "Off"; // "Off', "InDeadBand", "HeatOn", "CoolOn", "AutoChangeOver", "AuxHeatOn", "EconomyHeatOn", "EmergencyHeatOn", // "AuxCoolOn", "EconomyCoolOn", "BuildingProtection", "EnergySavingsHeating", "EnergySavingsCooling" - public DeviceThermostat(XmlNode xn, bool metric) : base (xn, metric) + public DeviceThermostat(XmlNode xn, int verabox, bool metric) : base (xn, verabox, metric) { _metric = metric; if (xn != null) @@ -51,7 +51,6 @@ public override int level { get { return -1; } - set { } } public override string mode @@ -62,11 +61,11 @@ { ReportPendingRequest(); // Do something with vera - string cmd = "?id=lu_action&DeviceNum="+id.ToString()+ + string cmd = "?id=lu_action&DeviceNum=" + internalId.ToString( )+ "&serviceId=urn:upnp-org:serviceId:HVAC_UserOperatingMode1&action=SetModeTarget" + - "&NewModeTarget="+(value == "Off" ? "Off" : (value == "Cool" ? "CoolOn" : (value == "Heat" ? "HeatOn" : "AutoChangeOver")) + "&NewModeTarget=" + (value == "Off" ? "Off" : (value == "Cool" ? "CoolOn" : (value == "Heat" ? "HeatOn" : "AutoChangeOver")) ); - _vera.DoVeraCommandRequest(cmd, ReportRequestError); + _myVeraBox.DoVeraCommandRequest(cmd, ReportRequestError); } } } @@ -79,13 +78,11 @@ public override bool isControllable { get { return true; } - set { } } public override int maxLevel { get { return -1; } - set { } } public override string GetStatusText() @@ -97,12 +94,7 @@ { return _hvacState + " - Fan : " + _fanMode + " - " + _temperature + (_metric ? "°C" : "°F") ; } - - public override string GetIconName() - { - return "Thermostat"; - } - + public override string [] GetCommands() { return new string [] {"Off", "On", "Auto", "Heat", "Cool"}; Modified: trunk/plugins/VeraControl/DeviceWindowCovering.cs =================================================================== --- trunk/plugins/VeraControl/DeviceWindowCovering.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DeviceWindowCovering.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -18,17 +18,12 @@ /// </summary> public class DeviceWindowCovering : DeviceDimmer { - public DeviceWindowCovering(XmlNode xn) : base (xn) + public DeviceWindowCovering(XmlNode xn, int verabox) : base (xn, verabox) { if (xn != null) { Update(xn); } } - - public override string GetIconName() - { - return "Window_Covering"; - } } } Modified: trunk/plugins/VeraControl/DialogActionTrigger.cs =================================================================== --- trunk/plugins/VeraControl/DialogActionTrigger.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DialogActionTrigger.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -116,7 +116,7 @@ base.OnClicked(controlId, control, actionType); } - private void InitSpinButtons(GUISpinButton spin, int selectedScene) + private void InitSpinButtons(GUISpinButton spin, long selectedScene) { GUIControl.ClearControl(GetID, spin.GetID); int iSceneIndex = 0; @@ -124,8 +124,8 @@ for (int i = 0; i < _vera.scenes.Count; i++) { - spin.AddSpinLabel(shortString(_vera.scenes[i].name), _vera.scenes[i].id); - if (_vera.scenes[i].id == selectedScene) + spin.AddSpinLabel(shortString(_vera.scenes[i].name), i + 1); + if (_vera.scenes[i].configChangeProofId == selectedScene) { iSceneIndex = i + 1; // 0 is - none - } @@ -160,7 +160,7 @@ if (spinList[i].SpinValue == 0) { _vera.actionTriggerTable[i] = 0; } else { - _vera.actionTriggerTable[i] = _vera.scenes[spinList[i].SpinValue - 1].id; + _vera.actionTriggerTable[i] = _vera.scenes[spinList[i].SpinValue - 1].configChangeProofId; } xmlwritter.SetValue("veracontroller", ((Actiontrigger) i).ToString(), _vera.actionTriggerTable[i].ToString()); } Modified: trunk/plugins/VeraControl/DialogDeviceControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/DialogDeviceControl.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -135,26 +135,33 @@ if (_myDev.isControllable) { if (_myDev.GetType() == typeof(DeviceSprinkler)) - { + { // Special Sprinkler device SetText(_myDev.name, _myDev.GetStatusText() + " - " + _myDev.mode, _myDev.GetExtraText() ); SetActiveBut((_myDev.status ? 1 : 0), (_myDev.mode == "Auto" ? 0 : (_myDev.mode == "Block" ? 2 : 1) )); } else if (_myDev.GetType() == typeof(DeviceThermostat)) - { + { // Thermostat device SetText(_myDev.name, _myDev.GetStatusText(), _myDev.GetExtraText() ); SetActiveBut((_myDev.status ? 1 : 0), (_myDev.mode == "Auto" ? 0 : (_myDev.mode == "CoolOn" || _myDev.mode == "Cool" ? 1 : (_myDev.mode == "HeatOn" || _myDev.mode == "Heat" ? 2 : 3) ))); } + else if (_myDev.GetType() == typeof(DeviceDimmer)) + { // Dimmer device + SetText(_myDev.name, "Dim level: " + _myDev.GetStatusText(), _myDev.GetExtraText() ); + SetActiveBut((_myDev.mode == "Off" ? 0 : (_myDev.mode == "On" ? 1 : 2)), + (_myDev.mode == "25%" ? 0 : (_myDev.mode == "50%" ? 1 : (_myDev.mode == "75%" ? 2 : 3) ))); + } else if (_myDev.GetType() == typeof(DeviceCam)) - { + { // WebCam device SetText(_myDev.name, _myDev.GetStatusText(), _myDev.GetExtraText()); } else - { + { // Rest of the devices SetText(_myDev.name, "", ""); SetActiveBut(_myDev.status ? 1 : 0, -1); } + // No slider or status buttons for a cam-device if (_myDev.GetType() != typeof(DeviceCam)) { @@ -169,6 +176,7 @@ { SetText(_myDev.name, _myDev.GetStatusText(), _myDev.GetExtraText()); } + // save last update ticks _lastUpdate = DateTime.Now.Ticks; } @@ -316,7 +324,7 @@ public int camUpdateDelay { - get { return _camUpdateDelay; } + get { return _camUpdateDelay; } set { _camUpdateDelay = value; } } Modified: trunk/plugins/VeraControl/Room.cs =================================================================== --- trunk/plugins/VeraControl/Room.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/Room.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -4,8 +4,8 @@ * Date: 22-12-2011 * Time: 14:05 * - * Copyright: 2012 GPL - Bart Eversdijk - * MediaPort plugin - MicasaVerde (TM) Vera Controller + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller * E-mail: ba...@ev... */ using System; @@ -18,18 +18,19 @@ /// </summary> public class Room { - public Room(XmlNode xn) + public Room(XmlNode xn, int veraid) { + _myVeraBox = VeraCommunication.Instance.boxes[veraid]; if (xn != null) { Update(xn); } } - public VeraHelper _helper = VeraHelper.Instance; - public VeraCommunication _vera = VeraCommunication.Instance; + public VeraHelper _helper = VeraHelper.Instance; + public VeraBox _myVeraBox; - private string _name = "unknown room"; + private string _name = "unassigned"; private int _id = 0; private int _section = 0; @@ -44,14 +45,15 @@ // void room no further processing needed return true; } + // Make sure room exists - if (_section == 0 || !_vera.status.IsSectionFound(_section)) + if (section == _myVeraBox.zeroId || !_myVeraBox.status.IsSectionFound(section)) { - if (!_vera.status.IsSectionFound(0)) + section = _myVeraBox.zeroId; + if (!_myVeraBox.status.IsSectionFound(section)) { // create dummy room to attach to - _vera.sections.Add(new Section(null)); + _myVeraBox.sections.Add(new Section(null, _myVeraBox.myId)); } - _section = 0; } return true; @@ -59,20 +61,38 @@ public int id { + get { + if (_myVeraBox == null) + { + return 0; + } + return _id + (VeraCommunication.IDMASK * _myVeraBox.myId); + } + } + + public int internalId + { get { return _id; } - set { } } - + public string name { - get { return _name; } - set { } + get { return _name; } } public int section { - get { return _section; } - set { } + get { + if (_myVeraBox == null) + { + return 0; + } + return _section + (VeraCommunication.IDMASK * _myVeraBox.myId); + } + set + { + _section = (value % VeraCommunication.IDMASK); + } } public override string ToString() Modified: trunk/plugins/VeraControl/Scene.cs =================================================================== --- trunk/plugins/VeraControl/Scene.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/Scene.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -19,8 +19,9 @@ /// </summary> public class Scene : BaseDevice { - public Scene(XmlNode xn) : base (xn) + public Scene(XmlNode xn, int verabox) : base (xn, verabox) { + _myVeraBox = VeraCommunication.Instance.boxes[verabox]; if (xn != null) { Update(xn); @@ -32,14 +33,7 @@ public override bool Update(XmlNode xn) { _active = _helper.GetAttrAsBool(xn, "active", _active); - bool b = base.Update(xn); - - // Make sure the room exists or else make it 0 - if (room != 0 && !_vera.status.IsRoomFound(room)) - { - room = 0; - } - return b; + return base.Update(xn); } public override string GetIconName() @@ -49,7 +43,7 @@ public override string GetStatusText() { - return (room == 0 ? "" : _vera.status.GetRoomById(room).name); + return (room == _myVeraBox.zeroId ? "" : _myVeraBox.status.GetRoomById(room).name); } public bool IsActive() @@ -61,13 +55,13 @@ { if (id == 0) { - _vera.status.system.ReportCommandError("Unknown scene"); + _myVeraBox.status.system.ReportCommandError("Unknown scene"); screenUpdateRequired = true; return; } ReportPendingRequest(); string cmd = "?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum="+id; - _vera.DoVeraCommandRequest(cmd, ReportRequestError); + _myVeraBox.DoVeraCommandRequest(cmd, ReportRequestError); } } } Modified: trunk/plugins/VeraControl/Section.cs =================================================================== --- trunk/plugins/VeraControl/Section.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/Section.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -4,8 +4,8 @@ * Date: 23-12-2011 * Time: 21:05 * - * Copyright: 2012 GPL - Bart Eversdijk - * MediaPort plugin - MicasaVerde (TM) Vera Controller + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller * E-mail: ba...@ev... */ using System; @@ -18,8 +18,9 @@ /// </summary> public class Section { - public Section(XmlNode xn) + public Section(XmlNode xn, int verabox) { + _myVeraBox = VeraCommunication.Instance.boxes[verabox]; if (xn != null) { Update(xn); @@ -28,8 +29,9 @@ public VeraHelper _helper = VeraHelper.Instance; - private string _name = "unknown section"; - private int _id = 0; + private string _name = ""; + private int _id = 0; + public VeraBox _myVeraBox = null; public bool Update(XmlNode xn) { @@ -40,16 +42,44 @@ public int id { + get { + if (_myVeraBox == null) + { + return 0; + } + return (VeraCommunication.IDMASK * _myVeraBox.myId) + _id; + } + } + + public int _internalId + { get { return _id; } - set { } } - + public string name { - get { return _name; } - set { } + get + { + if (_myVeraBox == null) + { + return (_name == "" ? "unknown section" : _name); + } + return (_name == "" ? _myVeraBox.name : _name); + } } + public string longName + { + get + { + if (_myVeraBox == null) + { + return _name; + } + return ((_myVeraBox.name != "" && _myVeraBox.name != "-") ? _myVeraBox.name + " : " : "") + _name; + } + } + public override string ToString() { return name; Modified: trunk/plugins/VeraControl/VeraCommunication.cs =================================================================== --- trunk/plugins/VeraControl/VeraCommunication.cs 2012-02-17 15:42:33 UTC (rev 4455) +++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-02-17 23:12:46 UTC (rev 4456) @@ -17,684 +17,575 @@ namespace VeraControl.Properties { + public enum VeraSortStyle + { + NO = 0, + ROOMS_ONLY_ASORT, + ROOMS_ONLY_DSORT, + GROUP_BOXES_ASORT, + GROUP_BOXES_DSORT, + + LAST + }; + + public class SortItem + { + public SortItem(VeraSortStyle sort, string t, string s) + { + option = sort; + fulltext = t; + shorttext = s; + } + public VeraSortStyle option; + public string fulltext; + public string shorttext; + } + + public enum VeraFilterStyle + { + NONE = 0, + UNKNOWN_DEVICES, + GENERIC_DEVICES, + REMOTE_DEVICES, + SCENE_CONTROLLERS, + CONTROLABLE_ONLY, + + LAST + }; + + public class FilterItem + { + public FilterItem(VeraFilterStyle f, string t, string s) + { + option = f; + fulltext = t; + shorttext = s; + } + public VeraFilterStyle option; + public string fulltext; + public string shorttext; + } + + /// <summary> /// Description of VeraCommunication. /// </summary> - public class VeraStatus + public sealed class VeraCommunication { - public DeviceSystem system = new DeviceSystem(); - public List<DeviceGeneric> devices = new List<DeviceGeneric>(); - public List<Scene> scenes = new List<Scene>(); - public List<Room> rooms = new List<Room>(); - public List<DevCategories> categories = new List<DevCategories>(); - public List<Section> sections = new List<Section>(); + private static volatile VeraCommunication _instance; + private static object _syncRoot = new Object(); + private VeraHelper _helper = VeraHelper.Instance; - #region Vers get by id support functions - - public void ClearAllLists() + // Config data + private int _numOfBoxes = 1; + public VeraBox [] boxes; + + public const int IDMASK = 0xFFFF; + public const int ALL = Int32.MaxValue; + + // Action control table + public long [] actionTriggerTable = new long[(int)Actiontrigger.LAST_ACTIONTRIGGER]; + + public static VeraCommunication Instance { - devices.Clear(); - scenes.Clear(); - rooms.Clear(); - categories.Clear(); - sections.Clear(); - } - public Room GetRoomById(int id) - { - foreach(Room room in rooms) + get { - if (room.id == id) + if (_instance == null) { - return room; + lock (_syncRoot) + { + if (_instance == null) + { + _instance = new VeraCommunication(); + + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) + { + int maxRefreshDelay = xmlreader.GetValueAsInt("veracontroller", "maxrefreshdelay", 60); + _instance._numOfBoxes = xmlreader.GetValueAsInt("veracontroller", "NumOfBoxes", -1); + bool oldStyleConfig = (_instance._numOfBoxes == -1); + if (oldStyleConfig) + { + _instance._numOfBoxes = 1; + _instance.boxes = new VeraBox[1]; + _instance.boxes[0] = new VeraBox(0, maxRefreshDelay, 1000); + _instance.boxes[0]._oldStyleConfig = true; + } + else + { + _instance.boxes = new VeraBox[_instance._numOfBoxes]; + for (int i = 0; i < _instance._numOfBoxes; i++) + { + _instance.boxes[i] = new VeraBox(i, maxRefreshDelay, 1000); + } + } + + for (Actiontrigger i = 0; i < Actiontrigger.LAST_ACTIONTRIGGER; i++) + { + _instance.actionTriggerTable[(int)i] = long.Parse(xmlreader.GetValueAsString("veracontroller", i.ToString(), "0")); + } + } + } + } } + + return _instance; } - return new Room(null); } - public Section GetSectionById(int id) + private VeraCommunication() { - foreach(Section section in sections) - { - if (section.id == id) - { - return section; - } - } - return new Section(null); } - public DeviceGeneric GetDeviceById(int id) + public bool IsVeraAlive(string ip, string port) { - foreach(DeviceGeneric dev in devices) - { - if (dev.id == id) - { - return dev; - } - } - return new DeviceGeneric(null); + string response = RetrieveURL("http://" + ip + ":" + port + "/data_request?id=lu_alive&time=" + DateTime.Now.Ticks); + return (response == "OK"); } - public Scene GetSceneById(int id) + private string RetrieveURL(string url) { - foreach(Scene scene in scenes) + // No callback thus Synchronised call (wait for response) + try { + WebClient wc = new WebClient(); + wc.CancelAsync(); // Cancel any current pending Async calls... + return wc.DownloadString(url); + } catch( Exception ) { - if (scene.id == id) - { - return scene; - } + return "ERROR"; } - return new Scene(null); } - public DevCategories GetCategoryById(int id) + public int numOfBoxes { - foreach(DevCategories cat in categories) - { - if (cat.id == id) - { - return cat; - } - } - return new DevCategories(null); + get { return _numOfBoxes; } } - public bool IsSectionFound(int id) + public int BoxId(long id) { - foreach(Section section in sections) - { - if (section.id == id) - { - return true; - } - } - return false; + return (int)(id / IDMASK); } - public bool IsRoomFound(int id) + public int DeviceId(long id) { - foreach(Room room in rooms) + return (int)(id % IDMASK); + } + + public void UpdateStatusOfAllBoxes() + { + for (int i = 0; i < numOfBoxes; i++) { - if (room.id == id) - { - return true; - } + boxes[i].UpdateCurrentStatus(); } - return false; } - public bool IsDeviceFound(int id) + public bool IsABoxPendingUnpdate() { - foreach(DeviceGeneric dev in devices) + for (int i = 0; i < numOfBoxes; i++) { - if (dev.id == id) + if (boxes[i].updatePending) { return true; } } return false; } + + public Room GetRoomById(int id) + { + return boxes[BoxId(id)].status.GetRoomById(id); + } + + public Section GetSectionById(int id) + { + return boxes[BoxId(id)].status.GetSectionById(id); + } + + public DeviceGeneric GetDeviceById(int id) + { + return boxes[BoxId(id)].status.GetDeviceById(id); + } - public bool IsSceneFound(int id) + public Scene GetSceneById(int id) { - foreach(Scene scene in scenes) + return boxes[BoxId(id)].status.GetSceneById(id); + } + + public Scene GetSceneByConfigProofId(long id) + { + for (int i = 0; i < numOfBoxes; i++) { - if (scene.id == id) + if (boxes[i].status.system.serialno == BoxId(id)) { - return true; + return boxes[i].status.GetSceneById(boxes[i].makeId((int)(id % IDMASK))) ; } } - return false; + return new Scene(null, 0); } - public bool IsCategoryFound(int id) + public DevCategorie... [truncated message content] |
From: <Ba...@us...> - 2012-02-19 22:21:53
|
Revision: 4457 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4457&view=rev Author: BartEv Date: 2012-02-19 22:21:45 +0000 (Sun, 19 Feb 2012) Log Message: ----------- Modified Paths: -------------- trunk/plugins/VeraControl/BaseDevice.cs trunk/plugins/VeraControl/DevCategories.cs trunk/plugins/VeraControl/DeviceDimmer.cs trunk/plugins/VeraControl/DeviceSecurity.cs trunk/plugins/VeraControl/DeviceThermostat.cs trunk/plugins/VeraControl/DeviceWindowCovering.cs trunk/plugins/VeraControl/Properties/AssemblyInfo.cs trunk/plugins/VeraControl/Room.cs trunk/plugins/VeraControl/Section.cs trunk/plugins/VeraControl/VeraCommunication.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/VeraSetupForm.Designer.cs trunk/plugins/VeraControl/VeraSetupForm.cs trunk/plugins/VeraControl/releases/VeraControl.xmp2 trunk/plugins/VeraControl/skin/Default/VeraControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml trunk/plugins/VeraControl/skin/Media/Vera/Window_Covering.png trunk/plugins/VeraControl/skin/Media/Vera/music_audio.png Added Paths: ----------- trunk/plugins/VeraControl/VeraBox.cs trunk/plugins/VeraControl/skin/Media/Vera/Motion_Sensor_bypass.png trunk/plugins/VeraControl/skin/Media/Vera/Window_Covering_0.png trunk/plugins/VeraControl/skin/Media/Vera/Window_Covering_100.png trunk/plugins/VeraControl/skin/Media/Vera/Window_Covering_25.png trunk/plugins/VeraControl/skin/Media/Vera/Window_Covering_50.png trunk/plugins/VeraControl/skin/Media/Vera/Window_Covering_75.png trunk/plugins/VeraControl/skin/Media/Vera/back.png trunk/plugins/VeraControl/skin/Media/Vera/room.png Modified: trunk/plugins/VeraControl/BaseDevice.cs =================================================================== --- trunk/plugins/VeraControl/BaseDevice.cs 2012-02-17 23:12:46 UTC (rev 4456) +++ trunk/plugins/VeraControl/BaseDevice.cs 2012-02-19 22:21:45 UTC (rev 4457) @@ -49,7 +49,7 @@ _name = _helper.GetAttrAsString(xn, "name", _name); _id = _helper.GetAttrAsInt (xn, "id", _id); _room = _helper.GetAttrAsInt (xn, "room", _room); - _comment = _helper.GetAttrAsString(xn, "comment", _comment ); + _comment = _helper.GetAttrAsString(xn, "comment", _comment ); _dsState = _helper.ToDevState (_helper.GetAttrAsInt(xn, "state", -1)); if (_id == 0) Modified: trunk/plugins/VeraControl/DevCategories.cs =================================================================== --- trunk/plugins/VeraControl/DevCategories.cs 2012-02-17 23:12:46 UTC (rev 4456) +++ trunk/plugins/VeraControl/DevCategories.cs 2012-02-19 22:21:45 UTC (rev 4457) @@ -37,7 +37,7 @@ _name = nm; } - private string _name = "unknown category"; + private string _name = "Generic"; private int _id = 0; public VeraHelper _helper = VeraHelper.Instance; @@ -74,8 +74,8 @@ case 3: // Switch return "Binary_Light_100"; - case 4: // Generic Sensor - return "generic_sensor"; + case 4: // Security Sensor + return "Motion_Sensor_100"; case 5: // Thermostat return "Thermostat"; @@ -93,8 +93,8 @@ case 10: // Ir TX return "IR_Transmitter"; - case 12: // Motion Sensor - return "Motion_Sensor_100"; + case 12: // Generic Sensor + return "generic_sensor"; case 11: // Generic IO case 13: // Serial port Modified: trunk/plugins/VeraControl/DeviceDimmer.cs =================================================================== --- trunk/plugins/VeraControl/DeviceDimmer.cs 2012-02-17 23:12:46 UTC (rev 4456) +++ trunk/plugins/VeraControl/DeviceDimmer.cs 2012-02-19 22:21:45 UTC (rev 4457) @@ -117,7 +117,7 @@ if (level > 0) { strmode = "25%"; } if (level > 25) { strmode = "50%"; } if (level > 50) { strmode = "75%"; } - if (level > 75) { strmode = "0n"; } + if (level > 75) { strmode = "On"; } return strmode; } set { Modified: trunk/plugins/VeraControl/DeviceSecurity.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSecurity.cs 2012-02-17 23:12:46 UTC (rev 4456) +++ trunk/plugins/VeraControl/DeviceSecurity.cs 2012-02-19 22:21:45 UTC (rev 4457) @@ -81,7 +81,7 @@ public override string GetIconName() { - return "Motion_Sensor_" + (_isTripped ? "100" : "0"); + return "Motion_Sensor_" + (status ? (_isTripped ? "100" : "0") : "bypass"); } public override string GetStatusText() Modified: trunk/plugins/VeraControl/DeviceThermostat.cs =================================================================== --- trunk/plugins/VeraControl/DeviceThermostat.cs 2012-02-17 23:12:46 UTC (rev 4456) +++ trunk/plugins/VeraControl/DeviceThermostat.cs 2012-02-19 22:21:45 UTC (rev 4457) @@ -63,8 +63,7 @@ // Do something with vera string cmd = "?id=lu_action&DeviceNum=" + internalId.ToString( )+ "&serviceId=urn:upnp-org:serviceId:HVAC_UserOperatingMode1&action=SetModeTarget" + - "&NewModeTarget=" + (value == "Off" ? "Off" : (value == "Cool" ? "CoolOn" : (value == "Heat" ? "HeatOn" : "AutoChangeOver")) - ); + "&NewModeTarget=" + (value == "Off" ? "Off" : (value == "Cool" ? "CoolOn" : (value == "Heat" ? "HeatOn" : "AutoChangeOver"))); _myVeraBox.DoVeraCommandRequest(cmd, ReportRequestError); } } Modified: trunk/plugins/VeraControl/DeviceWindowCovering.cs =================================================================== --- trunk/plugins/VeraControl/DeviceWindowCovering.cs 2012-02-17 23:12:46 UTC (rev 4456) +++ trunk/plugins/VeraControl/DeviceWindowCovering.cs 2012-02-19 22:21:45 UTC (rev 4457) @@ -4,8 +4,8 @@ * Date: 24-12-2011 * Time: 23:56 * - * Copyright: 2012 GPL - Bart Eversdijk - * MediaPort plugin - MicasaVerde (TM) Vera Controller + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller * E-mail: ba...@ev... */ using System; @@ -18,12 +18,65 @@ /// </summary> public class DeviceWindowCovering : DeviceDimmer { - public DeviceWindowCovering(XmlNode xn, int verabox) : base (xn, verabox) + public DeviceWindowCovering(XmlNode xn, int verabox) : base (xn, verabox) { if (xn != null) { Update(xn); } } + + public override string GetIconName() + { + string leveltxt = "0"; + if (level > 0) { leveltxt = "25"; } + if (level > 25) { leveltxt = "50"; } + if (level > 50) { leveltxt = "75"; } + if (level > 75) { leveltxt = "100"; } + + return "Window_Covering_" + leveltxt; + } + + public override string GetStatusText() + { + return (status ? (level == 100 ? "Closed" : level.ToString() + "%") : "Opened"); + } + + public override string mode + { + get { + string strmode = "Open"; + if (level > 0) { strmode = "25%"; } + if (level > 25) { strmode = "50%"; } + if (level > 50) { strmode = "75%"; } + if (level > 75) { strmode = "Close"; } + return strmode; + } + set { + switch (value) + { + case "Open": + level = 0; + break; + case "25%": + level = 25; + break; + case "50%": + level = 50; + break; + case "75%": + level = 75; + break; + case "Close": + level = 100; + break; + } + } + } + + public override string [] GetCommands() + { + return new string [] {"Open", "Close", "25%", "75%", "50%"}; + } } } Modified: trunk/plugins/VeraControl/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2012-02-17 23:12:46 UTC (rev 4456) +++ trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2012-02-19 22:21:45 UTC (rev 4457) @@ -28,4 +28,4 @@ // // You can specify all the values or you can use the default the Revision and // Build Numbers by using the '*' as shown below: -[assembly: AssemblyVersion("0.5.1.0")] +[assembly: AssemblyVersion("1.0.1.0")] Modified: trunk/plugins/VeraControl/Room.cs =================================================================== --- trunk/plugins/VeraControl/Room.cs 2012-02-17 23:12:46 UTC (rev 4456) +++ trunk/plugins/VeraControl/Room.cs 2012-02-19 22:21:45 UTC (rev 4457) @@ -61,7 +61,8 @@ public int id { - get { + get + { if (_myVeraBox == null) { return 0; @@ -82,7 +83,8 @@ public int section { - get { + get + { if (_myVeraBox == null) { return 0; Modified: trunk/plugins/VeraControl/Section.cs =================================================================== --- trunk/plugins/VeraControl/Section.cs 2012-02-17 23:12:46 UTC (rev 4456) +++ trunk/plugins/VeraControl/Section.cs 2012-02-19 22:21:45 UTC (rev 4457) @@ -42,7 +42,8 @@ public int id { - get { + get + { if (_myVeraBox == null) { return 0; Added: trunk/plugins/VeraControl/VeraBox.cs =================================================================== --- trunk/plugins/VeraControl/VeraBox.cs (rev 0) +++ trunk/plugins/VeraControl/VeraBox.cs 2012-02-19 22:21:45 UTC (rev 4457) @@ -0,0 +1,728 @@ +/* + * Created by SharpDevelop. + * User: Bart + * Date: 10-2-2012 + * Time: 16:41 + * + * + * Copyright: 2012 GPL - Bart Eversdijk + * MediaPort plugin - MicasaVerde (TM) Vera Controller + * E-mail: ba...@ev... + */ +using System; +using System.Net; +using System.IO; +using System.Threading; +using System.Collections.Generic; +using System.Xml; + +namespace VeraControl.Properties +{ + public enum ConnectionType + { + RemoteOnly = -1, + Auto = 0, + LocalOnly = 1 + } + + public class VeraStatus + { + public DeviceSystem system = new DeviceSystem(); + public List<DeviceGeneric> devices = new List<DeviceGeneric>(); + public List<Scene> scenes = new List<Scene>(); + public List<Room> rooms = new List<Room>(); + public List<DevCategories> categories = new List<DevCategories>(); + public List<Section> sections = new List<Section>(); + + #region Vers get by id support functions + + public void ClearAllLists() + { + devices.Clear(); + scenes.Clear(); + rooms.Clear(); + categories.Clear(); + sections.Clear(); + } + public Room GetRoomById(int id) + { + foreach(Room room in rooms) + { + if (room.id == id) + { + return room; + } + } + return new Room(null, 0); + } + + public Section GetSectionById(int id) + { + foreach(Section section in sections) + { + if (section.id == id) + { + return section; + } + } + return new Section(null, 0); + } + + public DeviceGeneric GetDeviceById(int id) + { + foreach(DeviceGeneric dev in devices) + { + if (dev.id == id) + { + return dev; + } + } + return new DeviceGeneric(null, 0); + } + + public Scene GetSceneById(int id) + { + foreach(Scene scene in scenes) + { + if (scene.id == id) + { + return scene; + } + } + return new Scene(null, 0); + } + + public DevCategories GetCategoryById(int id) + { + foreach(DevCategories cat in categories) + { + if (cat.id == id) + { + return cat; + } + } + return new DevCategories(null); + } + + public bool IsSectionFound(int id) + { + foreach(Section section in sections) + { + if (section.id == id) + { + return true; + } + } + return false; + } + + public bool IsRoomFound(int id) + { + foreach(Room room in rooms) + { + if (room.id == id) + { + return true; + } + } + return false; + } + + public bool IsDeviceFound(int id) + { + foreach(DeviceGeneric dev in devices) + { + if (dev.id == id) + { + return true; + } + } + return false; + } + + public bool IsSceneFound(int id) + { + foreach(Scene scene in scenes) + { + if (scene.id == id) + { + return true; + } + } + return false; + } + + public bool IsCategoryFound(int id) + { + foreach(DevCategories cat in categories) + { + if (cat.id == id) + { + return true; + } + } + return false; + } + #endregion + } + + /// <summary> + /// Description of VeraBox. + /// </summary> + public class VeraBox + { + private VeraHelper _helper = VeraHelper.Instance; + + // Actual device information + private VeraStatus _status = new VeraStatus(); + + // Config data + public int _maxRefreshDelay; // Maximun delay between 2 status updates in seconds + public int _minRefreshDelay = 1000; // Minimun delay between 2 status updates in miliseconds + private int _myVeraId = 0; + public bool _oldStyleConfig = false; // Read config settings in 0.9.0.3 or previous style + + // Communication status/control + private long _lastUpdate = 0; + private bool _screenUpdateRequired = false; // Only true when a new update was received AND at least one device(staus) or scene was changed + private bool _lastUpdateFailed = false; + private string _lastUpdateErrorMessage = ""; + public WebClient _webUpdateClient = new WebClient(); + public WebClient _webCommandClient = new WebClient(); + private Action<string> _webCommandClientErrorReporter = null; + + // Connection information + private int _serial = -1; + private string _ip = ""; + private string _name = ""; + private string _realLocalVeraAddress = null; + private string _realRemoteVeraAddress = null; + private string _discreteVeraAddress = null; + private ConnectionType _connectionType = ConnectionType.Auto; + private bool _fallBackConnection = false; + + public VeraBox(int id, int maxRefresh, int minRefresh) + { + _myVeraId = id; + _maxRefreshDelay = maxRefresh; + _minRefreshDelay = minRefresh; + + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) + { + // Set DownloadStringCompleted handler + _webUpdateClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnCompletedUpdateStatusRequest); + _webCommandClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(OnCompletedCommandRequest); + } + } + + public void DoVeraCommandRequest(string param, Action<string> errorReporter) + { + // If a request was pending just cancel the previous request (user is informed about the progress) + string url = veraAddress + "/data_request" + param + "&time=" + DateTime.Now.Ticks; + + // Callback thus ASynchronised call (do NOT wait for response) + try { + _webCommandClientErrorReporter = errorReporter; + _webCommandClient.CancelAsync(); // Cancel any current pending Async calls... + _webCommandClient.DownloadStringAsync(new Uri(url)); + + } catch( Exception e ) + { + _webCommandClientErrorReporter = null; + status.system.ReportCommandError(e.Message); + setScreenUpdateRequired(); + } + } + + public void OnCompletedCommandRequest(object sender, DownloadStringCompletedEventArgs e) + { + if (e.Cancelled) + { + // Communication cancel for some reason, no valid data to be expected + if (_webCommandClientErrorReporter != null) + { + // Send error to dialog message handler + _webCommandClientErrorReporter("Request was canceled"); + } + else + { + // Show eror in MediaPortal Vera-main window + status.system.ReportCommandError("Request was canceled"); + } + setScreenUpdateRequired(); + } + else if (e.Error != null) + { + // Handle error here + if (_webCommandClientErrorReporter != null) + { + // Send error to dialog message handler + _webCommandClientErrorReporter(e.Error.Message); + } + else + { + // Show eror in MediaPortal Vera-main window + status.system.ReportCommandError(e.Error.Message); + } + setScreenUpdateRequired(); + } + else + { + // Communication succes full -> no parse Vera response... + if (!e.Result.ToUpper().Contains("<OK>OK</OK>") && !e.Result.ToUpper().Contains("<JOBID>")) + { + if (_webCommandClientErrorReporter != null) + { + // Send error to dialog message handler + _webCommandClientErrorReporter(e.Result); + } + else + { + // Show eror in MediaPortal Vera-main window + status.system.ReportCommandError(e.Result); + } + setScreenUpdateRequired(); + } + } + // Communication done clear error report handler + _webCommandClientErrorReporter = null; + } + + public void UpdateCurrentStatus() + { + /* Keep updating with webClient timeout 180 sec, even when last time did fail or connection was lost....*/ + if (!_webUpdateClient.IsBusy && (!_lastUpdateFailed || (_lastUpdate + 30 < _helper.GetSecondsSince1970()))) + { + string url = veraAddress + "/data_request" + + "?id=lu_sdata&loadtime=" + _status.system.loadtime + + "&dataversion=" + _status.system.dataversion + + "&minimumdelay=" + _minRefreshDelay + + "&timeout=" + _maxRefreshDelay + + "&output_format=xml" + + "&time=" + DateTime.Now.Ticks; + + // Callback thus ASynchronised call (do NOT wait for response) + try { + _webUpdateClient.CancelAsync(); // Cancel any current pending Async calls... + _webUpdateClient.DownloadStringAsync(new Uri(url)); + } catch( Exception e ) + { + _lastUpdateFailed = true; + _lastUpdateErrorMessage = e.Message; + } + _lastUpdate = _helper.GetSecondsSince1970(); + } + } + + public void OnCompletedUpdateStatusRequest(object sender, DownloadStringCompletedEventArgs e) + { + if (!e.Cancelled) + { + // Communication cancel for some reason, no valid data to be expected + if (e.Error != null) + { + // Handle error here + _lastUpdateFailed = true; + _lastUpdateErrorMessage = e.Error.Message; + setScreenUpdateRequired(); + } + else + { + ParseUpdateInfo(e.Result); + // WebClient wc = new WebClient(); + // if (_status.system.dataversion == "0") + // { + // ParseUpdateInfo( wc.DownloadString(@"C:\Users\Bart\Documents\SharpDevelop Projects\VeraControl\testdata\text.xml")); + // } + } + } + + // update timer again (took some time to get the data) + _lastUpdate = _helper.GetSecondsSince1970(); + } + + public void ParseUpdateInfo(string veraresponse) + { + var xmlDoc = new XmlDocument(); + try { + xmlDoc.LoadXml(veraresponse); + } catch (Exception) + { + // Parser failed so incorrect data received (could be an interrupted data transfer) + return; + } + // Parse header + XmlNode rootnode = xmlDoc.SelectSingleNode("/root"); + if (rootnode == null) + { + // Not a status update, just return + return; + } + + if (!_screenUpdateRequired) + { + // Clear flag, only when previous update was already handled (might be some new or remove devices/scenes to be displayed) + _status.system.ClearFullReloadFlag(); + } + if (_lastUpdateFailed) + { + _lastUpdateFailed = false; + setScreenUpdateRequired(); + _status.system.ClearConnectionError(); + } + // Process system status first + _status.system.update(rootnode); + if (_status.system.fullReload) + { + // We have a full refresh -> Clear all lists (to get clear of removed devices/scenes/catgories/rooms/etc...) + _status.ClearAllLists(); + + } + + // Process Sections + XmlNodeList xnList = xmlDoc.SelectNodes("/root/sections/section"); + foreach (XmlNode xn in xnList) + { + Section sc = _status.GetSectionById( makeId(xn.Attributes["id"].Value) ); + if (sc.id != 0) { + sc.Update(xn); + } else { + _status.sections.Add(new Section(xn, _myVeraId)); + } + } + + // Process Rooms + xnList = xmlDoc.SelectNodes("/root/rooms/room"); + foreach (XmlNode xn in xnList) + { + Room room = _status.GetRoomById( makeId(xn.Attributes["id"].Value) ); + if (room.id != 0) { + room.Update(xn); + } else { + _status.rooms.Add(new Room(xn, _myVeraId)); + } + } + + // Process Scenes + xnList = xmlDoc.SelectNodes("/root/scenes/scene"); + // State update of Scenes are not reported done, so they have to be cleaned manualy + // if a message is still valid and/or new message will be reported below + foreach (Scene scene in _status.scenes) + { + scene.ClearCommState(); + } + foreach (XmlNode xn in xnList) + { + Scene sc = _status.GetSceneById( makeId(xn.Attributes["id"].Value) ); + if (sc.id != 0) { + sc.Update(xn); + } else { + _status.scenes.Add(new Scene(xn, _myVeraId)); + } + } + + // Process Categories - categories are general not Box specific + xnList = xmlDoc.SelectNodes("/root/categories/categorie"); + foreach (XmlNode xn in xnList) + { + DevCategories cat = _status.GetCategoryById( int.Parse(xn.Attributes["id"].Value) ); + if (cat.id != 0) { + cat.Update(xn); + } else { + _status.categories.Add(new DevCategories(xn)); + } + } + + // Process Devices + xnList = xmlDoc.SelectNodes("/root/devices/device"); + foreach (XmlNode xn in xnList) + { + DeviceGeneric dev = _status.GetDeviceById( makeId(xn.Attributes["id"].Value) ); + if (dev.id != 0) { + // update existing device + dev.Update(xn); + } else { + _status.system.SetFullReloadFlag(); + + // catids: http://wiki.micasaverde.com/index.php/Luup_UPNP_Files + switch (xn.Attributes["category"].Value) + { + //case "1": // TODO: Implement interface device ? + // m_status.devices.Add(new DeviceInterface(xn)); + // break; + + case "2": + _status.devices.Add(new DeviceDimmer(xn, _myVeraId)); + break; + + case "3": + case "11": // Generic IO + _status.devices.Add(new DeviceSwitch(xn, _myVeraId)); + break; + + case "4": // Generic Sensor + case "12": // Motion Sensor + _status.devices.Add(new DeviceSecurity(xn, _myVeraId)); + break; + + case "5": + _status.devices.Add(new DeviceThermostat(xn, _myVeraId, _status.system.IsMetric())); + break; + + case "6": + _status.devices.Add(new DeviceCam(xn, _myVeraId)); + break; + + case "7": + _status.devices.Add(new DeviceDoorlock(xn, _myVeraId)); + break; + + case "8": + _status.devices.Add(new DeviceWindowCovering(xn, _myVeraId)); + break; + + //case "9": + // m_status.devices.Add(new DeviceRemoteControl(xn, veraId)); + // break; + + //case "10": + // m_status.devices.Add(new DeviceIrTx(xn, veraId)); + // break; + + //case "13": + // m_status.devices.Add(new DeviceSerialPort(xn, veraId)); + // break + + case "14": + _status.devices.Add(new DeviceSceneController(xn, _myVeraId)); + break; + + // case "15": + // m_status.devices.Add(new DeviceAV(xn, veraId)); + // break; + + case "16": + _status.devices.Add(new DeviceHumidity(xn, _myVeraId)); + break; + + case "17": + _status.devices.Add(new DeviceTemperature(xn, _myVeraId, _status.system.IsMetric())); + break; + + case "18": + _status.devices.Add(new DeviceLightSensor(xn, _myVeraId)); + break; + + //case "19": + // m_status.devices.Add(new DeviceZwaveInt(xn, veraId)); + // break + //case "20": + // m_status.devices.Add(new DeviceInsteonInt(xn, veraId)); + // break + + case "21": + _status.devices.Add(new DevicePowerMeter(xn, _myVeraId)); + break; + + case "0": + default: + // Check for Google Weather Device + if (xn.Attributes["WindCondition"] != null || xn.Attributes["windcondition"] != null) + { + _status.devices.Add(new DeviceGWeather(xn, _myVeraId)); + break; + } + // Check for Bart's sprinkler Device + if (xn.Attributes["OperationMode"] != null) + { + _status.devices.Add(new DeviceSprinkler(xn, _myVeraId)); + break; + } + _status.devices.Add(new DeviceGeneric(xn, _myVeraId)); + break; + } + } + } + } + + public long SecondsSinceLastUpdate + { + get { return (_helper.GetSecondsSince1970() - _lastUpdate); } + } + + public List<Scene> scenes + { + get { return _status.scenes; } + } + + public List<DeviceGeneric> devices + { + get { return _status.devices; } + } + + public List<Room> rooms + { + get { return _status.rooms; } + } + + public List<DevCategories> categories + { + get { return _status.categories; } + } + + public List<Section> sections + { + get { return _status.sections; } + } + + public bool lastUpdateFailed + { + get { return _lastUpdateFailed; } + set { _lastUpdateFailed = value; } + } + + public string lastUpdateError + { + get { return _lastUpdateErrorMessage; } + } + + public string name + { + get { + if (_name == "" || _name == "-") + { + return (_connectionType == ConnectionType.RemoteOnly ? _serial.ToString() : _ip); + } + return _name; + } + } + + /// <summary> + /// Invoking this method will clear the update ready flag -> so caller need to handle the screen update + /// </summary> + /// <returns>When true a screen update shall be preformed by the caller</returns> + public bool NewScreenUpdateWaitingAndClearFlag() + { + bool b = _screenUpdateRequired; + _screenUpdateRequired = false; + return b; + } + + public void setScreenUpdateRequired() + { + _screenUpdateRequired = true; + } + /// <summary> + /// A request is currently being handled by Vera, this request takes at least _minRefreshDelay msecs, at most _maxRefreshDelay seconds and will be finished the moment Vera detects a change. + /// As soon as this function returns false a new update request should be invoked (with UpdateCurrentStatus()), Vera will take care of the Refresh delays (by keeping open the http-connection) + /// </summary> + public bool updatePending + { + get { return _webUpdateClient.IsBusy; } + } + + + public VeraStatus status + { + get { return _status; } + } + + public int myId + { + get { return _myVeraId; } + } + + public int zeroId + { + get { return makeId(0); } + } + + public int makeId(int id) + { + return (_myVeraId * VeraCommunication.IDMASK) + id; + } + + public int makeId(string id) + { + return makeId(int.Parse(id)); + } + + public ConnectionType connectionType + { + get { return _connectionType; } + } + + public bool inFallback + { + get { return (_connectionType == ConnectionType.Auto ? _fallBackConnection : true); } + set { _fallBackConnection = (_connectionType == ConnectionType.Auto ? value : false); } + } + + public string discreteVeraAddress + { + get { + if (_discreteVeraAddress == null) + { // Accessing this variable will set the discrete value aswell + string dum = veraAddress; + } + return (_fallBackConnection || _connectionType == ConnectionType.RemoteOnly ? _discreteVeraAddress : _realLocalVeraAddress); + } + } + + public string veraAddress + { + get { + if (_realLocalVeraAddress == null && _realRemoteVeraAddress == null) + { + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) + { + string id = ""; + if (!_oldStyleConfig) + { + id = "_" + myId.ToString("00"); + } + _ip = xmlreader.GetValueAsString("veracontroller", "ipaddress" + id, "127.0.0.1"); + string port = xmlreader.GetValueAsString("veracontroller", "portnumber" + id, "3480"); + string user = xmlreader.GetValueAsString("veracontroller", "miosusername" + id, ""); + string pass = xmlreader.GetValueAsString("veracontroller", "miospassword" + id, ""); + _serial = xmlreader.GetValueAsInt ("veracontroller", "serialnumber" + id, -1); + _name = xmlreader.GetValueAsString("veracontroller", "name" + id, ""); + + if (_oldStyleConfig) + { + _connectionType = (xmlreader.GetValueAsBool("veracontroller", "remoteConnected", false) ? ConnectionType.RemoteOnly : ConnectionType.LocalOnly); + } + else + { + _connectionType = (ConnectionType)xmlreader.GetValueAsInt("veracontroller", "connectiontype" + id, (int)ConnectionType.Auto); + if (_connectionType == ConnectionType.Auto && (_serial < 99 || user == "" || pass == "")) + { + _connectionType = ConnectionType.LocalOnly; + } + } + + string fwd = "fwd" + ((_serial % 1) == 1 ? "1" : "2"); + _realLocalVeraAddress = (_connectionType == ConnectionType.RemoteOnly) ? "" : "http://" + _ip + ":" + port; + _realRemoteVeraAddress = (_connectionType == ConnectionType.LocalOnly) ? "" : "https://" + fwd + ".mios.com/" + user + "/" + pass + "/" + _serial.ToString(); + _discreteVeraAddress = (_connectionType == ConnectionType.LocalOnly) ? _realLocalVeraAddress : fwd + ".mios.com/" + user + "/xxxxx/" + _serial.ToString(); + } + } + else + { + // Check if we did receive a different serial number, than was stored by the config file + if (!_oldStyleConfig && status.system.serialno != _serial && status.system.serialno != -1) + { + using (MediaPortal.Profile.Settings xmlWriter = new MediaPortal.Profile.MPSettings()) + { + // Store new serial number.... + xmlWriter.SetValue("veracontroller", "serialnumber" + "_" + myId.ToString("00"), _serial.ToString()); + } + } + } + + return (_fallBackConnection || _connectionType == ConnectionType.RemoteOnly ? _realRemoteVeraAddress :_realLocalVeraAddress); + } + } + } +} + Modified: trunk/plugins/VeraControl/VeraCommunication.cs =================================================================== --- trunk/plugins/VeraControl/VeraCommunication.cs 2012-02-17 23:12:46 UTC (rev 4456) +++ trunk/plugins/VeraControl/VeraCommunication.cs 2012-02-19 22:21:45 UTC (rev 4457) @@ -193,21 +193,37 @@ public Room GetRoomById(int id) { + if (BoxId(id) >= _instance.numOfBoxes) + { + return new Room(null, 0); + } return boxes[BoxId(id)].status.GetRoomById(id); } public Section GetSectionById(int id) { + if (BoxId(id) >= _instance.numOfBoxes) + { + return new Section(null, 0); + } return boxes[BoxId(id)].status.GetSectionById(id); } public DeviceGeneric GetDeviceById(int id) { + if (BoxId(id) >= _instance.numOfBoxes) + { + return new DeviceGeneric(null, 0); + } return boxes[BoxId(id)].status.GetDeviceById(id); } public Scene GetSceneById(int id) { + if (BoxId(id) >= _instance.numOfBoxes) + { + return new Scene(null, 0); + } return boxes[BoxId(id)].status.GetSceneById(id); } @@ -225,6 +241,10 @@ public DevCategories GetCategoryById(int id) { + if (BoxId(id) >= _instance.numOfBoxes) + { + return new DevCategories(0); + } return boxes[BoxId(id)].status.GetCategoryById(id); } @@ -246,26 +266,46 @@ public bool IsSectionFound(int id) { + if (BoxId(id) >= _instance.numOfBoxes) + { + return false; + } return boxes[BoxId(id)].status.IsSectionFound(id); } public bool IsRoomFound(int id) { + if (BoxId(id) >= _instance.numOfBoxes) + { + return false; + } return boxes[BoxId(id)].status.IsRoomFound(id); } public bool IsDeviceFound(int id) { + if (BoxId(id) >= _instance.numOfBoxes) + { + return false; + } return boxes[BoxId(id)].status.IsDeviceFound(id); } public bool IsSceneFound(int id) { + if (BoxId(id) >= _instance.numOfBoxes) + { + return false; + } return boxes[BoxId(id)].status.IsSceneFound(id); } public bool IsCategoryFound(int id) { + if (BoxId(id) >= _instance.numOfBoxes) + { + return false; + } return boxes[BoxId(id)].status.IsCategoryFound(id); } @@ -280,7 +320,6 @@ { return false; } - return (room.section == sectionid); } Modified: trunk/plugins/VeraControl/VeraControl.cs =================================================================== --- trunk/plugins/VeraControl/VeraControl.cs 2012-02-17 23:12:46 UTC (rev 4456) +++ trunk/plugins/VeraControl/VeraControl.cs 2012-02-19 22:21:45 UTC (rev 4457) @@ -27,6 +27,7 @@ using Action = MediaPortal.GUI.Library.Action; using Player = MediaPortal.Player.g_Player; using MediaType = MediaPortal.Player.g_Player.MediaType; +using System.Windows; using MediaPortal.Common.Utils; [assembly: CompatibleVersion("1.1.6.27644")] @@ -83,6 +84,7 @@ [SkinControlAttribute(10)] protected GUILabelControl _title = null; [SkinControl(20)] protected GUISpinButton _sectionList = null; [SkinControl(40)] protected GUIListControl _leftList = null; + [SkinControl(41)] protected GUICoverFlow _flowList = null; [SkinControl(50)] protected GUIListControl _rightList = null; [SkinControl(30)] protected GUIImage _systemStatusImage = null; @@ -118,6 +120,8 @@ public bool _enableSceneTrigger = false; private bool _autoSelectRoom = true; private bool _viewPerCategory = false; + private bool _viewListStyle = true; + private bool _devicesFlow = false; private VeraSortStyle _selectedSortOption = VeraSortStyle.NO; private VeraFilterStyle _selectedFilterOption = VeraFilterStyle.NONE; @@ -143,8 +147,8 @@ public VeraControl() { - // TODO: remove this sleep - Thread.Sleep(5000); + // TO DO: remove this sleep + // Thread.Sleep(5000); } #region ISetupForm Members @@ -158,7 +162,7 @@ // Returns the description of the plugin is shown in the plugin menu public string Description() { - return "Micasa Verde Vera 2 controller, let Media Portal control your Z-wave devices"; + return "Micasa Verde Vera controller, let Media Portal control your Z-wave devices"; } // Returns the author of the plugin which is shown in the plugin menu @@ -239,9 +243,10 @@ { _enableSceneTrigger = xmlreader.GetValueAsBool("veracontroller", "enableSceneTrigger", false); _autoSelectRoom = xmlreader.GetValueAsBool("veracontroller", "AutoSelectRoom", true); - _selectedSortOption = (VeraSortStyle) xmlreader.GetValueAsInt("veracontroller", "Sort", 0); - _selectedFilterOption = (VeraFilterStyle)xmlreader.GetValueAsInt("veracontroller", "Filter", 0); - _viewPerCategory = xmlreader.GetValueAsBool("veracontroller", "ViewMode", false); + _selectedSortOption = (VeraSortStyle) xmlreader.GetValueAsInt("veracontroller", "Sort", 0); + _selectedFilterOption = (VeraFilterStyle)xmlreader.GetValueAsInt("veracontroller", "Filter", 0); + _viewPerCategory = xmlreader.GetValueAsBool("veracontroller", "ViewMode", false); + _viewListStyle = xmlreader.GetValueAsBool("veracontroller", "ViewList", true); } GUIWindowManager.OnNewAction += new OnActionHandler(OnNewAction); @@ -271,11 +276,18 @@ protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType) { if (control == _rightList) - OnRightlistCrtl((GUIListControl)control, actionType); + OnRightlistCrtl(actionType); if (control == _leftList) - OnLeftlistCrtl((GUIListControl)control); - + OnLeftlistCrtl(); + + if (control == _flowList) + { + if (_devicesFlow) + OnRightlistCrtl(actionType); + else + OnLeftlistCrtl(); + } if (control == _sectionList) OnSectionList((GUISpinButton)control); @@ -351,12 +363,16 @@ default: break; } - + + // Now handle 'local' actions (only respond when Vera Controller is visible) if (GUIWindowManager.ActiveWindow == GetWindowId()) { switch(action.wID) { + case Action.ActionType.ACTION_PREVIOUS_MENU: + break; + case Action.ActionType.ACTION_MOUSE_MOVE: break; @@ -582,23 +598,44 @@ } RefreshNow(); - // Auto update right side list - if (_autoSelectRoom && - (!_viewPerCategory && _selectedRoom != _leftList.SelectedListItem.ItemId) || - ( _viewPerCategory && _selectedCategory != _leftList.SelectedListItem.ItemId) ) + // Auto update right side list (only valid when we see lists) + if (_autoSelectRoom && _viewListStyle) { - OnLeftlistCrtl(_leftList); + if ((!_viewPerCategory && _selectedRoom != _leftList.SelectedListItem.ItemId) || + ( _viewPerCategory && _selectedCategory != _leftList.SelectedListItem.ItemId) ) + { + OnLeftlistCrtl(); + } } - base.Render(timePassed); } + public List<GUIListItem> GetListItems() + { + if (_viewListStyle) + { + return _rightList.ListItems; + } + if (!_devicesFlow) + { + // No devices return empty list + return new List<GUIListItem>(); + } + + List<GUIListItem> list = new List<GUIListItem>(); + for (int i = 0; i < _flowList.Count; i++) + { + list.Add(_flowList.GetCard(i)); + } + return list; + } + public void RefreshNow() { int selectedItem = 0; - if (_rightList.SelectedListItem != null) + if ((_viewListStyle && _rightList.SelectedListItem != null) || (!_viewListStyle && _devicesFlow && _flowList.SelectedListItem != null)) { // Prevent Eception in case we have an empty room - selectedItem = _rightList.SelectedListItem.ItemId; + selectedItem = (_viewListStyle ? _rightList.SelectedListItem.ItemId : _flowList.SelectedListItem.ItemId); } else if (_lastSelectedItemId != 0) { @@ -611,28 +648,32 @@ if (_vera.NewScreenUpdateWaitingAndClearFlag() || newSelectedItem) { // if full reload has been found rebuild lists - if (_vera.FullReloadWaitingAndClearFlag() ) { + if (_vera.FullReloadWaitingAndClearFlag() ) + { FillLists(false); } else { // update device status - foreach (GUIListItem item in _rightList.ListItems) + foreach (GUIListItem item in GetListItems()) { - if (item.ItemId > 0) - { // ItemId > 0 so we have a device - DeviceGeneric dev = _vera.GetDeviceById(item.ItemId); - if (dev.NewScreenUpdateWaitingAndClearFlag() || (newSelectedItem && _lastSelectedItemId == item.ItemId)) - { - FillinDeviceInfo(item, dev); + if (item.ItemId != ALL) + { + if (item.ItemId > 0) + { // ItemId > 0 so we have a device + DeviceGeneric dev = _vera.GetDeviceById(item.ItemId); + if (dev.NewScreenUpdateWaitingAndClearFlag() || (newSelectedItem && _lastSelectedItemId == item.ItemId)) + { + FillinDeviceInfo(item, dev); + } } - } - else - { // ItemId < 0 so we have a scene - Scene scene = _vera.GetSceneById((item.ItemId * -1)); - if (scene.NewScreenUpdateWaitingAndClearFlag() || (newSelectedItem && _lastSelectedItemId == item.ItemId)) - { - FillinSceneInfo(item, scene); + else + { // ItemId < 0 so we have a scene + Scene scene = _vera.GetSceneById((item.ItemId * -1)); + if (scene.NewScreenUpdateWaitingAndClearFlag() || (newSelectedItem && _lastSelectedItemId == item.ItemId)) + { + FillinSceneInfo(item, scene); + } } } } @@ -660,7 +701,7 @@ _actionAutoRoomButton.Selected = _autoSelectRoom; _actionSortButton.Label = "Sort: " + _sortOptions[(int)_selectedSortOption].shorttext; _actionFilterButton.Label = "Filter: " + _filterOptions[(int)_selectedFilterOption].shorttext; - _actionViewButton.Label = "View: " + (_viewPerCategory ? "Category" : "Room");; + _actionViewButton.Label = "View: " + (_viewPerCategory ? "Category" : "Room") + (_viewListStyle ? " (list)" : " (flow)"); // Set selected box information - get availabiliy information here (not earlier, on init() not all boxes did have the change to response) using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) @@ -694,23 +735,97 @@ { ListSections(); } - if (_viewPerCategory) + if (_viewListStyle) { - ListCategories(_selectedCategory); - if (_selectedCategory == ALL) { - ListScenes(ALL, _selectedSection); - } else { - ListDevicesPerCategory(_selectedCategory); + _rightList.Visibility = Visibility.Visible; + _leftList.Visibility = Visibility.Visible; + _flowList.Visibility = Visibility.Hidden; + + _sectionList.NavigateUp = _leftList.GetID; + _sectionList.NavigateDown = _leftList.GetID; + _sectionList.NavigateRight = _rightList.GetID; + + _actionVeraSelectButton.NavigateRight = _leftList.GetID; + _actionTriggerButton.NavigateRight = _leftList.GetID; + _actionSceneEditButton.NavigateRight = _leftList.GetID; + _actionFilterButton.NavigateRight = _leftList.GetID; + _actionSortButton.NavigateRight = _leftList.GetID; + _actionAutoRoomButton.NavigateRight = _leftList.GetID; + _actionViewButton.NavigateRight = _leftList.GetID; + + if (_viewPerCategory) + { + ListCategories(_selectedCategory); + if (_selectedCategory == ALL) { + ListScenes(ALL, _selectedSection); + } else { + ListDevicesPerCategory(_selectedCategory); + } } + else + { + ListRooms(_selectedSection, _selectedRoom); + if (_selectedRoom == ALL) { + ListScenes(ALL, _selectedSection); + } else { + ListDevicesPerRoom(_selectedRoom); + } + } } else { - ListRooms(_selectedSection, _selectedRoom); - if (_selectedRoom == ALL) { - ListScenes(ALL, _selectedSection); - } else { - ListDevicesPerRoom(_selectedRoom); + _rightList.Visibility = Visibility.Hidden; + _leftList.Visibility = Visibility.Hidden; + _flowList.Visibility = Visibility.Visible; + + _sectionList.NavigateUp = _flowList.GetID; + _sectionList.NavigateDown = _flowList.GetID; + _sectionList.NavigateRight = _flowList.GetID; + + _actionVeraSelectButton.NavigateRight = _flowList.GetID; + _actionTriggerButton.NavigateRight = _flowList.GetID; + _actionSceneEditButton.NavigateRight = _flowList.GetID; + _actionFilterButton.NavigateRight = _flowList.GetID; + _actionSortButton.NavigateRight = _flowList.GetID; + _actionAutoRoomButton.NavigateRight = _flowList.GetID; + _actionViewButton.NavigateRight = _flowList.GetID; + + if (_viewPerCategory) + { + if (_devicesFlow) + { + if (_selectedCategory == ALL) + { + ListScenes(ALL, _selectedSection); + } + else + { + ListDevicesPerCategory(_selectedCategory); + } + } + else + { + ListCategories(_selectedCategory); + } } + else + { + if (_devicesFlow) + { + if (_selectedCategory == ALL) + { + ListScenes(ALL, _selectedSection); + } + else + { + ListDevicesPerRoom(_selectedCategory); + } + } + else + { + ListRooms(_selectedSection, _selectedRoom); + } + } } } @@ -797,7 +912,7 @@ int cnt = 0; int selected = 0; // --- fill in left lisft with rooms and scene item - GUIControl.ClearControl(GetID, _leftList.GetID); + GUIControl.ClearControl(GetID, (_viewListStyle ? _leftList.GetID : _flowList.GetID)); GUIListItem sceneitem = new GUIListItem("Scenes"); sceneitem.ItemId = ALL; @@ -806,23 +921,49 @@ sceneitem.ThumbnailImage = "Vera\\Scenes.png"; Utils.SetDefaultIcons(sceneitem); - _leftList.Add(sceneitem); - + if (_viewListStyle) + { + _leftList.Add(sceneitem); + } + else + { + sceneitem.IsFolder = true; + _flowList.Add(sceneitem); + } foreach(Room room in _vera.GetSortedRooms(_selectedBox, _selectedSortOption)) { if (showSection == ALL || room.section == showSection) { GUIListItem item = new GUIListItem(room.name); + + string sectioname = _vera.GetSectionById(room.section).name; item.Label2 = _vera.GetSectionById(room.section).name; - item.ItemId = room.id; - item.IconImage = @"Vera\OpenList.png"; - item.IconImageBig = @"Vera\OpenList.png"; - item.ThumbnailImage = @"Vera\OpenList.png"; - - Utils.SetDefaultIcons(item); - _leftList.Add(item); - + if (_viewListStyle) + { + item.IconImage = @"Vera\OpenList.png"; + item.IconImageBig = @"Vera\OpenList.png"; + item.ThumbnailImage = @"Vera\OpenList.png"; + + Utils.SetDefaultIcons(item); + + _leftList.Add(item); + } + else + { + item.IconImage = @"Vera\room.png"; + item.IconImageBig = @"Vera\room.png"; + item.ThumbnailImage = @"Vera\room.png"; + + Utils.SetDefaultIcons(item); + + item.IsFolder = true; + if (sectioname != "") + { + item.Label = sectioname + ": " + room.name; + } + _flowList.Add(item); + } cnt++; if (selectedRoom == room.id) { @@ -831,7 +972,11 @@ } } // Set Current Selected Item - _leftList.SelectedListItemIndex = selected; + if (_viewListStyle) { + _leftList.SelectedListItemIndex = selected; + } else { + _flowList.SelectedListItemIndex = selected; + } } private void ListCategories(int selectedCategory) @@ -839,7 +984,8 @@ int cnt = 0; int selected = 0; // --- fill in left lisft with rooms and scene item - GUIControl.ClearControl(GetID, _leftList.GetID); + GUIControl.ClearControl(GetID, (_viewListStyle ? _leftList.GetID : _flowList.GetID)); + GUIListItem sceneitem = new GUIListItem("Scenes"); sceneitem.ItemId = ALL; @@ -848,8 +994,15 @@ sceneitem.ThumbnailImage = "Vera\\Scenes.png"; Utils.SetDefaultIcons(sceneitem); - _leftList.Add(sceneitem); - + if (_viewListStyle) + { + _leftList.Add(sceneitem); + } + else + { + sceneitem.IsFolder = true; + _flowList.Add(sceneitem); + } foreach(DevCategories category in (_selectedBox == ALL ? _vera.categories : _vera.boxes[_selectedBox].categories)) { if (_vera.ContainsSectionThisCategoyy(category.id, _selectedSection, _selectedFilterOption)) @@ -861,8 +1014,15 @@ item.ThumbnailImage = @"Vera\" + category.GetIconName() + ".png"; Utils.SetDefaultIcons(item); - _leftList.Add(item); - + if (_viewListStyle) + { + _leftList.Add(item); + } + else + { + item.IsFolder = true; + _flowList.Add(item); + } cnt++; if (selectedCategory == category.id) { @@ -871,27 +1031,54 @@ } } // Set Current Selected Item - _leftList.SelectedListItemIndex = selected; + if (_viewListStyle) { + _leftList.SelectedListItemIndex = selected; + } else { + _flowList.SelectedListItemIndex = selected; + } } private void ListScenes(int selectedRoom, int selectedSection) { - GUIControl.ClearControl(GetID, _rightList.GetID); + GUIControl.ClearControl(GetID, (_viewListStyle ? _rightList.GetID : _flowList.GetID)); + if (!_viewListStyle) + { + // --- fill in flowlist a return icon + GUIListItem backitem = new GUIListItem("back"); + backitem.ItemId = ALL; + + backitem.IconImage = "Vera\\back.png"; + backitem.IconImageBig = "Vera\\back.png"; + backitem.ThumbnailImage = "Vera\\back.png"; + + Utils.SetDefaultIcons(backitem); + backitem.IsFolder = true; + _flowList.Add(backitem); + } + foreach(Scene scene in _vera.GetSortedScenes(_selectedBox, _selectedSortOption)) { if ((selectedRoom == ALL || scene.InRoom(selectedRoom)) && _vera.IsRoomInSection(scene.room, selectedSection)) { GUIListItem item = new GUIListItem(scene.name); FillinSceneInfo(item, scene); - _rightList.Add(item); + if (_viewListStyle) { + _rightList.Add(item); + } else { + item.IsFolder = true; + _flowList.Add(item); + } } } GUIControl.FocusControl(GetID, _leftList.GetID); // Set Current Selected Item - _rightList.SelectedListItemIndex = 0; - + if (_viewListStyle) { + _rightList.SelectedListItemIndex = 0; + } else { + _flowList.SelectedListItemIndex = 0; + } _title.Label = _titleTxt + " - Scenes"; } @@ -923,7 +1110,12 @@ { GUIListItem item = new GUIListItem(dev.name); FillinDeviceInfo(item, dev); - _rightList.Add(item); + if (_viewListStyle) { + _rightList.Add(item); + } else { + item.IsFolder = true; + _flowList.Add(item); + } } } _title.Label = _titleTxt + " - " + _vera.GetRoomById(selectedRoom).name; @@ -931,8 +1123,23 @@ private void ListDevicesPerCategory(int selectedCategory) { - GUIControl.ClearControl(GetID, _rightList.GetID); + GUIControl.ClearControl(GetID, (_viewListStyle ? _rightList.GetID : _flowList.GetID)); + if (!_viewListStyle) + { + // --- fill in flowlist a return icon + GUIListItem backitem = new GUIListItem("back"); + backitem.ItemId = ALL; + + backitem.IconImage = "Vera\\back.png"; + backitem.IconImageBig = "Vera\\back.png"; + backitem.ThumbnailImage = "Vera\\back.png"; + + Utils.SetDefaultIcons(backitem); + backitem.IsFolder = true; + _flowList.Add(backitem); + } + foreach(DeviceGeneric dev in _vera.GetSortedDevices(_selectedBox, _selectedSortOption)) { if (dev.InCategory(selectedCategory) && dev.PassesFilter(_selectedFilterOption)) @@ -941,7 +1148,11 @@ { GUIListItem item = new GUIListItem(dev.name); FillinDeviceInfo(item, dev); - _rightList.Add(item); + if (_viewListStyle) { + _rightList.Add(item); + } else { + _flowList.Add(item); + } } } } @@ -960,17 +1171,23 @@ Utils.SetDefaultIcons(item); + if (!_viewListStyle) + { + item.Label = dev.name + (dev.GetStatusText() != "" ? " [" + dev.GetStatusText() +"]" : ""); + item.IsFolder = true; + } + if (_lastSelectedItemId == dev.id) { SetDeviceStatus(dev.commstate, dev.comment); } } - private void OnLeftlistCrtl(GUIListControl control) + private void OnLeftlistCrtl() { - int id = control.SelectedListItem.ItemId; + int id = (_viewListStyle ? _leftList.SelectedListItem.ItemId : _flowList.SelectedListItem.ItemId); - GUIAnimation.HideControl(GetID, _rightList.GetID); + _devicesFlow = true; if (_viewPerCategory) { _selectedCategory = id; @@ -996,8 +1213,6 @@ ListDevicesPerRoom(id); } } - - GUIAnimation.ShowControl(GetID, _rightList.GetID); } private void OnSectionList(GUISpinButton control) @@ -1005,13 +1220,12 @@ if (control.SpinValue > 0) { _selectedSection = _vera.GetSections(_selectedBox)[control.SpinValue-1].id;; - //_selectedSection = _vera.sections[control.SpinValue-1].id; } else { _selectedSection = ALL; } - if (_selectedSection == 0 ) + if (_selectedSection == 0) { _selectedSection = ALL; } @@ -1023,11 +1237,18 @@ FillLists(false); } - private void OnRightlistCrtl(GUIListControl control, Action.ActionType actionType) + private void OnRightlistCrtl(Action.ActionType actionType) { - if (control.SelectedListItem.ItemId < 0) + int itemId = (_viewListStyle ? _rightList.SelectedListItem.ItemId : _flowList.SelectedListItem.ItemId); + if (itemId == ALL) + { + _devicesFlow = false; + FillLists(false); + return; + } + if (itemId < 0) { // We have a scene as selected item (id <= 0) - Scene scene = _vera.GetSceneById((control.SelectedListItem.ItemId * -1)); + Scene scene = _vera.GetSceneById((itemId * -1)); if (scene != null) { @@ -1047,7 +1268,7 @@ } else { // We have a device as selected item - DeviceGeneric dev = _vera.GetDeviceById(control.SelectedListItem.ItemId); + DeviceGeneric dev = _vera.GetDeviceById(itemId); switch (actionType) { @@ -1122,6 +1343,7 @@ } // Update lists to reflect choice + _devicesFlow = false; FillLists(true); RefreshNow(); } @@ -1155,6 +1377,7 @@ } // Update lists to reflect choice + _devicesFlow = false; FillLists(true); RefreshNow(); } @@ -1169,24 +1392,30 @@ dlgMenu.Reset(); dlgMenu.SetHeading("Select viewing mode"); - dlgMenu.Add("View per room"); - dlgMenu.Add("View per category"); + dlgMenu.Add("View lists per room"); + dlgMenu.Add("View list per category"); + dlgMenu.Add("View flowstyle per room"); + dlgMenu.Add("View flowstyle per category"); dlgMenu.DoModal(GUIWindowManager.ActiveWindow); if (dlgMenu.SelectedLabel != -1) { // Something was selected - _viewPerCategory = (dlgMenu.SelectedId == 2); - control.Label = "View: " + (_viewPerCategory ? "Category" : "Room"); + _viewPerCategory = (dlgMenu.SelectedId == 2) || (dlgMenu.SelectedId == 4); + _viewListStyle = (dlgMenu.SelectedId <= 2); + control.Label = "... [truncated message content] |
From: <Ba...@us...> - 2012-10-06 20:09:08
|
Revision: 4511 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=4511&view=rev Author: BartEv Date: 2012-10-06 20:09:02 +0000 (Sat, 06 Oct 2012) Log Message: ----------- Modified Paths: -------------- trunk/plugins/VeraControl/DeviceSprinkler.cs trunk/plugins/VeraControl/VeraBox.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/VeraHelper.cs Modified: trunk/plugins/VeraControl/DeviceSprinkler.cs =================================================================== --- trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-09-09 20:42:42 UTC (rev 4510) +++ trunk/plugins/VeraControl/DeviceSprinkler.cs 2012-10-06 20:09:02 UTC (rev 4511) @@ -56,7 +56,7 @@ public override bool status { get { return _status; } - set { + set { if (id > 0) // Only send when a valid ID is found { ReportPendingRequest(); Modified: trunk/plugins/VeraControl/VeraBox.cs =================================================================== --- trunk/plugins/VeraControl/VeraBox.cs 2012-09-09 20:42:42 UTC (rev 4510) +++ trunk/plugins/VeraControl/VeraBox.cs 2012-10-06 20:09:02 UTC (rev 4511) @@ -15,6 +15,7 @@ using System.Threading; using System.Collections.Generic; using System.Xml; +using System.Linq; namespace VeraControl.Properties { @@ -46,122 +47,77 @@ } public Room GetRoomById(int id) { - foreach(Room room in rooms) + var room = from r in rooms where r.id == id select r; + if (room.Count() > 0) { - if (room.id == id) - { - return room; - } + return room.First(); } return new Room(null, 0); } public Section GetSectionById(int id) { - foreach(Section section in sections) + var section = from s in sections where s.id == id select s; + if (section.Count() > 0) { - if (section.id == id) - { - return section; - } + return section.First(); } return new Section(null, 0); } public DeviceGeneric GetDeviceById(int id) { - foreach(DeviceGeneric dev in devices) + var device = from d in devices where d.id == id select d; + if (device.Count() > 0) { - if (dev.id == id) - { - return dev; - } + return device.First(); } return new DeviceGeneric(null, 0); } public Scene GetSceneById(int id) { - foreach(Scene scene in scenes) + var scene = from s in scenes where s.id == id select s; + if (scene.Count() > 0) { - if (scene.id == id) - { - return scene; - } + return scene.First(); } return new Scene(null, 0); } public DevCategories GetCategoryById(int id) { - foreach(DevCategories cat in categories) + var cat = from c in categories where c.id == id select c; + if (cat.Count() > 0) { - if (cat.id == id) - { - return cat; - } + return cat.First(); } return new DevCategories(null); } public bool IsSectionFound(int id) { - foreach(Section section in sections) - { - if (section.id == id) - { - return true; - } - } - return false; + return ((from s in sections where s.id == id select s).Count() > 0); } public bool IsRoomFound(int id) { - foreach(Room room in rooms) - { - if (room.id == id) - { - return true; - } - } - return false; + return ((from r in rooms where r.id == id select r).Count() > 0); } public bool IsDeviceFound(int id) { - foreach(DeviceGeneric dev in devices) - { - if (dev.id == id) - { - return true; - } - } - return false; + return ((from d in devices where d.id == id select d).Count() > 0); } public bool IsSceneFound(int id) { - foreach(Scene scene in scenes) - { - if (scene.id == id) - { - return true; - } - } - return false; + return ((from s in scenes where s.id == id select s).Count() > 0); } public bool IsCategoryFound(int id) { - foreach(DevCategories cat in categories) - { - if (cat.id == id) - { - return true; - } - } - return false; + return ((from c in categories where c.id == id select c).Count() > 0); } #endregion } @@ -433,6 +389,9 @@ } } + // TODO: Add non standard json devices; http://192.10.1.240:3480/data_request?id=user_data&output_format=xml + // Dynamic create controls based on the supplied information + // Process Devices xnList = xmlDoc.SelectNodes("/root/devices/device"); foreach (XmlNode xn in xnList) Modified: trunk/plugins/VeraControl/VeraControl.cs =================================================================== --- trunk/plugins/VeraControl/VeraControl.cs 2012-09-09 20:42:42 UTC (rev 4510) +++ trunk/plugins/VeraControl/VeraControl.cs 2012-10-06 20:09:02 UTC (rev 4511) @@ -147,7 +147,7 @@ public VeraControl() { - // TO DO: remove this sleep + // TODO: remove this sleep // Thread.Sleep(5000); } @@ -254,7 +254,7 @@ Player.PlayBackEnded += new Player.EndedHandler(g_Player_PlayBackEnded); Player.PlayBackStarted += new Player.StartedHandler(g_Player_PlayBackStarted); Player.PlayBackStopped += new Player.StoppedHandler(g_Player_PlayBackStopped); - + // Handle MP start-up trigger - do this is a different Thread to not block MP-start up new Thread( () => { _vera.UpdateStatusOfAllBoxes(); @@ -325,7 +325,14 @@ #region Action Trigger Detection private void OnNewAction(Action action) { - + switch(action.wID) + { // This switch is for debug purposes (set breakpoint on next switch to debug Actions add ignore mouse/key actions) + case Action.ActionType.ACTION_KEY_PRESSED: + case Action.ActionType.ACTION_MOUSE_CLICK: + case Action.ActionType.ACTION_MOUSE_DOUBLECLICK: + case Action.ActionType.ACTION_MOUSE_MOVE: + return; + } // Handle global action responders first (Scene triggers need to be handled also when we are not visible) switch(action.wID) { @@ -347,6 +354,25 @@ } break; + // Handle play button in pause mode + case Action.ActionType.ACTION_PLAY: + case Action.ActionType.ACTION_MUSIC_PLAY: + if (Player.IsMusic && _lastAction == Actiontrigger.MUSIC_PAUSED) { + HandleActionTriggers(Actiontrigger.MUSIC_PAUSE_RESUMED); + } else if (Player.IsRadio && _lastAction == Actiontrigger.RADIO_PAUSED) { + HandleActionTriggers(Actiontrigger.RADIO_PAUSE_RESUMED); + } else if (Player.IsTVRecording && _lastAction == Actiontrigger.RECORDING_PAUSED) { + HandleActionTriggers(Actiontrigger.RECORDING_PAUSE_RESUMED); + } else if ((Player.IsTV || Player.IsTimeShifting) && _lastAction == Actiontrigger.TV_PAUSED) { + HandleActionTriggers(Actiontrigger.TV_PAUSE_RESUMED); + } else if (Player.IsVideo && _lastAction == Actiontrigger.VIDEO_PAUSED) { + HandleActionTriggers(Actiontrigger.VIDEO_PAUSE_RESUMED); + } else { + if (_lastAction == Actiontrigger.UNKNOWN_PAUSED) + HandleActionTriggers(Actiontrigger.UNKNOWN_PAUSE_RESUMED); + } + break; + case Action.ActionType.ACTION_EXIT: HandleActionTriggers(Actiontrigger.MP_EXIT); break; Modified: trunk/plugins/VeraControl/VeraHelper.cs =================================================================== --- trunk/plugins/VeraControl/VeraHelper.cs 2012-09-09 20:42:42 UTC (rev 4510) +++ trunk/plugins/VeraControl/VeraHelper.cs 2012-10-06 20:09:02 UTC (rev 4511) @@ -34,7 +34,7 @@ } private static volatile VeraHelper _instance; - private static object _syncRoot = new Object(); + private static object _syncRoot = new Object(); public static VeraHelper Instance { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2013-08-13 09:30:52
|
Revision: 4615 http://sourceforge.net/p/mp-plugins/code/4615 Author: bartev Date: 2013-08-13 09:30:50 +0000 (Tue, 13 Aug 2013) Log Message: ----------- Modified Paths: -------------- trunk/plugins/VeraControl/DevCategories.cs trunk/plugins/VeraControl/Properties/AssemblyInfo.cs trunk/plugins/VeraControl/VeraBox.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/skin/Default/VeraControl.xml trunk/plugins/VeraControl/skin/Default/VeraDialogActionTrigger.xml trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml trunk/plugins/VeraControl/skin/Default/VeraDialogSceneControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml Added Paths: ----------- trunk/plugins/VeraControl/skin/Titan/ trunk/plugins/VeraControl/skin/Titan/VeraControl.xml trunk/plugins/VeraControl/skin/Titan/VeraDialogActionTrigger.xml trunk/plugins/VeraControl/skin/Titan/VeraDialogDeviceControl.xml trunk/plugins/VeraControl/skin/Titan/VeraDialogSceneControl.xml Modified: trunk/plugins/VeraControl/DevCategories.cs =================================================================== --- trunk/plugins/VeraControl/DevCategories.cs 2013-07-24 08:12:30 UTC (rev 4614) +++ trunk/plugins/VeraControl/DevCategories.cs 2013-08-13 09:30:50 UTC (rev 4615) @@ -62,9 +62,9 @@ public string GetIconName() - { + { //reference : http://wiki.micasaverde.com/index.php/Luup_UPNP_Files#Device_Categories switch (id) - { + { case 1: // Interface return "USB_UIRT"; Modified: trunk/plugins/VeraControl/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2013-07-24 08:12:30 UTC (rev 4614) +++ trunk/plugins/VeraControl/Properties/AssemblyInfo.cs 2013-08-13 09:30:50 UTC (rev 4615) @@ -14,7 +14,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Bart Eversdijk")] [assembly: AssemblyProduct("VeraControl")] -[assembly: AssemblyCopyright("Copyright 2012")] +[assembly: AssemblyCopyright("Copyright 2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -28,4 +28,4 @@ // // You can specify all the values or you can use the default the Revision and // Build Numbers by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.1.0")] +[assembly: AssemblyVersion("1.1.0.0")] Modified: trunk/plugins/VeraControl/VeraBox.cs =================================================================== --- trunk/plugins/VeraControl/VeraBox.cs 2013-07-24 08:12:30 UTC (rev 4614) +++ trunk/plugins/VeraControl/VeraBox.cs 2013-08-13 09:30:50 UTC (rev 4615) @@ -403,7 +403,7 @@ } else { _status.system.SetFullReloadFlag(); - // catids: http://wiki.micasaverde.com/index.php/Luup_UPNP_Files + // catids: http://wiki.micasaverde.com/index.php/Luup_UPNP_Files#Device_Categories switch (xn.Attributes["category"].Value) { //case "1": // TODO: Implement interface device ? Modified: trunk/plugins/VeraControl/VeraControl.cs =================================================================== --- trunk/plugins/VeraControl/VeraControl.cs 2013-07-24 08:12:30 UTC (rev 4614) +++ trunk/plugins/VeraControl/VeraControl.cs 2013-08-13 09:30:50 UTC (rev 4615) @@ -30,7 +30,7 @@ using System.Windows; using MediaPortal.Common.Utils; -[assembly: CompatibleVersion("1.1.6.27644")] +[assembly: CompatibleVersion("1.3.100.0","1.1.6.27644")] [assembly: UsesSubsystem("MP.SkinEngine")] [assembly: UsesSubsystem("MP.Config")] @@ -93,11 +93,11 @@ [SkinControlAttribute(33)] protected GUILabelControl _deviceStatusText = null; [SkinControl(500)] protected GUIButtonControl _actionVeraSelectButton = null; - [SkinControl(501)] protected GUIToggleButtonControl _actionTriggerButton = null; + [SkinControl(501)] protected GUICheckButton _actionTriggerButton = null; [SkinControl(502)] protected GUIButtonControl _actionSceneEditButton = null; [SkinControl(503)] protected GUIButtonControl _actionFilterButton = null; [SkinControl(504)] protected GUIButtonControl _actionSortButton = null; - [SkinControl(505)] protected GUIToggleButtonControl _actionAutoRoomButton = null; + [SkinControl(505)] protected GUICheckButton _actionAutoRoomButton = null; [SkinControl(506)] protected GUIButtonControl _actionViewButton = null; @@ -126,7 +126,7 @@ private VeraFilterStyle _selectedFilterOption = VeraFilterStyle.NONE; private bool [] _lastUpdateFailed = new bool[100]; - private string _titleTxt = "Micasa Verde - Vera control"; + private string _titleTxt = "Selected: "; private SortItem [] _sortOptions = new SortItem [] { new SortItem(VeraSortStyle.NO, "No Sorting, keep Vera's sorting", "No"), @@ -296,7 +296,7 @@ OnActionSceneEditButton((GUIButtonControl)control); if (control == _actionTriggerButton) - OnActionTrigger((GUIToggleButtonControl)control); + OnActionTrigger((GUICheckButton)control); if(control == _actionVeraSelectButton) { @@ -313,7 +313,7 @@ OnActionSortButton((GUIButtonControl)control); if (control == _actionAutoRoomButton) - OnActionAutoRoomButton((GUIToggleButtonControl)control); + OnActionAutoRoomButton((GUICheckButton)control); if (control == _actionViewButton) OnActionViewButton((GUIButtonControl)control); @@ -1105,7 +1105,7 @@ } else { _flowList.SelectedListItemIndex = 0; } - _title.Label = _titleTxt + " - Scenes"; + _title.Label = _titleTxt + "Scenes"; } private void FillinSceneInfo(GUIListItem item, Scene scene) @@ -1144,7 +1144,7 @@ } } } - _title.Label = _titleTxt + " - " + _vera.GetRoomById(selectedRoom).name; + _title.Label = _titleTxt + _vera.GetRoomById(selectedRoom).name; } private void ListDevicesPerCategory(int selectedCategory) @@ -1182,7 +1182,7 @@ } } } - _title.Label = _titleTxt + " - " + _vera.GetCategoryById(selectedCategory).name; + _title.Label = _titleTxt + _vera.GetCategoryById(selectedCategory).name; } private void FillinDeviceInfo(GUIListItem item, DeviceGeneric dev) @@ -1324,7 +1324,7 @@ } } - private void OnActionTrigger(GUIToggleButtonControl control) + private void OnActionTrigger(GUICheckButton control) { _enableSceneTrigger = control.Selected; @@ -1480,7 +1480,7 @@ } } - private void OnActionAutoRoomButton(GUIToggleButtonControl control) + private void OnActionAutoRoomButton(GUICheckButton control) { _autoSelectRoom = control.Selected; Modified: trunk/plugins/VeraControl/skin/Default/VeraControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/Default/VeraControl.xml 2013-07-24 08:12:30 UTC (rev 4614) +++ trunk/plugins/VeraControl/skin/Default/VeraControl.xml 2013-08-13 09:30:50 UTC (rev 4615) @@ -9,17 +9,20 @@ <id>1</id> <posX>0</posX> <posY>0</posY> - <width>720</width> - <height>576</height> + <width>960</width> + <height>720</height> <texture>background.png</texture> </control> + +<import>common.time.xml</import> +<import>common.window.xml</import> <control> <description>an Image</description> <type>image</type> <id>2</id> - <posX>10</posX> - <posY>320</posY> + <posX>120</posX> + <posY>520</posY> <width>150</width> <height>180</height> <texture>hover_remote.png</texture> @@ -29,9 +32,9 @@ <type>image</type> <id>30</id> <posX>300</posX> - <posY>530</posY> - <width>20</width> - <height>20</height> + <posY>650</posY> + <width>25</width> + <height>25</height> <texture></texture> <visible>no</visible> </control> @@ -41,7 +44,7 @@ <type>label</type> <id>31</id> <posX>320</posX> - <posY>530</posY> + <posY>650</posY> <label></label> <font>font13</font> <textcolor>90FFFFFF</textcolor> @@ -51,9 +54,9 @@ <type>image</type> <id>32</id> <posX>300</posX> - <posY>500</posY> - <width>20</width> - <height>20</height> + <posY>620</posY> + <width>25</width> + <height>25</height> <texture></texture> <visible>no</visible> </control> @@ -63,7 +66,7 @@ <type>label</type> <id>33</id> <posX>320</posX> - <posY>500</posY> + <posY>620</posY> <label></label> <font>font13</font> <textcolor>90FFFFFF</textcolor> @@ -74,7 +77,7 @@ <type>actiongroup</type> <visible>!Control.HasFocus(200)</visible> <dimColor>00ffffff</dimColor> - <width>263</width> + <width>960</width> <height>473</height> <buttonX>0</buttonX> <buttonY>0</buttonY> @@ -88,28 +91,28 @@ <type>image</type> <posX>15</posX> <posY>63</posY> - <width>206</width> + <width>290</width> <height>472</height> <texture>Backslide.png</texture> <colorDiffuse>fffffffff</colorDiffuse> <visible>!Control.HasFocus(20)+!Control.HasFocus(40)+!Control.HasFocus(50)</visible> - <animation effect="slide" time="150" start="-300,0" reversible="false">visible</animation> - <animation effect="slide" time="150" end="-300,0" reversible="false">hidden</animation> + <animation effect="slide" time="70" start="-300,0" reversible="false">visible</animation> + <animation effect="slide" time="70" end="-300,0" reversible="false">hidden</animation> </control> <control> <description>group element</description> <type>group</type> <visible>!Control.HasFocus(20)+!Control.HasFocus(40)+!Control.HasFocus(50)</visible> - <posX>40</posX> - <posY>97</posY> + <posX>37</posX> + <posY>121</posY> <layout>StackLayout</layout> - <animation effect="slide" time="150" start="-300,0" reversible="false">visible</animation> - <animation effect="slide" time="150" end="-300,0" reversible="false">hidden</animation> + <animation effect="slide" time="70" start="-300,0" reversible="false">visible</animation> + <animation effect="slide" time="70" end="-300,0" reversible="false">hidden</animation> <control> <id>500</id> <description>Box Selector</description> <type>button</type> - <onup>505</onup> + <onup>506</onup> <ondown>501</ondown> <onright>40</onright> <label>Box:</label> @@ -117,15 +120,11 @@ <control> <id>501</id> <description>Enable disable scene triggers</description> - <type>togglebutton</type> + <type>checkbutton</type> <onup>500</onup> <ondown>502</ondown> <onright>40</onright> <label>Scene Triggers</label> - <textureFocus>togglebutton-on-focus.png</textureFocus> - <textureNoFocus>togglebutton-on-nofocus.png</textureNoFocus> - <AltTextureFocus>togglebutton-off-focus.png</AltTextureFocus> - <AltTextureNoFocus>togglebutton-off-nofocus.png</AltTextureNoFocus> </control> <control> <id>502</id> @@ -157,15 +156,11 @@ <control> <id>505</id> <description>Instant Update Room List</description> - <type>togglebutton</type> + <type>checkbutton</type> <onup>504</onup> <ondown>506</ondown> <onright>40</onright> <label>Show list on focus</label> - <textureFocus>togglebutton-on-focus.png</textureFocus> - <textureNoFocus>togglebutton-on-nofocus.png</textureNoFocus> - <AltTextureFocus>togglebutton-off-focus.png</AltTextureFocus> - <AltTextureNoFocus>togglebutton-off-nofocus.png</AltTextureNoFocus> </control> <control> <id>506</id> @@ -189,7 +184,7 @@ <id>20</id> <label>Section:</label> <posX>30</posX> - <posY>55</posY> + <posY>75</posY> <onleft>500</onleft> <onright>50</onright> <ondown>40</ondown> @@ -209,8 +204,8 @@ <showrange>no</showrange> <reverse>no</reverse> <cycleItems>yes</cycleItems> - <height>34</height> - <width>250</width> + <height>40</height> + <width>300</width> <font>font12</font> <shadowAngle>45</shadowAngle> <shadowDistance>1</shadowDistance> @@ -236,9 +231,9 @@ <type>listcontrol</type> <id>40</id> <posX>30</posX> - <posY>85</posY> - <height>300</height> - <width>250</width> + <posY>150</posY> + <height>430</height> + <width>400</width> <spinx>300</spinx> <onup>20</onup> <ondown>20</ondown> @@ -261,74 +256,35 @@ <keepaspectratio>yes</keepaspectratio> </control> </control> + <control> + <description>Cover Flow view</description> + <animation effect="fade" time="150">WindowOpen</animation> + <animation effect="fade" time="250">WindowClose</animation> + <animation effect="slide" time="550" start="1960,0">WindowOpen</animation> + <animation effect="slide" time="250" end="1960,0">WindowClose</animation> - <control> - <description>Cover Flow view</description> <type>coverflow</type> - <colordiffuse>90ffffff</colordiffuse> - <dimColor>90ffffff</dimColor> <id>41</id> <posX>0</posX> <posY>160</posY> - <width>720</width> + <width>950</width> <height>576</height> <onup>20</onup> - <onleft>500</onleft> - <selectedCard>0</selectedCard> - <cardWidth>270</cardWidth> - <cardHeight>270</cardHeight> - <angle>65</angle> - <sideShift>200</sideShift> + <onleft>500</onleft> + <cardWidth>270</cardWidth> + <cardHeight>270</cardHeight> + <sideShift>380</sideShift> <sideGap>90</sideGap> - <sideDepth>400</sideDepth> - <offsetY>0</offsetY> - <selectedOffsetY>0</selectedOffsetY> - <speed>8</speed> - <backgroundDiffuse>FF000000</backgroundDiffuse> - <background>-</background> - <showBackground>no</showBackground> - <foregroundHeight>576</foregroundHeight> - <foregroundWidth>720</foregroundWidth> - <foregroundX>0</foregroundX> - <foregroundY>0</foregroundY> - <foregroundDiffuse>FF000000</foregroundDiffuse> - <foreground>coverflow_foreground.png</foreground> - <showForeground>no</showForeground> - <showFrame>no</showFrame> - <frame>Picture_cover2.png</frame> - <frameFocus>Picture_cover2.png</frameFocus> - <frameWidth>270</frameWidth> - <frameHeight>270</frameHeight> - <spinSpeed>8</spinSpeed> - <unfocusedAlpha>FF</unfocusedAlpha> - <folderPrefix>[</folderPrefix> - <folderSuffix>]</folderSuffix> - <font1>font15</font1> - <font2>font10</font2> - <label1>...</label1> - <label2></label2> - <textColor>FFFFFFFF</textColor> - <remoteColor>FFFF0000</remoteColor> - <playedColor>FFA0D0FF</playedColor> - <downloadColor>FF00FF00</downloadColor> - <selectedColor>FFFFFFFF</selectedColor> - <shadowAngle>45</shadowAngle> - <shadowDistance>0</shadowDistance> - <shadowColor>FF000000</shadowColor> - <label1YOff>-30</label1YOff> - <label2YOff>330</label2YOff> - <pageSize>5</pageSize> - <keepaspectratio>yes</keepaspectratio> - <scrollbarBackground>bar_hor.png</scrollbarBackground> - <scrollbarLeft>mouse_left_horizontal.png</scrollbarLeft> - <scrollbarRight>mouse_right_horizontal.png</scrollbarRight> - <scrollbarYOff>285</scrollbarYOff> - <showScrollbar>no</showScrollbar> - <cards mask="Picturethumbmask.png">Picturethumbmask.png</cards> - </control> + <sideDepth>550</sideDepth> + <angle>65</angle> + <selectedOffsetY>120</selectedOffsetY> + <offsetY>160</offsetY> + <label1YOff>-3000</label1YOff> + <font1>font14</font1> + <showScrollbar>no</showScrollbar> + <showFrame>no</showFrame> + </control> - - <control> <description>group element</description> <type>group</type> @@ -341,10 +297,10 @@ <description>right control</description> <type>listcontrol</type> <id>50</id> - <posX>300</posX> - <posY>55</posY> - <height>460</height> - <width>300</width> + <posX>500</posX> + <posY>150</posY> + <height>500</height> + <width>400</width> <onleft>40</onleft> <onright>500</onright> <scrollOffset>5</scrollOffset> @@ -372,10 +328,12 @@ <control> <type>label</type> - <posX>200</posX> - <posY>17</posY> + <posX>20</posX> + <posY>10</posY> <label>Micasa Verde - Vera control</label> <id>10</id> + <font>font11</font> + <textcolor>ff6FAFE1</textcolor> </control> </controls> </window> Modified: trunk/plugins/VeraControl/skin/Default/VeraDialogActionTrigger.xml =================================================================== --- trunk/plugins/VeraControl/skin/Default/VeraDialogActionTrigger.xml 2013-07-24 08:12:30 UTC (rev 4614) +++ trunk/plugins/VeraControl/skin/Default/VeraDialogActionTrigger.xml 2013-08-13 09:30:50 UTC (rev 4615) @@ -9,8 +9,8 @@ <description>Heading text label</description> <type>label</type> <id>4</id> - <posX>239</posX> - <posY>89</posY> + <posX>245</posX> + <posY>130</posY> <label>181</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -18,26 +18,26 @@ <control> <type>image</type> <id>0</id> - <width>720</width> - <height>576</height> + <width>960</width> + <height>720</height> <texture>black.png</texture> <colordiffuse>40ffffff</colordiffuse> </control> <control> <type>image</type> <id>0</id> - <posX>115</posX> - <posY>64</posY> - <width>545</width> - <height>365</height> + <posX>210</posX> + <posY>100</posY> + <width>550</width> + <height>440</height> <texture>context_background.png</texture> </control> <control> <description>Exit button</description> <type>button</type> <id>2</id> - <posX>585</posX> - <posY>77</posY> + <posX>690</posX> + <posY>130</posY> <width>40</width> <height>40</height> <textureFocus>dialogue_shutdown_focus.png</textureFocus> @@ -56,8 +56,8 @@ <description>Play label</description> <type>label</type> <id>0</id> - <posX>280</posX> - <posY>130</posY> + <posX>380</posX> + <posY>170</posY> <label>2553</label> <font>font10</font> <textcolor>80FFFFFF</textcolor> @@ -66,8 +66,8 @@ <description>Paused label</description> <type>label</type> <id>0</id> - <posX>370</posX> - <posY>130</posY> + <posX>470</posX> + <posY>170</posY> <label>19011</label> <font>font10</font> <textcolor>80FFFFFF</textcolor> @@ -76,8 +76,8 @@ <description>Resume label</description> <type>label</type> <id>0</id> - <posX>460</posX> - <posY>130</posY> + <posX>560</posX> + <posY>170</posY> <label>732</label> <font>font10</font> <textcolor>80FFFFFF</textcolor> @@ -86,8 +86,8 @@ <description>Stop label</description> <type>label</type> <id>0</id> - <posX>550</posX> - <posY>130</posY> + <posX>650</posX> + <posY>170</posY> <label>2552</label> <font>font10</font> <textcolor>80FFFFFF</textcolor> @@ -99,8 +99,8 @@ <description>Music label</description> <type>label</type> <id>0</id> - <posX>150</posX> - <posY>160</posY> + <posX>260</posX> + <posY>200</posY> <label>249</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -109,8 +109,8 @@ <control> <description>Music started</description> <id>20</id> - <posX>280</posX> - <posY>160</posY> + <posX>380</posX> + <posY>200</posY> <onleft>23</onleft> <onright>21</onright> <onup>50</onup> @@ -140,8 +140,8 @@ <control> <description>Music paused</description> <id>21</id> - <posX>370</posX> - <posY>160</posY> + <posX>470</posX> + <posY>200</posY> <onup>51</onup> <ondown>26</ondown> <onleft>20</onleft> @@ -171,8 +171,8 @@ <control> <description>Music resumed</description> <id>22</id> - <posX>460</posX> - <posY>160</posY> + <posX>560</posX> + <posY>200</posY> <onup>52</onup> <ondown>27</ondown> <onleft>21</onleft> @@ -202,8 +202,8 @@ <control> <description>Music stopped</description> <id>23</id> - <posX>550</posX> - <posY>160</posY> + <posX>650</posX> + <posY>200</posY> <onup>2</onup> <ondown>28</ondown> <onleft>22</onleft> @@ -235,8 +235,8 @@ <description>Video label</description> <type>label</type> <id>0</id> - <posX>150</posX> - <posY>190</posY> + <posX>260</posX> + <posY>230</posY> <label>291</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -244,8 +244,8 @@ <control> <description>Video start</description> <id>25</id> - <posX>280</posX> - <posY>190</posY> + <posX>380</posX> + <posY>230</posY> <onup>20</onup> <ondown>30</ondown> <onleft>28</onleft> @@ -275,8 +275,8 @@ <control> <description>Video paused</description> <id>26</id> - <posX>370</posX> - <posY>190</posY> + <posX>470</posX> + <posY>230</posY> <onup>21</onup> <ondown>31</ondown> <onleft>25</onleft> @@ -306,8 +306,8 @@ <control> <description>Video resumed</description> <id>27</id> - <posX>460</posX> - <posY>190</posY> + <posX>560</posX> + <posY>230</posY> <onup>22</onup> <ondown>32</ondown> <onleft>26</onleft> @@ -337,8 +337,8 @@ <control> <description>Video stopped</description> <id>28</id> - <posX>550</posX> - <posY>190</posY> + <posX>650</posX> + <posY>230</posY> <onup>23</onup> <ondown>33</ondown> <onleft>27</onleft> @@ -370,8 +370,8 @@ <description>TV label</description> <type>label</type> <id>0</id> - <posX>150</posX> - <posY>220</posY> + <posX>260</posX> + <posY>260</posY> <label>605</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -379,8 +379,8 @@ <control> <description>TV start</description> <id>30</id> - <posX>280</posX> - <posY>220</posY> + <posX>380</posX> + <posY>260</posY> <onup>25</onup> <ondown>35</ondown> <onleft>33</onleft> @@ -410,8 +410,8 @@ <control> <description>TV paused</description> <id>31</id> - <posX>370</posX> - <posY>220</posY> + <posX>470</posX> + <posY>260</posY> <onup>26</onup> <ondown>36</ondown> <onleft>30</onleft> @@ -441,8 +441,8 @@ <control> <description>TV resumed</description> <id>32</id> - <posX>460</posX> - <posY>220</posY> + <posX>560</posX> + <posY>260</posY> <onup>27</onup> <ondown>37</ondown> <onleft>31</onleft> @@ -472,8 +472,8 @@ <control> <description>TV stopped</description> <id>33</id> - <posX>550</posX> - <posY>220</posY> + <posX>650</posX> + <posY>260</posY> <onup>28</onup> <ondown>38</ondown> <onleft>32</onleft> @@ -505,8 +505,8 @@ <description>Recordings label</description> <type>label</type> <id>0</id> - <posX>150</posX> - <posY>250</posY> + <posX>260</posX> + <posY>290</posY> <label>652</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -514,8 +514,8 @@ <control> <description>Recordings start</description> <id>35</id> - <posX>280</posX> - <posY>250</posY> + <posX>380</posX> + <posY>290</posY> <onup>30</onup> <ondown>40</ondown> <onleft>38</onleft> @@ -545,8 +545,8 @@ <control> <description>Recordings paused</description> <id>36</id> - <posX>370</posX> - <posY>250</posY> + <posX>470</posX> + <posY>290</posY> <onup>31</onup> <ondown>41</ondown> <onleft>35</onleft> @@ -576,8 +576,8 @@ <control> <description>Recordings resumed</description> <id>37</id> - <posX>460</posX> - <posY>250</posY> + <posX>560</posX> + <posY>290</posY> <onup>32</onup> <ondown>42</ondown> <onleft>36</onleft> @@ -607,8 +607,8 @@ <control> <description>Recordings stopped</description> <id>38</id> - <posX>550</posX> - <posY>250</posY> + <posX>650</posX> + <posY>290</posY> <onup>33</onup> <ondown>43</ondown> <onleft>37</onleft> @@ -640,8 +640,8 @@ <description>Radio label</description> <type>label</type> <id>0</id> - <posX>150</posX> - <posY>280</posY> + <posX>260</posX> + <posY>320</posY> <label>862</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -649,8 +649,8 @@ <control> <description>Radio start</description> <id>40</id> - <posX>280</posX> - <posY>280</posY> + <posX>380</posX> + <posY>320</posY> <onup>35</onup> <ondown>45</ondown> <onleft>43</onleft> @@ -680,8 +680,8 @@ <control> <description>Radio paused</description> <id>41</id> - <posX>370</posX> - <posY>280</posY> + <posX>470</posX> + <posY>320</posY> <onup>36</onup> <ondown>46</ondown> <onleft>40</onleft> @@ -711,8 +711,8 @@ <control> <description>Radio resumed</description> <id>42</id> - <posX>460</posX> - <posY>280</posY> + <posX>560</posX> + <posY>320</posY> <onup>37</onup> <ondown>47</ondown> <onleft>41</onleft> @@ -742,8 +742,8 @@ <control> <description>Radio stopped</description> <id>43</id> - <posX>550</posX> - <posY>280</posY> + <posX>650</posX> + <posY>320</posY> <onup>38</onup> <ondown>48</ondown> <onleft>42</onleft> @@ -775,8 +775,8 @@ <description>Unknown label</description> <type>label</type> <id>0</id> - <posX>150</posX> - <posY>310</posY> + <posX>260</posX> + <posY>350</posY> <label>2014</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -784,8 +784,8 @@ <control> <description>Unknown start</description> <id>45</id> - <posX>280</posX> - <posY>310</posY> + <posX>380</posX> + <posY>350</posY> <onup>40</onup> <ondown>50</ondown> <onleft>48</onleft> @@ -815,8 +815,8 @@ <control> <description>Unknown paused</description> <id>46</id> - <posX>370</posX> - <posY>310</posY> + <posX>470</posX> + <posY>350</posY> <onup>41</onup> <ondown>51</ondown> <onleft>45</onleft> @@ -846,8 +846,8 @@ <control> <description>Unknown resumed</description> <id>47</id> - <posX>460</posX> - <posY>310</posY> + <posX>560</posX> + <posY>350</posY> <onup>42</onup> <ondown>52</ondown> <onleft>46</onleft> @@ -877,8 +877,8 @@ <control> <description>Unknown stopped</description> <id>48</id> - <posX>550</posX> - <posY>310</posY> + <posX>650</posX> + <posY>350</posY> <onup>43</onup> <ondown>100</ondown> <onleft>47</onleft> @@ -910,8 +910,8 @@ <description>Startup label</description> <type>label</type> <id>0</id> - <posX>280</posX> - <posY>340</posY> + <posX>380</posX> + <posY>380</posY> <label>3017</label> <font>font10</font> <textcolor>80FFFFFF</textcolor> @@ -920,8 +920,8 @@ <description>Sleep label</description> <type>label</type> <id>0</id> - <posX>370</posX> - <posY>340</posY> + <posX>470</posX> + <posY>380</posY> <label>1032</label> <font>font10</font> <textcolor>80FFFFFF</textcolor> @@ -930,8 +930,8 @@ <description>Exit label</description> <type>label</type> <id>0</id> - <posX>460</posX> - <posY>340</posY> + <posX>560</posX> + <posY>380</posY> <label>1030</label> <font>font10</font> <textcolor>80FFFFFF</textcolor> @@ -941,8 +941,8 @@ <description>MediaPortal label</description> <type>label</type> <id>0</id> - <posX>150</posX> - <posY>370</posY> + <posX>260</posX> + <posY>410</posY> <label>MediaPortal</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -950,8 +950,8 @@ <control> <description>MediaPortal start</description> <id>50</id> - <posX>280</posX> - <posY>370</posY> + <posX>380</posX> + <posY>410</posY> <onup>45</onup> <ondown>20</ondown> <onleft>100</onleft> @@ -981,8 +981,8 @@ <control> <description>MediaPortal Sleep</description> <id>51</id> - <posX>370</posX> - <posY>370</posY> + <posX>470</posX> + <posY>410</posY> <onup>46</onup> <ondown>21</ondown> <onleft>50</onleft> @@ -1012,8 +1012,8 @@ <control> <description>MediaPortal Exit</description> <id>52</id> - <posX>460</posX> - <posY>370</posY> + <posX>560</posX> + <posY>410</posY> <onup>47</onup> <ondown>22</ondown> <onleft>51</onleft> @@ -1045,11 +1045,11 @@ <description>Store button</description> <type>button</type> <id>100</id> - <posX>550</posX> - <posY>360</posY> + <posX>620</posX> + <posY>445</posY> <textXOff>5</textXOff> <textYOff>6</textYOff> - <width>80</width> + <width>100</width> <height>37</height> <textureFocus>button_focus.png</textureFocus> <textureNoFocus>button_nofocus.png</textureNoFocus> Modified: trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml 2013-07-24 08:12:30 UTC (rev 4614) +++ trunk/plugins/VeraControl/skin/Default/VeraDialogDeviceControl.xml 2013-08-13 09:30:50 UTC (rev 4615) @@ -8,26 +8,26 @@ <control> <type>image</type> <id>0</id> - <width>720</width> - <height>576</height> + <width>960</width> + <height>720</height> <texture>black.png</texture> <colordiffuse>40ffffff</colordiffuse> </control> <control> <type>image</type> <id>0</id> - <posX>115</posX> - <posY>64</posY> - <width>545</width> - <height>365</height> + <posX>210</posX> + <posY>100</posY> + <width>550</width> + <height>440</height> <texture>context_background.png</texture> </control> <control> <description>Heading text label</description> <type>label</type> <id>4</id> - <posX>239</posX> - <posY>89</posY> + <posX>245</posX> + <posY>130</posY> <label>181</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -36,8 +36,8 @@ <description>Exit button</description> <type>button</type> <id>2</id> - <posX>585</posX> - <posY>77</posY> + <posX>690</posX> + <posY>130</posY> <width>40</width> <height>40</height> <textureFocus>dialogue_shutdown_focus.png</textureFocus> @@ -52,8 +52,8 @@ <control> <type>image</type> <id>5</id> - <posX>510</posX> - <posY>130</posY> + <posX>580</posX> + <posY>190</posY> <width>100</width> <height>200</height> <texture>Vera\generic_sensor.png</texture> @@ -63,8 +63,8 @@ <description>text label</description> <type>label</type> <id>6</id> - <posX>180</posX> - <posY>130</posY> + <posX>260</posX> + <posY>190</posY> <label>Dit is een label!!!</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -73,8 +73,8 @@ <description>subtext label</description> <type>label</type> <id>7</id> - <posX>180</posX> - <posY>180</posY> + <posX>260</posX> + <posY>230</posY> <label>Dit is label 2</label> <font>font13</font> <textcolor>90FFFFFF</textcolor> @@ -83,8 +83,8 @@ <description>subtext label</description> <type>label</type> <id>8</id> - <posX>180</posX> - <posY>210</posY> + <posX>260</posX> + <posY>270</posY> <label>Dit is label 3</label> <font>font13</font> <textcolor>90FFFFFF</textcolor> @@ -93,20 +93,19 @@ <control> <type>image</type> <id>30</id> - <posX>180</posX> - <posY>240</posY> - <width>20</width> - <height>20</height> + <posX>260</posX> + <posY>350</posY> + <width>30</width> + <height>30</height> <texture></texture> <visible>no</visible> </control> - <control> <description>commment label</description> <type>label</type> <id>31</id> - <posX>200</posX> - <posY>240</posY> + <posX>295</posX> + <posY>350</posY> <label>comment</label> <font>font13</font> <textcolor>90FFFFFF</textcolor> @@ -116,8 +115,8 @@ <description>Left button</description> <type>button</type> <id>10</id> - <posX>180</posX> - <posY>332</posY> + <posX>255</posX> + <posY>445</posY> <textXOff>29</textXOff> <textYOff>6</textYOff> <width>120</width> @@ -137,8 +136,8 @@ <description>Right button</description> <type>button</type> <id>11</id> - <posX>440</posX> - <posY>332</posY> + <posX>595</posX> + <posY>445</posY> <textXOff>31</textXOff> <textYOff>6</textYOff> <width>120</width> @@ -158,8 +157,8 @@ <description>Mode1 button</description> <type>button</type> <id>12</id> - <posX>180</posX> - <posY>300</posY> + <posX>255</posX> + <posY>400</posY> <textXOff>29</textXOff> <textYOff>6</textYOff> <width>120</width> @@ -179,8 +178,8 @@ <description>Mode2 button</description> <type>button</type> <id>13</id> - <posX>310</posX> - <posY>300</posY> + <posX>425</posX> + <posY>400</posY> <textXOff>31</textXOff> <textYOff>6</textYOff> <width>120</width> @@ -200,8 +199,8 @@ <description>Mode3 button</description> <type>button</type> <id>14</id> - <posX>440</posX> - <posY>300</posY> + <posX>595</posX> + <posY>400</posY> <textXOff>31</textXOff> <textYOff>6</textYOff> <width>120</width> @@ -222,8 +221,8 @@ <id>15</id> <description>Dimmable Light</description> <type>slider</type> - <posX>330</posX> - <posY>345</posY> + <posX>385</posX> + <posY>455</posY> <spintype>Int</spintype> <showrange>yes</showrange> <textureSliderBar>osd_slider_bg.png</textureSliderBar> @@ -240,7 +239,7 @@ <description>loading label</description> <type>label</type> <id>57</id> - <posX>400</posX> + <posX>500</posX> <posY>240</posY> <label>Loading image...</label> <font>font13</font> @@ -250,7 +249,7 @@ <control> <type>image</type> <id>20</id> - <posX>340</posX> + <posX>485</posX> <posY>160</posY> <width>600</width> <height>240</height> @@ -260,7 +259,7 @@ <control> <type>image</type> <id>21</id> - <posX>340</posX> + <posX>485</posX> <posY>160</posY> <width>600</width> <height>240</height> @@ -271,11 +270,11 @@ <description>Cam Up</description> <type>button</type> <id>50</id> - <posX>190</posX> - <posY>180</posY> + <posX>295</posX> + <posY>260</posY> <textXOff>29</textXOff> <textYOff>6</textYOff> - <width>80</width> + <width>100</width> <height>32</height> <textureFocus>button_focus.png</textureFocus> <textureNoFocus>button_nofocus.png</textureNoFocus> @@ -293,11 +292,11 @@ <description>Cam left</description> <type>button</type> <id>51</id> - <posX>140</posX> - <posY>220</posY> + <posX>240</posX> + <posY>300</posY> <textXOff>29</textXOff> <textYOff>6</textYOff> - <width>80</width> + <width>100</width> <height>32</height> <textureFocus>button_focus.png</textureFocus> <textureNoFocus>button_nofocus.png</textureNoFocus> @@ -315,11 +314,11 @@ <description>Cam right</description> <type>button</type> <id>52</id> - <posX>240</posX> - <posY>220</posY> + <posX>350</posX> + <posY>300</posY> <textXOff>29</textXOff> <textYOff>6</textYOff> - <width>80</width> + <width>100</width> <height>32</height> <textureFocus>button_focus.png</textureFocus> <textureNoFocus>button_nofocus.png</textureNoFocus> @@ -337,11 +336,11 @@ <description>Cam down</description> <type>button</type> <id>53</id> - <posX>190</posX> - <posY>260</posY> + <posX>295</posX> + <posY>340</posY> <textXOff>29</textXOff> <textYOff>6</textYOff> - <width>80</width> + <width>100</width> <height>32</height> <textureFocus>button_focus.png</textureFocus> <textureNoFocus>button_nofocus.png</textureNoFocus> @@ -359,15 +358,15 @@ <description>Zoom min</description> <type>button</type> <id>55</id> - <posX>140</posX> - <posY>320</posY> + <posX>240</posX> + <posY>400</posY> <textXOff>29</textXOff> <textYOff>6</textYOff> - <width>80</width> + <width>100</width> <height>32</height> <textureFocus>button_focus.png</textureFocus> <textureNoFocus>button_nofocus.png</textureNoFocus> - <label>zoom -</label> + <label>zm -</label> <font>font10</font> <textalign>center</textalign> <textvalign>middle</textvalign> @@ -381,15 +380,15 @@ <description>Zoom plus</description> <type>button</type> <id>56</id> - <posX>240</posX> - <posY>320</posY> + <posX>350</posX> + <posY>400</posY> <textXOff>29</textXOff> <textYOff>6</textYOff> - <width>80</width> + <width>100</width> <height>32</height> <textureFocus>button_focus.png</textureFocus> <textureNoFocus>button_nofocus.png</textureNoFocus> - <label>zoom +</label> + <label>zm +</label> <font>font10</font> <textalign>center</textalign> <textvalign>middle</textvalign> Modified: trunk/plugins/VeraControl/skin/Default/VeraDialogSceneControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/Default/VeraDialogSceneControl.xml 2013-07-24 08:12:30 UTC (rev 4614) +++ trunk/plugins/VeraControl/skin/Default/VeraDialogSceneControl.xml 2013-08-13 09:30:50 UTC (rev 4615) @@ -8,26 +8,26 @@ <control> <type>image</type> <id>0</id> - <width>720</width> - <height>576</height> + <width>960</width> + <height>720</height> <texture>black.png</texture> <colordiffuse>40ffffff</colordiffuse> </control> <control> <type>image</type> <id>0</id> - <posX>115</posX> - <posY>64</posY> - <width>545</width> - <height>365</height> + <posX>210</posX> + <posY>100</posY> + <width>550</width> + <height>440</height> <texture>context_background.png</texture> </control> <control> <description>Heading text label</description> <type>label</type> <id>4</id> - <posX>239</posX> - <posY>89</posY> + <posX>245</posX> + <posY>130</posY> <label>181</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -36,8 +36,8 @@ <description>Exit button</description> <type>button</type> <id>2</id> - <posX>585</posX> - <posY>77</posY> + <posX>690</posX> + <posY>130</posY> <width>40</width> <height>40</height> <textureFocus>dialogue_shutdown_focus.png</textureFocus> @@ -52,8 +52,8 @@ <control> <type>image</type> <id>5</id> - <posX>500</posX> - <posY>130</posY> + <posX>580</posX> + <posY>190</posY> <width>150</width> <height>150</height> <texture>hover_my videos.png</texture> @@ -63,8 +63,8 @@ <description>text label</description> <type>label</type> <id>6</id> - <posX>200</posX> - <posY>150</posY> + <posX>260</posX> + <posY>230</posY> <label>Dit is een label!!!</label> <font>font13</font> <textcolor>FFFFFFFF</textcolor> @@ -72,10 +72,10 @@ <control> <type>image</type> <id>30</id> - <posX>180</posX> - <posY>240</posY> - <width>20</width> - <height>20</height> + <posX>260</posX> + <posY>370</posY> + <width>30</width> + <height>30</height> <texture></texture> <visible>no</visible> </control> @@ -83,8 +83,8 @@ <description>commment label</description> <type>label</type> <id>31</id> - <posX>200</posX> - <posY>240</posY> + <posX>295</posX> + <posY>370</posY> <label>comment</label> <font>font13</font> <textcolor>90FFFFFF</textcolor> @@ -94,8 +94,8 @@ <description>Run button</description> <type>button</type> <id>11</id> - <posX>330</posX> - <posY>332</posY> + <posX>430</posX> + <posY>445</posY> <textXOff>31</textXOff> <textYOff>6</textYOff> <width>120</width> Modified: trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml 2013-07-24 08:12:30 UTC (rev 4614) +++ trunk/plugins/VeraControl/skin/DefaultWide/VeraControl.xml 2013-08-13 09:30:50 UTC (rev 4615) @@ -13,15 +13,18 @@ <height>720</height> <texture>background.png</texture> </control> + +<import>common.time.xml</import> +<import>common.window.xml</import> <control> <description>an Image</description> <type>image</type> <id>2</id> - <posX>20</posX> - <posY>400</posY> - <width>350</width> - <height>250</height> + <posX>120</posX> + <posY>490</posY> + <width>300</width> + <height>200</height> <texture>hover_remote.png</texture> </control> @@ -117,15 +120,11 @@ <control> <id>501</id> <description>Enable disable scene triggers</description> - <type>togglebutton</type> + <type>checkbutton</type> <onup>500</onup> <ondown>502</ondown> <onright>40</onright> <label>Scene Triggers</label> - <textureFocus>togglebutton-on-focus.png</textureFocus> - <textureNoFocus>togglebutton-on-nofocus.png</textureNoFocus> - <AltTextureFocus>togglebutton-off-focus.png</AltTextureFocus> - <AltTextureNoFocus>togglebutton-off-nofocus.png</AltTextureNoFocus> </control> <control> <id>502</id> @@ -157,15 +156,11 @@ <control> <id>505</id> <description>Instant Update Room List</description> - <type>togglebutton</type> + <type>checkbutton</type> <onup>504</onup> <ondown>506</ondown> <onright>40</onright> <label>Show list on focus</label> - <textureFocus>togglebutton-on-focus.png</textureFocus> - <textureNoFocus>togglebutton-on-nofocus.png</textureNoFocus> - <AltTextureFocus>togglebutton-off-focus.png</AltTextureFocus> - <AltTextureNoFocus>togglebutton-off-nofocus.png</AltTextureNoFocus> </control> <control> <id>506</id> @@ -185,7 +180,7 @@ <id>20</id> <label>Section:</label> <posX>60</posX> - <posY>70</posY> + <posY>78</posY> <onleft>500</onleft> <onright>50</onright> <onup>40</onup> @@ -205,7 +200,7 @@ <reverse>no</reverse> <cycleItems>yes</cycleItems> <height>34</height> - <width>500</width> + <width>350</width> <font>font10</font> <shadowAngle>45</shadowAngle> <shadowDistance>1</shadowDistance> @@ -231,8 +226,8 @@ <type>listcontrol</type> <id>40</id> <posX>60</posX> - <posY>110</posY> - <height>360</height> + <posY>140</posY> + <height>410</height> <width>500</width> <onup>20</onup> <ondown>20</ondown> @@ -259,71 +254,36 @@ <spinColor>00ffffff</spinColor> <suffix>|</suffix> </control> - </control> - <control> - <description>Cover Flow view</description> + </control> + + <control> + <description>Cover Flow view</description> + <animation effect="fade" time="150">WindowOpen</animation> + <animation effect="fade" time="250">WindowClose</animation> + <animation effect="slide" time="550" start="1960,0">WindowOpen</animation> + <animation effect="slide" time="250" end="1960,0">WindowClose</animation> + <type>coverflow</type> - <colordiffuse>90ffffff</colordiffuse> - <dimColor>90ffffff</dimColor> <id>41</id> <posX>0</posX> - <posY>200</posY> + <posY>90</posY> <width>1280</width> - <height>720</height> + <height>576</height> <onup>20</onup> - <onleft>500</onleft> - <selectedCard>0</selectedCard> - <cardWidth>360</cardWidth> - <cardHeight>360</cardHeight> - <angle>65</angle> + <onleft>500</onleft> + <cardWidth>270</cardWidth> + <cardHeight>270</cardHeight> <sideShift>380</sideShift> <sideGap>90</sideGap> - <sideDepth>550</sideDepth> - <offsetY>0</offsetY> - <selectedOffsetY>0</selectedOffsetY> - <speed>8</speed> - <backgroundDiffuse>FF000000</backgroundDiffuse> - <background>-</background> - <showBackground>no</showBackground> - <foregroundHeight>720</foregroundHeight> - <foregroundWidth>1280</foregroundWidth> - <foregroundX>0</foregroundX> - <foregroundY>0</foregroundY> - <foregroundDiffuse>FF000000</foregroundDiffuse> - <foreground>coverflow_foreground.png</foreground> - <showForeground>no</showForeground> - <showFrame>no</showFrame> - <frame>Picture_cover2.png</frame> - <frameFocus>Picture_cover2.png</frameFocus> - <frameWidth>360</frameWidth> - <frameHeight>360</frameHeight> - <spinSpeed>8</spinSpeed> - <unfocusedAlpha>FF</unfocusedAlpha> - <folderPrefix>[</folderPrefix> - <folderSuffix>]</folderSuffix> - <font1>font15</font1> - <font2>font10</font2> - <label1>...</label1> - <label2></label2> - <textColor>FFFFFFFF</textColor> - <remoteColor>FFFF0000</remoteColor> - <playedColor>FFA0D0FF</playedColor> - <downloadColor>FF00FF00</downloadColor> - <selectedColor>FFFFFFFF</selectedColor> - <shadowAngle>45</shadowAngle> - <shadowDistance>0</shadowDistance> - <shadowColor>FF000000</shadowColor> - <label1YOff>-50</label1YOff> - <label2YOff>430</label2YOff> - <pageSize>5</pageSize> - <keepaspectratio>yes</keepaspectratio> - <scrollbarBackground>bar_hor.png</scrollbarBackground> - <scrollbarLeft>mouse_left_horizontal.png</scrollbarLeft> - <scrollbarRight>mouse_right_horizontal.png</scrollbarRight> - <scrollbarYOff>455</scrollbarYOff> - <showScrollbar>no</showScrollbar> - <cards mask="Picturethumbmask.png">Picturethumbmask.png</cards> - </control> + <sideDepth>550</sideDepth> + <angle>65</angle> + <selectedOffsetY>120</selectedOffsetY> + <offsetY>160</offsetY> + <label1YOff>-3000</label1YOff> + <font1>font14</font1> + <showScrollbar>no</showScrollbar> + <showFrame>no</showFrame> + </control> <control> <description>group element</description> @@ -338,8 +298,8 @@ <type>listcontrol</type> <id>50</id> <posX>600</posX> - <posY>70</posY> - <height>560</height> + <posY>140</posY> + <height>490</height> <width>600</width> <onleft>40</onleft> <onright>500</onright> @@ -368,10 +328,12 @@ <control> <type>label</type> - <posX>400</posX> - <posY>17</posY> + <posX>20</posX> + <posY>10</posY> <label>Micasa Verde - Vera control</label> <id>10</id> + <font>font11</font> + <textcolor>ff6FAFE1</textcolor> </control> </controls> </window> Modified: trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml 2013-07-24 08:12:30 UTC (rev 4614) +++ trunk/plugins/VeraControl/skin/DefaultWide/VeraDialogDeviceControl.xml 2013-08-13 09:30:50 UTC (rev 4615) @@ -223,7 +223,7 @@ <description>Dimmable Light</description> <type>slider</type> <id>15</id> - <posX>620</posX> + <posX>580</posX> <posY>460</posY> <spintype>int</spintype> <showrange>yes</showrange> Added: trunk/plugins/VeraControl/skin/Titan/VeraControl.xml =================================================================== --- trunk/plugins/VeraControl/skin/Titan/VeraControl.xml (rev 0) +++ trunk/plugins/VeraControl/skin/Titan/VeraControl.xml 2013-08-13 09:30:50 UTC (rev 4615) @@ -0,0 +1,408 @@ +<window> + <id>1972</id> + <defaultcontrol>40</defaultcontrol> + <define>#header.label:Vera Control</define> + <allowoverlay>yes</allowoverlay> + <controls> + <control> + <description>BackGround</description> + <type>image</type> + <id>1</id> + <posX>0</posX> + <posY>0</posY> + <width>1920</width> + <height>1080</height> + <texture>background.png</texture> + </control> + +<import>common.time.xml</import> +<import>common.overlay.xml</import> + + <control> + <description>an Image</description> + <type>image</type> + <id>2</id> + <posX>120</posX> + <posY>850</posY> + <width>300</width> + <height>200</height> + <texture>vera\IR_Transmitter.png</texture> + </control> + <control> + <description>an Image</description> + <type>image</type> + <id>3</id> + <posX>1780</posX> + <posY>950</posY> + <texture>vera\Zwave.png</texture> + </control> + + <control> + <type>image</type> + <id>30</id> + <posX>700</posX> + <posY>980</posY> + <width>30</width> + <height>30</height> + <texture></texture> + <visible>no</visible> + </control> + + <control> + <description>commment label</description> + <type>label</type> + <id>31</id> + <posX>740</posX> + <posY>980</posY> + <label></label> + <textcolor>90FFFFFF</textcolor> + </control> + + <control> + <type>image</type> + <id>32</id> + <posX>700</posX> + <posY>940</posY> + <width>30</width> + <height>30</height> + <texture></texture> + <visible>no</visible> + </control> + + <control> + <description>commment label</description> + <type>label</type> + <id>33</id> + <posX>740</posX> + <posY>940</posY> + <label></label> + <textcolor>90FFFFFF</textcolor> + </control> + + <control> + <description>action menu</description> + <type>actiongroup</type> + <visible>!Control.HasFocus(200)</visible> + <dimColor>00ffffff</dimColor> + <width>568</width> + <height>900</height> + <buttonX>-460</buttonX> + <buttonY>155</buttonY> + <buttonwidth>499</buttonwidth> + <buttonheight>1080</buttonheight> + <onexit>40</onexit> + <defaultcontrol>500</defaultcontrol> + <textureFocus>-</textureFocus> + <textureNoFocus>Action_nofocus.png</textureNoFocus> + <control> + <type>image</type> + <width>1920</width> + <height>1080</height> + <texture>semi_trans_back_hidden_menu.png</texture> + <colorDiffuse>fffffffff</colorDiffuse> + <visible>!Control.HasFocus(20)+!Control.HasFocus(40)+!Control.HasFocus(50)</visible> + <animation effect="fade" time="450">visible</animation> + <animation effect="fade" time="400">hidden</animation> + </control> + <control> + <type>image</type> + <id>0</id> + <posY>0</posY> + <posX>0</posX> + <width>612</width> + <height>1074</height> + <texture>menu_bg.png</texture> + <visible>!Control.HasFocus(50)</visible> + <animation effect="fade" time="0">WindowClose</animation> + <animation effect="slide" start="-150,0" time="100">visible</animation> + <animation effect="fade" time="50">visible</animation> + <animation effect="fade" time="0">hidden</animation> + </control> + <control> + <description>Menu label</description> + <type>label</type> + <id>1</id> + <posX>116</posX> + <posY>100</posY> + <label>924</label> + <font>fontB16</font> + <textcolor>393939</textcolor> + <visible>!Control.HasFocus(50)</visible> + <animation effect="fade" time="0">WindowClose</animation> + <animation effect="slide" start="-150,0" time="100">visible</animation> + <animation effect="fade" time="50">visible</animation> + <animation effect="fade" time="0">hidden</animation> + </control> + <control> + <description>group element</description> + <type>group</type> + <visible>!Control.HasFocus(20)+!Control.HasFocus(40)+!Control.HasFocus(50)</visible> + <posX>110</posX> + <posY>160</posY> + <layout>StackLayout</layout> + <animation effect="slide" time="150" start="-300,0" reversible="false">visible</animation> + <animation effect="slide" time="150" end="-300,0" reversible="false">hidden</animation> + <control> + <id>500</id> + <description>Box Selector</description> + <type>button</type> + <onup>506</onup> + <ondown>501</ondown> + <onright>40</onright> + <label>Box:</label> + </control> + <control> + <id>501</id> + <description>Enable disable scene triggers</description> + <type>checkbutton</type> + <onup>500</onup> + <ondown>502</ondown> + <onright>40</onright> + <label>Scene Triggers</label> + <textcolorNoFocus>FF444444</textcolorNoFocus> + </control> + <control> + <id>502</id> + <description>Edit Scene triggers</description> + <type>button</type> + <onup>501</onup> + <ondown>503</ondown> + <onright>40</onright> + <label>Edit Scene Triggers</label> + </control> + <control> + <id>503</id> + <description>Device filter</description> + <type>button</type> + <onup>502</onup> + <ondown>504</ondown> + <onright>40</onright> + <label>Filter:</label> + </control> + <control> + <id>504</id> + <description>Sort mode</description> + <type>button</type> + <onup>503</onup> + <ondown>505</ondown> + <onright>40</onright> + <label>Sort:</label> + </control> + <control> + <id>505</id> + <description>Instant Update Room List</description> + <type>checkbutton</type> + <onup>504</onup> + <ondown>506</ondown> + <onright>40</onright> + <label>Show list on focus</label> + <textcolorNoFocus>FF444444</textcolorNoFocus> + </control> + <control> + <id>506</id> + <description>Viewing mode</description> + <type>button</type> + <onup>505</onup> + <ondown>500</ondown> + <onright>40</onright> + <label>View:</label> + </control> + </control> + </control> + + <control> + <description>group element</description> + <type>group</type> + <control> + <type>image</type> + <posX>70</posX> + <posY>110</posY> + <width>560</width> + <height>80</height> + <texture>panel_settings_main.png</texture> + <visible>Control.isvisible(20)</visible> + </control> + <control> + <description>category</description> + <type>spinbutton</type> + <id>20</id> + <label>Section:</label> + <posX>110</posX> + <posY>130</posY> + <onleft>500</onleft> + <onright>50</onright> + <onup>40</onup> + <textureUp>arrow_round_up_nofocus.png</textureUp> + <textureDown>arrow_round_down_nofocus.png</textureDown> + <textureUpFocus>arrow_round_up_focus.png</textureUpFocus> + <textureDownFocus>arrow_round_down_focus.png</textureDownFocus> + <spinWidth>30</spinWidth> + <spinHeight>30</spinHeight> + <spinXOff>20</spinXOff> + <spinTextXOff>7</spinTextXOff> + <spinalign>right</spinalign> + <spinvalign>middle</spinvalign> + <spintype>text</spintype> + <orientation>horizontal</orientation> + <showrange>no</showrange> + <reverse>no</reverse> + <cycleItems>yes</cycleItems> + <height>34</height> + <width>460</width> + <font>font10</font> + <shadowAngle>45</shadowAngle> + <shadowDistance>1</shadowDistance> + <shadowColor>FF000000</shadowColor> + <textcolorFocus>0xffa0d0ff</textcolorFocus> + <textcolorNoFocus>0x60ffffff</textcolorNoFocus> + <textalign>left</textalign> + <textvalign>middle</textvalign> + <textXOff>10</textXOff> + <textureFocus>button_focus.png</textureFocus> + <textureNoFocus>button_nofocus.png</textureNoFocus> + </control> + </control> + + + + <control> + <description>group element</description> + <type>group</type> + <animation effect="fade" time="150">WindowOpen</animation> + <animation effect="fade" time="250">WindowClose</animation> + <animation effect="slide" time="150" start="1900,0">WindowOpen</animation> + <animation effect="slide" time="250" end="1900,0">WindowClose</animation> + <control> + <type>image</type> + <posX>60</posX> + <posY>185</posY> + <width>860</width> + <height>700</height> + <texture>panel_settings_main.png</texture> + <visible>Control.isvisible(40)</visible> + </control> + <control> + <description>left control</description> + <type>listcontrol</type> + <id>40</id> + <posX>110</posX> + <posY>235</posY> + <height>680</height> + <width>760</width> + <onup>20</onup> + <ondown>20</ondown> + <onleft>500</onleft> + <onright>50</onright> + <scrollOffset>5</scrollOffset> + <itemWidth>33</itemWidth> + <itemHeight>33</itemHeight> + <IconXOff>20</IconXOff> + <IconYOff>3</IconYOff> + <textXOff>25</textXOff> + <textYOff>3</textYOff> + <textXOff2>0</textXOff2> + <textYOff2>5</textYOff2> + <textXOff3>75</textXOff3> + <textYOff3>10</textYOff3> + <font>font10</font> + <font2>font10</font2> + <font3>font10</font3> + <keepaspectratio>yes</keepaspectratio> + <spinPosX>1650</spinPosX> + <spinPosY>1250</spinPosY> + <spinCanFocus>no</spinCanFocus> + <spinColor>00ffffff</spinColor> + <suffix>|</suffix> + <unfocusedAlpha applyToAll="true">ff</unfocusedAlpha> + </control> + </control> + <control> + <description>Cover Flow v... [truncated message content] |
From: <ba...@us...> - 2013-08-19 19:54:21
|
Revision: 4619 http://sourceforge.net/p/mp-plugins/code/4619 Author: bartev Date: 2013-08-19 19:54:19 +0000 (Mon, 19 Aug 2013) Log Message: ----------- Fixed UTF8 strings Modified Paths: -------------- trunk/plugins/VeraControl/VeraControl.csproj trunk/plugins/VeraControl/VeraHelper.cs Modified: trunk/plugins/VeraControl/VeraControl.csproj =================================================================== --- trunk/plugins/VeraControl/VeraControl.csproj 2013-08-19 19:50:54 UTC (rev 4618) +++ trunk/plugins/VeraControl/VeraControl.csproj 2013-08-19 19:54:19 UTC (rev 4619) @@ -73,6 +73,7 @@ <Reference Include="System.ServiceModel.Web"> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference> + <Reference Include="System.Web" /> <Reference Include="System.Web.Extensions"> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference> Modified: trunk/plugins/VeraControl/VeraHelper.cs =================================================================== --- trunk/plugins/VeraControl/VeraHelper.cs 2013-08-19 19:50:54 UTC (rev 4618) +++ trunk/plugins/VeraControl/VeraHelper.cs 2013-08-19 19:54:19 UTC (rev 4619) @@ -10,6 +10,9 @@ */ using System; using System.Xml; +using System.Text; +using System.Web; +using System.IO; namespace VeraControl.Properties { @@ -126,7 +129,10 @@ { return def; } - return xn.Attributes[key].Value; + + // Vera send UTF8 strings in ASCII format convert them to real UTF8 strings. + byte[] bytes = Encoding.Default.GetBytes(HttpUtility.UrlDecode(xn.Attributes[key].Value)); + return Encoding.UTF8.GetString(bytes); } public long GetSecondsSince1970() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2014-08-14 21:47:13
|
Revision: 4870 http://sourceforge.net/p/mp-plugins/code/4870 Author: bartev Date: 2014-08-14 21:47:03 +0000 (Thu, 14 Aug 2014) Log Message: ----------- Added direct scene trigger control and MP 1.8.x support Modified Paths: -------------- trunk/plugins/VeraControl/DialogActionTrigger.cs trunk/plugins/VeraControl/DialogDeviceControl.cs trunk/plugins/VeraControl/VeraControl.cs trunk/plugins/VeraControl/VeraControl.csproj trunk/plugins/VeraControl/VeraControl.sln Modified: trunk/plugins/VeraControl/DialogActionTrigger.cs =================================================================== --- trunk/plugins/VeraControl/DialogActionTrigger.cs 2014-08-14 21:45:58 UTC (rev 4869) +++ trunk/plugins/VeraControl/DialogActionTrigger.cs 2014-08-14 21:47:03 UTC (rev 4870) @@ -63,7 +63,18 @@ [SkinControlAttribute(50)] protected GUISpinButton _spMPStart = null; [SkinControlAttribute(51)] protected GUISpinButton _spMPSleep = null; [SkinControlAttribute(52)] protected GUISpinButton _spMPExit = null; - + + [SkinControlAttribute(60)] protected GUISpinButton _spNumkey0 = null; + [SkinControlAttribute(61)] protected GUISpinButton _spNumkey1 = null; + [SkinControlAttribute(62)] protected GUISpinButton _spNumkey2 = null; + [SkinControlAttribute(63)] protected GUISpinButton _spNumkey3 = null; + [SkinControlAttribute(64)] protected GUISpinButton _spNumkey4 = null; + [SkinControlAttribute(65)] protected GUISpinButton _spNumkey5 = null; + [SkinControlAttribute(66)] protected GUISpinButton _spNumkey6 = null; + [SkinControlAttribute(67)] protected GUISpinButton _spNumkey7 = null; + [SkinControlAttribute(68)] protected GUISpinButton _spNumkey8 = null; + [SkinControlAttribute(69)] protected GUISpinButton _spNumkey9 = null; + private VeraCommunication _vera = VeraCommunication.Instance; public DialogActionTrigger() @@ -84,7 +95,9 @@ _spRecStart, _spRecPause, _spRecResume, _spRecStop, _spRadioStart, _spRadioPause, _spRadioResume, _spRadioStop, _spUnknownStart, _spUnknownPause, _spUnknownResume, _spUnknownStop, - _spMPStart, _spMPSleep, _spMPExit + _spMPStart, _spMPSleep, _spMPExit, + _spNumkey0, _spNumkey1, _spNumkey2, _spNumkey3, _spNumkey4, + _spNumkey5, _spNumkey6, _spNumkey7, _spNumkey8, _spNumkey9 }; // (P)re load spin contor @@ -153,7 +166,9 @@ _spRecStart, _spRecPause, _spRecResume, _spRecStop, _spRadioStart, _spRadioPause, _spRadioResume, _spRadioStop, _spUnknownStart, _spUnknownPause, _spUnknownResume, _spUnknownStop, - _spMPStart, _spMPSleep, _spMPExit + _spMPStart, _spMPSleep, _spMPExit, + _spNumkey0, _spNumkey1, _spNumkey2, _spNumkey3, _spNumkey4, + _spNumkey5, _spNumkey6, _spNumkey7, _spNumkey8, _spNumkey9 }; for (int i = 0; i < spinList.Length; i++) { Modified: trunk/plugins/VeraControl/DialogDeviceControl.cs =================================================================== --- trunk/plugins/VeraControl/DialogDeviceControl.cs 2014-08-14 21:45:58 UTC (rev 4869) +++ trunk/plugins/VeraControl/DialogDeviceControl.cs 2014-08-14 21:47:03 UTC (rev 4870) @@ -9,6 +9,7 @@ * E-mail: ba...@ev... */ using System; +using System.Windows; using System.Threading; using System.Collections; using MediaPortal; Modified: trunk/plugins/VeraControl/VeraControl.cs =================================================================== --- trunk/plugins/VeraControl/VeraControl.cs 2014-08-14 21:45:58 UTC (rev 4869) +++ trunk/plugins/VeraControl/VeraControl.cs 2014-08-14 21:47:03 UTC (rev 4870) @@ -72,6 +72,17 @@ MP_SHUTDOWN, MP_EXIT, + NUMKEY_0, + NUMKEY_1, + NUMKEY_2, + NUMKEY_3, + NUMKEY_4, + NUMKEY_5, + NUMKEY_6, + NUMKEY_7, + NUMKEY_8, + NUMKEY_9, + LAST_ACTIONTRIGGER }; @@ -117,6 +128,7 @@ private long _lastSystemStatusChg = 0; private int _lastSystemStatusId = 0; + private int _directSceneState = 0; // 1 = 1 star = pressed, 2 = 2 stars pressen '0' - '9' num key pressen --> waiting for # to confirm public bool _enableSceneTrigger = false; private bool _autoSelectRoom = true; private bool _viewPerCategory = false; @@ -238,6 +250,7 @@ { _selectedRoom = ALL; _selectedSection = ALL; + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings()) { @@ -327,12 +340,20 @@ { switch(action.wID) { // This switch is for debug purposes (set breakpoint on next switch to debug Actions add ignore mouse/key actions) - case Action.ActionType.ACTION_KEY_PRESSED: case Action.ActionType.ACTION_MOUSE_CLICK: case Action.ActionType.ACTION_MOUSE_DOUBLECLICK: case Action.ActionType.ACTION_MOUSE_MOVE: return; } + + + switch(action.wID) + { + + default: + break; + } + // Handle global action responders first (Scene triggers need to be handled also when we are not visible) switch(action.wID) { @@ -385,6 +406,80 @@ HandleActionTriggers(Actiontrigger.MP_SHUTDOWN); break; + // This case is for handling direct scene request **<num># + case Action.ActionType.ACTION_KEY_PRESSED: + // 1 = 1 star = pressed, 2 = 2 stars pressed, '0' - '9' num key pressed --> waiting for # to confirm + if (action.m_key.KeyChar == '*' && _directSceneState <= 1) + { + this._directSceneState++; + + // TODO: prevent key-pressed action from begin handled further by MP + break; + } + + if (_directSceneState == 2 && action.m_key.KeyChar >= '0' && action.m_key.KeyChar <= '9') + { + // Store selected scene key number + this._directSceneState = action.m_key.KeyChar; + + // TODO: prevent key-pressed action from begin handled further by MP + break; + } + + if (_directSceneState >= '0' && _directSceneState <= '9' && action.m_key.KeyChar == '#') + { + #region Yes we have a go for Scene execution! + Log.Info("Action Key pressed run scene for key: " + this._directSceneState); + switch (this._directSceneState) + { + case '0': + HandleActionTriggers(Actiontrigger.NUMKEY_0); + break; + + case '1': + HandleActionTriggers(Actiontrigger.NUMKEY_1); + break; + + case '2': + HandleActionTriggers(Actiontrigger.NUMKEY_2); + break; + + case '3': + HandleActionTriggers(Actiontrigger.NUMKEY_3); + break; + + case '4': + HandleActionTriggers(Actiontrigger.NUMKEY_4); + break; + + case '5': + HandleActionTriggers(Actiontrigger.NUMKEY_5); + break; + + case '6': + HandleActionTriggers(Actiontrigger.NUMKEY_6); + break; + + case '7': + HandleActionTriggers(Actiontrigger.NUMKEY_7); + break; + + case '8': + HandleActionTriggers(Actiontrigger.NUMKEY_8); + break; + + case '9': + HandleActionTriggers(Actiontrigger.NUMKEY_9); + break; + } + #endregion + // TODO: prevent key-pressed action from begin handled further by MP + } + + // Reset direct scene state + _directSceneState = 0; + break; + // Resume ? how to determine (Plug in init?) default: break; @@ -402,6 +497,7 @@ case Action.ActionType.ACTION_MOUSE_MOVE: break; + // Handle menu info key case Action.ActionType.ACTION_CONTEXT_MENU: case Action.ActionType.ACTION_SHOW_INFO: ShowInfoDialog(); Modified: trunk/plugins/VeraControl/VeraControl.csproj =================================================================== --- trunk/plugins/VeraControl/VeraControl.csproj 2014-08-14 21:45:58 UTC (rev 4869) +++ trunk/plugins/VeraControl/VeraControl.csproj 2014-08-14 21:47:03 UTC (rev 4870) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> <PropertyGroup> <ProjectGuid>{B403D22F-BFFF-41F5-846E-E60586CFB39F}</ProjectGuid> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> @@ -7,7 +7,7 @@ <OutputType>Library</OutputType> <RootNamespace>VeraControl</RootNamespace> <AssemblyName>VeraControl</AssemblyName> - <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkProfile>Client</TargetFrameworkProfile> <AppDesignerFolder>Properties</AppDesignerFolder> <SourceAnalysisOverrideSettingsFile>C:\Users\Bart\AppData\Roaming\ICSharpCode/SharpDevelop4\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile> @@ -47,29 +47,32 @@ </PropertyGroup> <ItemGroup> <Reference Include="Common.Utils"> - <HintPath>..\..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Common.Utils.dll</HintPath> + <HintPath>..\..\..\..\..\Program Files %28x86%29\Team MediaPortal\MediaPortal\Common.Utils.dll</HintPath> </Reference> <Reference Include="Core"> - <HintPath>..\..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Core.dll</HintPath> + <HintPath>..\..\..\..\..\Program Files %28x86%29\Team MediaPortal\MediaPortal\Core.dll</HintPath> </Reference> <Reference Include="Dialogs"> - <HintPath>..\..\..\..\..\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\Dialogs.dll</HintPath> + <HintPath>..\..\..\..\..\Program Files %28x86%29\Team MediaPortal\MediaPortal\plugins\Windows\Dialogs.dll</HintPath> </Reference> <Reference Include="MediaFoundation"> - <HintPath>..\..\..\..\..\Program Files\Team MediaPortal\MediaPortal\MediaFoundation.dll</HintPath> + <HintPath>..\..\..\..\..\Program Files %28x86%29\Team MediaPortal\MediaPortal\MediaFoundation.dll</HintPath> </Reference> + <Reference Include="PresentationCore"> + <RequiredTargetFramework>3.0</RequiredTargetFramework> + </Reference> <Reference Include="RemotePlugins"> - <HintPath>..\..\..\..\..\Program Files\Team MediaPortal\MediaPortal\RemotePlugins.dll</HintPath> + <HintPath>..\..\..\..\..\Program Files %28x86%29\Team MediaPortal\MediaPortal\RemotePlugins.dll</HintPath> </Reference> <Reference Include="System" /> <Reference Include="System.Core"> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference> <Reference Include="System.Drawing" /> - <Reference Include="System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> + <Reference Include="System.Runtime.Serialization"> <RequiredTargetFramework>3.0</RequiredTargetFramework> </Reference> - <Reference Include="System.Runtime.Serialization.Formatters.Soap, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> + <Reference Include="System.Runtime.Serialization.Formatters.Soap" /> <Reference Include="System.ServiceModel.Web"> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference> @@ -77,16 +80,18 @@ <Reference Include="System.Web.Extensions"> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference> + <Reference Include="System.Windows" /> <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xml" /> <Reference Include="System.Xml.Linq"> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference> <Reference Include="Utils"> - <HintPath>..\..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Utils.dll</HintPath> + <HintPath>..\..\..\..\..\Program Files %28x86%29\Team MediaPortal\MediaPortal\Utils.dll</HintPath> </Reference> <Reference Include="WindowPlugins"> - <HintPath>..\..\..\..\..\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\WindowPlugins.dll</HintPath> + <HintPath>..\..\..\..\..\Program Files %28x86%29\Team MediaPortal\MediaPortal\plugins\Windows\WindowPlugins.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> Modified: trunk/plugins/VeraControl/VeraControl.sln =================================================================== --- trunk/plugins/VeraControl/VeraControl.sln 2014-08-14 21:45:58 UTC (rev 4869) +++ trunk/plugins/VeraControl/VeraControl.sln 2014-08-14 21:47:03 UTC (rev 4870) @@ -1,7 +1,7 @@ -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -# SharpDevelop 4.1.0.8000 +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# SharpDevelop 4.4 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VeraControl", "VeraControl.csproj", "{B403D22F-BFFF-41F5-846E-E60586CFB39F}" EndProject Global This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |