From 374ead41fb3fe981279e41c98bddd6dd0b8a2735 Mon Sep 17 00:00:00 2001 From: nastymorbol <nastymorbol@gmail.com> Date: Wed, 21 Mar 2018 03:50:59 +0100 Subject: [PATCH 1/2] Example update to BACnet Version 1.0.20-beta --- .gitignore | 3 +- .../AnotherStorageImplementation.csproj | 181 +++++++++--------- .../BacnetObjects/NotificationClass.cs | 14 +- 3 files changed, 102 insertions(+), 96 deletions(-) diff --git a/.gitignore b/.gitignore index 61fdd38..aebafaa 100644 --- a/.gitignore +++ b/.gitignore @@ -249,4 +249,5 @@ paket-files/ # JetBrains Rider .idea/ -*.sln.iml \ No newline at end of file +*.sln.iml +AnotherStorageImplementation/packages.config diff --git a/AnotherStorageImplementation/AnotherStorageImplementation.csproj b/AnotherStorageImplementation/AnotherStorageImplementation.csproj index 73a8b01..8a304d7 100644 --- a/AnotherStorageImplementation/AnotherStorageImplementation.csproj +++ b/AnotherStorageImplementation/AnotherStorageImplementation.csproj @@ -1,95 +1,100 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">x86</Platform> - <ProductVersion>8.0.30703</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{EE8E3C58-371E-4164-93DA-13D055D5BDDE}</ProjectGuid> - <OutputType>Exe</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>BaCSharp</RootNamespace> - <AssemblyName>AnotherStorageImplementation</AssemblyName> - <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> - <TargetFrameworkProfile>Client</TargetFrameworkProfile> - <FileAlignment>512</FileAlignment> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> - <DebugSymbols>true</DebugSymbols> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <DebugType>full</DebugType> - <PlatformTarget>AnyCPU</PlatformTarget> - <ErrorReport>prompt</ErrorReport> - <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <Optimize>true</Optimize> - <DebugType>pdbonly</DebugType> - <PlatformTarget>AnyCPU</PlatformTarget> - <ErrorReport>prompt</ErrorReport> - <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> - </PropertyGroup> - <ItemGroup> - <Reference Include="BACnet, Version=1.0.8.5, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\packages\BACnet.1.0.8.5-alpha\lib\net40\BACnet.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> - <HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net40\Newtonsoft.Json.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="PacketDotNet, Version=0.13.0.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\packages\PacketDotNet.0.13.0\lib\net\PacketDotNet.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="SharpPcap, Version=4.2.0.0, Culture=neutral, processorArchitecture=MSIL"> - <HintPath>..\packages\SharpPcap.4.2.0\lib\net\SharpPcap.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="System" /> - <Reference Include="System.Core" /> - <Reference Include="Microsoft.CSharp" /> - </ItemGroup> - <ItemGroup> - <Compile Include="BacnetActivity.cs" /> - <Compile Include="BacnetObjects\AnalogInput.cs" /> - <Compile Include="BacnetObjects\AnalogObject.cs" /> - <Compile Include="BacnetObjects\AnalogObjectEvent.cs" /> - <Compile Include="BacnetObjects\AnalogOutput.cs" /> - <Compile Include="BacnetObjects\BacnetFile.cs" /> - <Compile Include="BacnetObjects\BaCSharpObject.cs" /> - <Compile Include="BacnetObjects\BaCSharpType.cs" /> - <Compile Include="BacnetObjects\BinaryInput.cs" /> - <Compile Include="BacnetObjects\BinaryObject.cs" /> - <Compile Include="BacnetObjects\BinaryOutput.cs" /> - <Compile Include="BacnetObjects\Calendar.cs" /> - <Compile Include="BacnetObjects\CharacterString.cs" /> - <Compile Include="BacnetObjects\DeviceObject.cs" /> - <Compile Include="BacnetObjects\MultiStateInput.cs" /> - <Compile Include="BacnetObjects\MultiStateOutput.cs" /> - <Compile Include="BacnetObjects\NotificationClass.cs" /> - <Compile Include="BacnetObjects\Schedule.cs" /> - <Compile Include="BacnetObjects\StructuredView.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="BacnetObjects\TrendLog.cs" /> - <Compile Include="BacnetObjects\TrendLogCustom.cs" /> - <Compile Include="Program.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="Subscription.cs" /> - </ItemGroup> - <ItemGroup> - <None Include="packages.config" /> - </ItemGroup> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">x86</Platform> + <ProductVersion>8.0.30703</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{EE8E3C58-371E-4164-93DA-13D055D5BDDE}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>BaCSharp</RootNamespace> + <AssemblyName>AnotherStorageImplementation</AssemblyName> + <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> + <TargetFrameworkProfile>Client</TargetFrameworkProfile> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> + <DebugSymbols>true</DebugSymbols> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <DebugType>full</DebugType> + <PlatformTarget>AnyCPU</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <Optimize>true</Optimize> + <DebugType>pdbonly</DebugType> + <PlatformTarget>AnyCPU</PlatformTarget> + <ErrorReport>prompt</ErrorReport> + <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> + </PropertyGroup> + <ItemGroup> + <Reference Include="Common.Logging, Version=3.4.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL"> + <HintPath>C:\Users\sschulze.PLUETH\source\repos\BACnetCommand\packages\Common.Logging.3.4.1\lib\net40\Common.Logging.dll</HintPath> + </Reference> + <Reference Include="Common.Logging.Core, Version=3.4.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL"> + <HintPath>C:\Users\sschulze.PLUETH\source\repos\BACnetCommand\packages\Common.Logging.Core.3.4.1\lib\net40\Common.Logging.Core.dll</HintPath> + </Reference> + <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> + <HintPath>C:\Users\sschulze.PLUETH\source\repos\BACnetCommand\packages\Newtonsoft.Json.11.0.1\lib\net40\Newtonsoft.Json.dll</HintPath> + </Reference> + <Reference Include="PacketDotNet, Version=0.16.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>C:\Users\sschulze.PLUETH\source\repos\BACnetCommand\packages\PacketDotNet.0.16.0\lib\PacketDotNet.dll</HintPath> + </Reference> + <Reference Include="SharpPcap, Version=4.4.0.0, Culture=neutral, processorArchitecture=MSIL"> + <HintPath>C:\Users\sschulze.PLUETH\source\repos\BACnetCommand\packages\SharpPcap.4.4.0\lib\SharpPcap.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="Microsoft.CSharp" /> + </ItemGroup> + <ItemGroup> + <Compile Include="BacnetActivity.cs" /> + <Compile Include="BacnetObjects\AnalogInput.cs" /> + <Compile Include="BacnetObjects\AnalogObject.cs" /> + <Compile Include="BacnetObjects\AnalogObjectEvent.cs" /> + <Compile Include="BacnetObjects\AnalogOutput.cs" /> + <Compile Include="BacnetObjects\BacnetFile.cs" /> + <Compile Include="BacnetObjects\BaCSharpObject.cs" /> + <Compile Include="BacnetObjects\BaCSharpType.cs" /> + <Compile Include="BacnetObjects\BinaryInput.cs" /> + <Compile Include="BacnetObjects\BinaryObject.cs" /> + <Compile Include="BacnetObjects\BinaryOutput.cs" /> + <Compile Include="BacnetObjects\Calendar.cs" /> + <Compile Include="BacnetObjects\CharacterString.cs" /> + <Compile Include="BacnetObjects\DeviceObject.cs" /> + <Compile Include="BacnetObjects\MultiStateInput.cs" /> + <Compile Include="BacnetObjects\MultiStateOutput.cs" /> + <Compile Include="BacnetObjects\NotificationClass.cs" /> + <Compile Include="BacnetObjects\Schedule.cs" /> + <Compile Include="BacnetObjects\StructuredView.cs"> + <SubType>Code</SubType> + </Compile> + <Compile Include="BacnetObjects\TrendLog.cs" /> + <Compile Include="BacnetObjects\TrendLogCustom.cs" /> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Subscription.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\BACnet\BACnet.csproj"> + <Project>{66832876-01fc-4b7c-8d92-54195773fabf}</Project> + <Name>BACnet</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> - --> + --> </Project> \ No newline at end of file diff --git a/AnotherStorageImplementation/BacnetObjects/NotificationClass.cs b/AnotherStorageImplementation/BacnetObjects/NotificationClass.cs index 5cf497b..e35c4c2 100644 --- a/AnotherStorageImplementation/BacnetObjects/NotificationClass.cs +++ b/AnotherStorageImplementation/BacnetObjects/NotificationClass.cs @@ -117,10 +117,10 @@ public void AddReportingRecipient(DeviceReportingRecipient recipient) } public void SendIntrinsectEvent(BacnetObjectId SenderObject, - BacnetEventNotificationData.BacnetNotifyTypes notifyType, - BacnetEventNotificationData.BacnetEventTypes evenType, - BacnetEventNotificationData.BacnetEventStates fromstate, - BacnetEventNotificationData.BacnetEventStates tostate) + BacnetNotifyTypes notifyType, + BacnetEventTypes evenType, + BacnetEventStates fromstate, + BacnetEventStates tostate) { if ((m_PROP_RECIPIENT_LIST == null) || (m_PROP_RECIPIENT_LIST.Count == 0)) @@ -166,11 +166,11 @@ public void SendIntrinsectEvent(BacnetObjectId SenderObject, DoASend = false; // new State is OK ? - if ((tostate == BacnetEventNotificationData.BacnetEventStates.EVENT_STATE_OFFNORMAL) && ((devReportEntry.evenType.value[0] & 1) != 1)) + if ((tostate == BacnetEventStates.EVENT_STATE_OFFNORMAL) && ((devReportEntry.evenType.value[0] & 1) != 1)) DoASend = false; - if ((tostate == BacnetEventNotificationData.BacnetEventStates.EVENT_STATE_NORMAL) && ((devReportEntry.evenType.value[0] & 2) != 2)) + if ((tostate == BacnetEventStates.EVENT_STATE_NORMAL) && ((devReportEntry.evenType.value[0] & 2) != 2)) DoASend = false; - if ((tostate == BacnetEventNotificationData.BacnetEventStates.EVENT_STATE_FAULT) && ((devReportEntry.evenType.value[0] & 4) != 4)) + if ((tostate == BacnetEventStates.EVENT_STATE_FAULT) && ((devReportEntry.evenType.value[0] & 4) != 4)) DoASend = false; // Find the receiver endPoint From a4fea4c3d7d1b7392b423820cbabb2b077a7ae46 Mon Sep 17 00:00:00 2001 From: nastymorbol <nastymorbol@gmail.com> Date: Wed, 21 Mar 2018 03:52:26 +0100 Subject: [PATCH 2/2] Resolved Bug in AnalogObject The Analog Object raised an CHANG_OF_VALUE Event. This was wrong and now raises an CHANGE_OF_STATE Event --- .../BacnetObjects/AnalogObjectEvent.cs | 34 +++++++++---------- AnotherStorageImplementation/packages.config | 14 ++++---- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/AnotherStorageImplementation/BacnetObjects/AnalogObjectEvent.cs b/AnotherStorageImplementation/BacnetObjects/AnalogObjectEvent.cs index 5eb7711..54f11b5 100644 --- a/AnotherStorageImplementation/BacnetObjects/AnalogObjectEvent.cs +++ b/AnotherStorageImplementation/BacnetObjects/AnalogObjectEvent.cs @@ -172,11 +172,11 @@ private void IntrinsicReportingManagement() double ll = Convert.ToDouble(m_PROP_LOW_LIMIT); double db = Convert.ToDouble(m_PROP_DEADBAND); - bool LimitEnabledHigh = (m_PROP_LIMIT_ENABLE.value[0] & (uint)BacnetEventNotificationData.BacnetLimitEnable.EVENT_HIGH_LIMIT_ENABLE) != 0; - bool LimitEnabledLow = (m_PROP_LIMIT_ENABLE.value[0] & (uint)BacnetEventNotificationData.BacnetLimitEnable.EVENT_LOW_LIMIT_ENABLE) != 0; + bool LimitEnabledHigh = (m_PROP_LIMIT_ENABLE.value[0] & (uint)BacnetLimitEnable.EVENT_HIGH_LIMIT_ENABLE) != 0; + bool LimitEnabledLow = (m_PROP_LIMIT_ENABLE.value[0] & (uint)BacnetLimitEnable.EVENT_LOW_LIMIT_ENABLE) != 0; - bool EventToOffNormal = (m_PROP_EVENT_ENABLE.value[0] & (uint)BacnetEventNotificationData.BacnetEventEnable.EVENT_ENABLE_TO_OFFNORMAL) != 0; - bool EventToNormal = (m_PROP_EVENT_ENABLE.value[0] & (uint)BacnetEventNotificationData.BacnetEventEnable.EVENT_ENABLE_TO_NORMAL) != 0; + bool EventToOffNormal = (m_PROP_EVENT_ENABLE.value[0] & (uint)BacnetEventEnable.EVENT_ENABLE_TO_OFFNORMAL) != 0; + bool EventToNormal = (m_PROP_EVENT_ENABLE.value[0] & (uint)BacnetEventEnable.EVENT_ENABLE_TO_NORMAL) != 0; bool NotifyState = false; @@ -185,48 +185,48 @@ private void IntrinsicReportingManagement() switch (fromState) { - case (uint)BacnetEventNotificationData.BacnetEventStates.EVENT_STATE_NORMAL : + case (uint)BacnetEventStates.EVENT_STATE_NORMAL : /* If LimitHigh flag is enabled and Present_Value exceed the High_Limit and Event to Offnormal is enabled then the notification must be done */ if ((pv > hl)&&LimitEnabledHigh) { - toState = (int)BacnetEventNotificationData.BacnetEventStates.EVENT_STATE_HIGH_LIMIT; + toState = (int)BacnetEventStates.EVENT_STATE_HIGH_LIMIT; NotifyState = EventToOffNormal; } /* If LowLimit flag is enabled and Present_Value exceed the Low_Limit and Event to Offnormal is enabled then the notification must be done */ if ((pv < ll)&LimitEnabledLow) { - toState = (int)BacnetEventNotificationData.BacnetEventStates.EVENT_STATE_LOW_LIMIT; + toState = (int)BacnetEventStates.EVENT_STATE_LOW_LIMIT; NotifyState = EventToOffNormal; } break; - case (uint)BacnetEventNotificationData.BacnetEventStates.EVENT_STATE_HIGH_LIMIT: + case (uint)BacnetEventStates.EVENT_STATE_HIGH_LIMIT: /* Present_Value fall below the High_Limit - Deadband ? */ if (pv < (hl - db)) { - toState = (int)BacnetEventNotificationData.BacnetEventStates.EVENT_STATE_NORMAL; + toState = (int)BacnetEventStates.EVENT_STATE_NORMAL; NotifyState = EventToNormal; } /* Present_Value fall below the Low_Limit ? */ if ((pv < ll) && LimitEnabledLow) { - toState = (int)BacnetEventNotificationData.BacnetEventStates.EVENT_STATE_LOW_LIMIT; + toState = (int)BacnetEventStates.EVENT_STATE_LOW_LIMIT; if (!NotifyState) NotifyState = EventToOffNormal; } break; - case (uint)BacnetEventNotificationData.BacnetEventStates.EVENT_STATE_LOW_LIMIT: + case (uint)BacnetEventStates.EVENT_STATE_LOW_LIMIT: /* Present_Value exceed the Low_Limit + Deadband ? */ if (pv > (ll + db)) { - toState = (int)BacnetEventNotificationData.BacnetEventStates.EVENT_STATE_NORMAL; + toState = (int)BacnetEventStates.EVENT_STATE_NORMAL; NotifyState = EventToNormal; } /* Present_Value exceed the High_Limit ? */ if ((pv > hl) && LimitEnabledHigh) { - toState = (int)BacnetEventNotificationData.BacnetEventStates.EVENT_STATE_HIGH_LIMIT; + toState = (int)BacnetEventStates.EVENT_STATE_HIGH_LIMIT; if (!NotifyState) NotifyState = EventToOffNormal; } @@ -256,10 +256,10 @@ the notification must be done */ if (nc!=null) nc.SendIntrinsectEvent( m_PROP_OBJECT_IDENTIFIER, - (BacnetEventNotificationData.BacnetNotifyTypes)m_PROP_NOTIFY_TYPE, - BacnetEventNotificationData.BacnetEventTypes.EVENT_CHANGE_OF_VALUE, - (BacnetEventNotificationData.BacnetEventStates)fromState, - (BacnetEventNotificationData.BacnetEventStates)toState); + (BacnetNotifyTypes)m_PROP_NOTIFY_TYPE, + BacnetEventTypes.EVENT_CHANGE_OF_STATE, + (BacnetEventStates)fromState, + (BacnetEventStates)toState); } } } \ No newline at end of file diff --git a/AnotherStorageImplementation/packages.config b/AnotherStorageImplementation/packages.config index 228619f..214c5ba 100644 --- a/AnotherStorageImplementation/packages.config +++ b/AnotherStorageImplementation/packages.config @@ -1,7 +1,9 @@ -<?xml version="1.0" encoding="utf-8"?> -<packages> - <package id="BACnet" version="1.0.8.5-alpha" targetFramework="net40-client" /> - <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net40-client" /> - <package id="PacketDotNet" version="0.13.0" targetFramework="net40-client" /> - <package id="SharpPcap" version="4.2.0" targetFramework="net40-client" /> +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="BACnet" version="1.0.20-beta" targetFramework="net40-client" /> + <package id="Common.Logging" version="3.4.1" targetFramework="net40-client" /> + <package id="Common.Logging.Core" version="3.4.1" targetFramework="net40-client" /> + <package id="Newtonsoft.Json" version="11.0.1" targetFramework="net40-client" /> + <package id="PacketDotNet" version="0.16.0" targetFramework="net40-client" /> + <package id="SharpPcap" version="4.4.0" targetFramework="net40-client" /> </packages> \ No newline at end of file