├── .gitignore ├── AllExamples.sln ├── AnotherStorageImplementation ├── AnotherStorageImplementation.csproj ├── BacnetActivity.cs ├── BacnetObjects │ ├── AnalogInput.cs │ ├── AnalogObject.cs │ ├── AnalogObjectEvent.cs │ ├── AnalogOutput.cs │ ├── BaCSharpObject.cs │ ├── BaCSharpType.cs │ ├── BacnetFile.cs │ ├── BinaryInput.cs │ ├── BinaryObject.cs │ ├── BinaryOutput.cs │ ├── Calendar.cs │ ├── CharacterString.cs │ ├── DeviceObject.cs │ ├── MultiStateInput.cs │ ├── MultiStateOutput.cs │ ├── NotificationClass.cs │ ├── Schedule.cs │ ├── StructuredView.cs │ ├── TrendLog.cs │ └── TrendLogCustom.cs ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Subscription.cs ├── nuget.config └── packages.config ├── Bacnet.Room.Simulator ├── BACnetActivity.cs ├── Bacnet.Room.Simulator.csproj ├── DeviceStorage.xml ├── DeviceStorageUs.xml ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── ImgMode │ ├── HArret.png │ ├── H_Chaud.png │ └── H_Froid.png ├── Ini.cs ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── README.md ├── RoomModel.cs ├── app.config ├── nuage-soleil-meteo-icone-8152.ico ├── nuget.config └── packages.config ├── BacnetToDatabase ├── BacnetToDatabase.csproj ├── Main.Designer.cs ├── Main.cs ├── Main.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── nuget.config └── packages.config ├── BasicAdviseCOV ├── BasicAdviseCOV.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── nuget.config └── packages.config ├── BasicAlarmListener ├── BasicAlarmListener.csproj ├── DeviceDescriptor.xml ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── nuget.config └── packages.config ├── BasicReadWrite ├── BasicReadWrite.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── nuget.config └── packages.config ├── BasicServer ├── BasicServer.csproj ├── DeviceDescriptor.xml ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── nuget.config └── packages.config ├── DemoBBMD ├── BACnetActivity.cs ├── Config.txt ├── DemoBBMD.csproj ├── DeviceStorage.xml ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── app.config ├── nuget.config └── packages.config ├── MIT_license.txt ├── ObjectBrowseSample ├── App.config ├── ObjectBrowseSample.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── nuget.config └── packages.config ├── README.md └── RaspberrySample ├── DeviceDescriptor.xml ├── FileGPIO.cs ├── MemGPIO.cs ├── Program.cs ├── Properties └── AssemblyInfo.cs ├── RaspberrySample.csproj ├── nuget.config └── packages.config /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | artifacts/ 46 | 47 | *_i.c 48 | *_p.c 49 | *_i.h 50 | *.ilk 51 | *.meta 52 | *.obj 53 | *.pch 54 | *.pdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *.log 65 | *.vspscc 66 | *.vssscc 67 | .builds 68 | *.pidb 69 | *.svclog 70 | *.scc 71 | 72 | # Chutzpah Test files 73 | _Chutzpah* 74 | 75 | # Visual C++ cache files 76 | ipch/ 77 | *.aps 78 | *.ncb 79 | *.opendb 80 | *.opensdf 81 | *.sdf 82 | *.cachefile 83 | *.VC.db 84 | *.VC.VC.opendb 85 | 86 | # Visual Studio profiler 87 | *.psess 88 | *.vsp 89 | *.vspx 90 | *.sap 91 | 92 | # TFS 2012 Local Workspace 93 | $tf/ 94 | 95 | # Guidance Automation Toolkit 96 | *.gpState 97 | 98 | # ReSharper is a .NET coding add-in 99 | _ReSharper*/ 100 | *.[Rr]e[Ss]harper 101 | *.DotSettings.user 102 | 103 | # JustCode is a .NET coding add-in 104 | .JustCode 105 | 106 | # TeamCity is a build add-in 107 | _TeamCity* 108 | 109 | # DotCover is a Code Coverage Tool 110 | *.dotCover 111 | 112 | # NCrunch 113 | _NCrunch_* 114 | .*crunch*.local.xml 115 | nCrunchTemp_* 116 | 117 | # MightyMoose 118 | *.mm.* 119 | AutoTest.Net/ 120 | 121 | # Web workbench (sass) 122 | .sass-cache/ 123 | 124 | # Installshield output folder 125 | [Ee]xpress/ 126 | 127 | # DocProject is a documentation generator add-in 128 | DocProject/buildhelp/ 129 | DocProject/Help/*.HxT 130 | DocProject/Help/*.HxC 131 | DocProject/Help/*.hhc 132 | DocProject/Help/*.hhk 133 | DocProject/Help/*.hhp 134 | DocProject/Help/Html2 135 | DocProject/Help/html 136 | 137 | # Click-Once directory 138 | publish/ 139 | 140 | # Publish Web Output 141 | *.[Pp]ublish.xml 142 | *.azurePubxml 143 | # TODO: Comment the next line if you want to checkin your web deploy settings 144 | # but database connection strings (with potential passwords) will be unencrypted 145 | *.pubxml 146 | *.publishproj 147 | 148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 149 | # checkin your Azure Web App publish settings, but sensitive information contained 150 | # in these scripts will be unencrypted 151 | PublishScripts/ 152 | 153 | # NuGet Packages 154 | *.nupkg 155 | # The packages folder can be ignored because of Package Restore 156 | **/packages/* 157 | # except build/, which is used as an MSBuild target. 158 | !**/packages/build/ 159 | # Uncomment if necessary however generally it will be regenerated when needed 160 | #!**/packages/repositories.config 161 | # NuGet v3's project.json files produces more ignoreable files 162 | *.nuget.props 163 | *.nuget.targets 164 | 165 | # Microsoft Azure Build Output 166 | csx/ 167 | *.build.csdef 168 | 169 | # Microsoft Azure Emulator 170 | ecf/ 171 | rcf/ 172 | 173 | # Windows Store app package directories and files 174 | AppPackages/ 175 | BundleArtifacts/ 176 | Package.StoreAssociation.xml 177 | _pkginfo.txt 178 | 179 | # Visual Studio cache files 180 | # files ending in .cache can be ignored 181 | *.[Cc]ache 182 | # but keep track of directories ending in .cache 183 | !*.[Cc]ache/ 184 | 185 | # Others 186 | ClientBin/ 187 | ~$* 188 | *~ 189 | *.dbmdl 190 | *.dbproj.schemaview 191 | *.pfx 192 | *.publishsettings 193 | node_modules/ 194 | orleans.codegen.cs 195 | 196 | # Since there are multiple workflows, uncomment next line to ignore bower_components 197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 198 | #bower_components/ 199 | 200 | # RIA/Silverlight projects 201 | Generated_Code/ 202 | 203 | # Backup & report files from converting an old project file 204 | # to a newer Visual Studio version. Backup files are not needed, 205 | # because we have git ;-) 206 | _UpgradeReport_Files/ 207 | Backup*/ 208 | UpgradeLog*.XML 209 | UpgradeLog*.htm 210 | 211 | # SQL Server files 212 | *.mdf 213 | *.ldf 214 | 215 | # Business Intelligence projects 216 | *.rdl.data 217 | *.bim.layout 218 | *.bim_*.settings 219 | 220 | # Microsoft Fakes 221 | FakesAssemblies/ 222 | 223 | # GhostDoc plugin setting file 224 | *.GhostDoc.xml 225 | 226 | # Node.js Tools for Visual Studio 227 | .ntvs_analysis.dat 228 | 229 | # Visual Studio 6 build log 230 | *.plg 231 | 232 | # Visual Studio 6 workspace options file 233 | *.opt 234 | 235 | # Visual Studio LightSwitch build output 236 | **/*.HTMLClient/GeneratedArtifacts 237 | **/*.DesktopClient/GeneratedArtifacts 238 | **/*.DesktopClient/ModelManifest.xml 239 | **/*.Server/GeneratedArtifacts 240 | **/*.Server/ModelManifest.xml 241 | _Pvt_Extensions 242 | 243 | # Paket dependency manager 244 | .paket/paket.exe 245 | paket-files/ 246 | 247 | # FAKE - F# Make 248 | .fake/ 249 | 250 | # JetBrains Rider 251 | .idea/ 252 | *.sln.iml -------------------------------------------------------------------------------- /AllExamples.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Bacnet.Room.Simulator", "Bacnet.Room.Simulator\Bacnet.Room.Simulator.csproj", "{07552C4C-AD80-4645-AC91-D6138B5888AA}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnotherStorageImplementation", "AnotherStorageImplementation\AnotherStorageImplementation.csproj", "{EE8E3C58-371E-4164-93DA-13D055D5BDDE}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BacnetToDatabase", "BacnetToDatabase\BacnetToDatabase.csproj", "{AB80ADFC-41DD-4E98-87CB-89C358B9E65D}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicAdviseCOV", "BasicAdviseCOV\BasicAdviseCOV.csproj", "{C501E026-4977-49C6-8DCB-5B9600C17FF1}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicAlarmListener", "BasicAlarmListener\BasicAlarmListener.csproj", "{91C94BC2-B863-4415-AB5F-2C4D02B2F2CE}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicReadWrite", "BasicReadWrite\BasicReadWrite.csproj", "{28F7604F-7DCD-4330-8261-55AEB2B0BAC4}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicServer", "BasicServer\BasicServer.csproj", "{DB89E653-7DBF-45BC-A92E-3754D8091E89}" 19 | EndProject 20 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoBBMD", "DemoBBMD\DemoBBMD.csproj", "{A2CE9357-71B6-40F7-97C7-74AF1E5659A5}" 21 | EndProject 22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RaspberrySample", "RaspberrySample\RaspberrySample.csproj", "{47FC9B60-CC4A-479C-8267-DCEEE53067AC}" 23 | EndProject 24 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ObjectBrowseSample", "ObjectBrowseSample\ObjectBrowseSample.csproj", "{CD8499E5-8FB1-44FC-9B42-BB437C58AAA2}" 25 | EndProject 26 | Global 27 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 28 | Debug|Any CPU = Debug|Any CPU 29 | Release|Any CPU = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 32 | {07552C4C-AD80-4645-AC91-D6138B5888AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {07552C4C-AD80-4645-AC91-D6138B5888AA}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {07552C4C-AD80-4645-AC91-D6138B5888AA}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {07552C4C-AD80-4645-AC91-D6138B5888AA}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {EE8E3C58-371E-4164-93DA-13D055D5BDDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {EE8E3C58-371E-4164-93DA-13D055D5BDDE}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {EE8E3C58-371E-4164-93DA-13D055D5BDDE}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {EE8E3C58-371E-4164-93DA-13D055D5BDDE}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {AB80ADFC-41DD-4E98-87CB-89C358B9E65D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {AB80ADFC-41DD-4E98-87CB-89C358B9E65D}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {AB80ADFC-41DD-4E98-87CB-89C358B9E65D}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {AB80ADFC-41DD-4E98-87CB-89C358B9E65D}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {C501E026-4977-49C6-8DCB-5B9600C17FF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {C501E026-4977-49C6-8DCB-5B9600C17FF1}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {C501E026-4977-49C6-8DCB-5B9600C17FF1}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {C501E026-4977-49C6-8DCB-5B9600C17FF1}.Release|Any CPU.Build.0 = Release|Any CPU 48 | {91C94BC2-B863-4415-AB5F-2C4D02B2F2CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 49 | {91C94BC2-B863-4415-AB5F-2C4D02B2F2CE}.Debug|Any CPU.Build.0 = Debug|Any CPU 50 | {91C94BC2-B863-4415-AB5F-2C4D02B2F2CE}.Release|Any CPU.ActiveCfg = Release|Any CPU 51 | {91C94BC2-B863-4415-AB5F-2C4D02B2F2CE}.Release|Any CPU.Build.0 = Release|Any CPU 52 | {28F7604F-7DCD-4330-8261-55AEB2B0BAC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 53 | {28F7604F-7DCD-4330-8261-55AEB2B0BAC4}.Debug|Any CPU.Build.0 = Debug|Any CPU 54 | {28F7604F-7DCD-4330-8261-55AEB2B0BAC4}.Release|Any CPU.ActiveCfg = Release|Any CPU 55 | {28F7604F-7DCD-4330-8261-55AEB2B0BAC4}.Release|Any CPU.Build.0 = Release|Any CPU 56 | {DB89E653-7DBF-45BC-A92E-3754D8091E89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 57 | {DB89E653-7DBF-45BC-A92E-3754D8091E89}.Debug|Any CPU.Build.0 = Debug|Any CPU 58 | {DB89E653-7DBF-45BC-A92E-3754D8091E89}.Release|Any CPU.ActiveCfg = Release|Any CPU 59 | {DB89E653-7DBF-45BC-A92E-3754D8091E89}.Release|Any CPU.Build.0 = Release|Any CPU 60 | {A2CE9357-71B6-40F7-97C7-74AF1E5659A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 61 | {A2CE9357-71B6-40F7-97C7-74AF1E5659A5}.Debug|Any CPU.Build.0 = Debug|Any CPU 62 | {A2CE9357-71B6-40F7-97C7-74AF1E5659A5}.Release|Any CPU.ActiveCfg = Release|Any CPU 63 | {A2CE9357-71B6-40F7-97C7-74AF1E5659A5}.Release|Any CPU.Build.0 = Release|Any CPU 64 | {47FC9B60-CC4A-479C-8267-DCEEE53067AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 65 | {47FC9B60-CC4A-479C-8267-DCEEE53067AC}.Debug|Any CPU.Build.0 = Debug|Any CPU 66 | {47FC9B60-CC4A-479C-8267-DCEEE53067AC}.Release|Any CPU.ActiveCfg = Release|Any CPU 67 | {47FC9B60-CC4A-479C-8267-DCEEE53067AC}.Release|Any CPU.Build.0 = Release|Any CPU 68 | {CD8499E5-8FB1-44FC-9B42-BB437C58AAA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 69 | {CD8499E5-8FB1-44FC-9B42-BB437C58AAA2}.Debug|Any CPU.Build.0 = Debug|Any CPU 70 | {CD8499E5-8FB1-44FC-9B42-BB437C58AAA2}.Release|Any CPU.ActiveCfg = Release|Any CPU 71 | {CD8499E5-8FB1-44FC-9B42-BB437C58AAA2}.Release|Any CPU.Build.0 = Release|Any CPU 72 | EndGlobalSection 73 | GlobalSection(SolutionProperties) = preSolution 74 | HideSolutionNode = FALSE 75 | EndGlobalSection 76 | EndGlobal 77 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/AnotherStorageImplementation.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {EE8E3C58-371E-4164-93DA-13D055D5BDDE} 9 | Exe 10 | Properties 11 | BaCSharp 12 | AnotherStorageImplementation 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | true 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | full 22 | AnyCPU 23 | prompt 24 | MinimumRecommendedRules.ruleset 25 | 26 | 27 | bin\Release\ 28 | TRACE 29 | true 30 | pdbonly 31 | AnyCPU 32 | prompt 33 | MinimumRecommendedRules.ruleset 34 | 35 | 36 | 37 | ..\packages\BACnet.1.0.8.5-alpha\lib\net40\BACnet.dll 38 | True 39 | 40 | 41 | ..\packages\Newtonsoft.Json.8.0.3\lib\net40\Newtonsoft.Json.dll 42 | True 43 | 44 | 45 | ..\packages\PacketDotNet.0.13.0\lib\net\PacketDotNet.dll 46 | True 47 | 48 | 49 | ..\packages\SharpPcap.4.2.0\lib\net\SharpPcap.dll 50 | True 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Code 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 95 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/AnalogInput.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | 32 | namespace BaCSharp 33 | { 34 | public class AnalogInput : AnalogObject 35 | { 36 | public AnalogInput(int ObjId, String ObjName, String Description, T InitialValue, BacnetUnitsId Unit) 37 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_INPUT, (uint)ObjId), ObjName, Description, InitialValue, Unit) 38 | { 39 | m_PRESENT_VALUE_ReadOnly = true; 40 | } 41 | public AnalogInput(BacnetObjectId ObjId, String ObjName, String Description, T InitialValue, BacnetUnitsId Unit) 42 | : base(ObjId, ObjName, Description, InitialValue, Unit) 43 | { 44 | m_PRESENT_VALUE_ReadOnly = true; 45 | } 46 | public AnalogInput() { } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/AnalogObject.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | 32 | namespace BaCSharp 33 | { 34 | public abstract partial class AnalogObject : BaCSharpObject 35 | { 36 | public uint m_PROP_UNITS; 37 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_ENUMERATED)] 38 | public virtual uint PROP_UNITS 39 | { 40 | get { return m_PROP_UNITS; } 41 | } 42 | public uint m_PROP_EVENT_STATE = 0; 43 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_ENUMERATED)] 44 | public virtual uint PROP_EVENT_STATE 45 | { 46 | get { return m_PROP_EVENT_STATE; } // See BacnetEventNotificationData.BacnetEventStates 47 | } 48 | 49 | public BacnetBitString m_PROP_STATUS_FLAGS = new BacnetBitString(); 50 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_BIT_STRING)] 51 | public virtual BacnetBitString PROP_STATUS_FLAGS 52 | { 53 | get { return m_PROP_STATUS_FLAGS; } 54 | } 55 | 56 | public bool m_PROP_OUT_OF_SERVICE = false; 57 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_BOOLEAN)] 58 | public virtual bool PROP_OUT_OF_SERVICE 59 | { 60 | get { return m_PROP_OUT_OF_SERVICE; } 61 | set { 62 | m_PROP_OUT_OF_SERVICE=value; 63 | m_PROP_STATUS_FLAGS.SetBit((byte)3, value); 64 | ExternalCOVManagement(BacnetPropertyIds.PROP_OUT_OF_SERVICE); 65 | } 66 | } 67 | 68 | public bool m_PRESENT_VALUE_ReadOnly = false; 69 | public T m_PROP_PRESENT_VALUE; 70 | // BacnetSerialize made freely by the stack depending on the type 71 | public virtual T PROP_PRESENT_VALUE 72 | { 73 | get { return m_PROP_PRESENT_VALUE; } 74 | set 75 | { 76 | if (m_PRESENT_VALUE_ReadOnly == false) 77 | { 78 | internal_PROP_PRESENT_VALUE = value; 79 | } 80 | else 81 | ErrorCode_PropertyWrite = ErrorCodes.WriteAccessDenied; 82 | } 83 | } 84 | 85 | // This property shows the same attribut as the previous, but without restriction 86 | // for internal usage, not for network callbacks 87 | public virtual T internal_PROP_PRESENT_VALUE 88 | { 89 | get { return m_PROP_PRESENT_VALUE; } 90 | set 91 | { 92 | if (!value.Equals(m_PROP_PRESENT_VALUE)) 93 | { 94 | m_PROP_PRESENT_VALUE = value; 95 | ExternalCOVManagement(BacnetPropertyIds.PROP_PRESENT_VALUE); 96 | IntrinsicReportingManagement(); 97 | } 98 | } 99 | } 100 | 101 | public AnalogObject() {} 102 | 103 | public AnalogObject(BacnetObjectId ObjId, String ObjName, String Description, T InitialValue, BacnetUnitsId Unit) 104 | : base(ObjId, ObjName, Description) 105 | { 106 | 107 | m_PROP_STATUS_FLAGS.SetBit((byte)0, false); 108 | m_PROP_STATUS_FLAGS.SetBit((byte)1, false); 109 | m_PROP_STATUS_FLAGS.SetBit((byte)2, false); 110 | m_PROP_STATUS_FLAGS.SetBit((byte)3, false); 111 | 112 | m_PROP_UNITS = (uint)Unit; 113 | 114 | m_PROP_PRESENT_VALUE = InitialValue; 115 | 116 | AnalogObjectEvent(); 117 | 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/AnalogOutput.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | 32 | namespace BaCSharp 33 | { 34 | 35 | public class AnalogOutput : AnalogValueAndOutput 36 | { 37 | public AnalogOutput(int ObjId, String ObjName, String Description, T InitialValue, BacnetUnitsId Unit) 38 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_OUTPUT, (uint)ObjId), ObjName, Description, InitialValue, Unit, true) 39 | { 40 | } 41 | public AnalogOutput() { } 42 | } 43 | 44 | public class AnalogValue : AnalogValueAndOutput 45 | { 46 | public AnalogValue(int ObjId, String ObjName, String Description, T InitialValue, BacnetUnitsId Unit, bool WithPriorityArray) 47 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_ANALOG_VALUE, (uint)ObjId), ObjName, Description, InitialValue, Unit, WithPriorityArray) 48 | { 49 | } 50 | public AnalogValue() { } 51 | } 52 | 53 | public class AnalogValueAndOutput : AnalogObject 54 | { 55 | public bool UsePriorityArray = false; 56 | 57 | protected T m_PROP_RELINQUISH_DEFAULT; 58 | // BacnetSerialize made freely by the stack depending on the type 59 | public virtual T PROP_RELINQUISH_DEFAULT 60 | { 61 | get { return m_PROP_RELINQUISH_DEFAULT; } 62 | set { 63 | m_PROP_RELINQUISH_DEFAULT=value; 64 | ExternalCOVManagement(BacnetPropertyIds.PROP_RELINQUISH_DEFAULT); 65 | } 66 | } 67 | 68 | public BacnetValue[] m_PROP_PRIORITY_ARRAY = new BacnetValue[16]; 69 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_NULL)] 70 | public virtual BacnetValue[] PROP_PRIORITY_ARRAY 71 | { 72 | get { return m_PROP_PRIORITY_ARRAY; } 73 | } 74 | 75 | public AnalogValueAndOutput(BacnetObjectId ObjId, String ObjName, String Description, T InitialValue, BacnetUnitsId Unit, bool WithPriorityArray) 76 | : base(ObjId, ObjName, Description, InitialValue, Unit) 77 | { 78 | if (WithPriorityArray == true) 79 | { 80 | UsePriorityArray = true; 81 | m_PROP_RELINQUISH_DEFAULT = InitialValue; 82 | } 83 | 84 | this.m_PRESENT_VALUE_ReadOnly = false; 85 | } 86 | 87 | public AnalogValueAndOutput() { } 88 | 89 | public override void Post_NewtonSoft_Json_Deserialization(DeviceObject device) 90 | { 91 | base.Post_NewtonSoft_Json_Deserialization(device); 92 | 93 | // basic int becom int64 for instance during serialization/deserialization 94 | for (int i = 0; i < 16; i++) 95 | if (m_PROP_PRIORITY_ARRAY[i].Tag!=BacnetApplicationTags.BACNET_APPLICATION_TAG_NULL) 96 | m_PROP_PRIORITY_ARRAY[i] = new BacnetValue(m_PROP_PRIORITY_ARRAY[i].Tag,Convert.ChangeType(m_PROP_PRIORITY_ARRAY[i].Value,typeof(T))); 97 | } 98 | 99 | // Do not shows PROP_PRIORITY_ARRAY & PROP_RELINQUISH_DEFAULT if not in use 100 | protected override uint BacnetMethodNametoId(String Name) 101 | { 102 | if ((UsePriorityArray == false) && ((Name == "get_PROP_PRIORITY_ARRAY") || (Name == "get_PROP_RELINQUISH_DEFAULT"))) // Hide these properties 103 | return (uint)((int)BacnetPropertyIds.MAX_BACNET_PROPERTY_ID); 104 | else 105 | return base.BacnetMethodNametoId(Name); 106 | } 107 | 108 | // Since set_PROP_PRESENT_VALUE offered by the inherited property PROP_PRESENT_VALUE cannot 109 | // receive null value to clear the Priority Array, and do not have the priority 110 | // it is 'override' here with the set2_xxx (which replace set_xx in the call if exist) 111 | public virtual void set2_PROP_PRESENT_VALUE(IList Value, byte WritePriority) 112 | { 113 | if (UsePriorityArray == false) 114 | { 115 | PROP_PRESENT_VALUE = (T)Convert.ChangeType(Value[0].Value, typeof(T)); 116 | //PROP_PRESENT_VALUE = (T) Value[0].Value; 117 | return; 118 | } 119 | else 120 | { 121 | m_PROP_PRIORITY_ARRAY[(int)WritePriority - 1] = Value[0]; 122 | 123 | bool done = false; 124 | for (int i = 0; i < 16; i++) 125 | { 126 | if (m_PROP_PRIORITY_ARRAY[i].Value != null) // A value is OK 127 | { 128 | PROP_PRESENT_VALUE = (T)(T)Convert.ChangeType(m_PROP_PRIORITY_ARRAY[i].Value, typeof(T)); 129 | //PROP_PRESENT_VALUE = (T)m_PROP_PRIORITY_ARRAY[i].Value; 130 | done = true; 131 | break; 132 | } 133 | } 134 | if (done == false) // Nothing in the array : PROP_PRESENT_VALUE = PROP_RELINQUISH_DEFAULT 135 | { 136 | PROP_PRESENT_VALUE = m_PROP_RELINQUISH_DEFAULT; 137 | } 138 | 139 | return; 140 | } 141 | } 142 | 143 | // This will shows a property which is only programmed with methods 144 | // ... just for the example 145 | protected bool binternal = true; 146 | 147 | public virtual IList get2_PROP_OPTIONAL() 148 | { 149 | return new BacnetValue[1] { new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_BOOLEAN, binternal) }; 150 | } 151 | 152 | public virtual void set2_PROP_OPTIONAL(IList Value, byte WritePriority) 153 | { 154 | binternal = (bool)Value[0].Value; 155 | } 156 | 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/BaCSharpType.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | 32 | namespace BaCSharp 33 | { 34 | class BaCSharpTypeAttribute : Attribute 35 | { 36 | public BacnetApplicationTags BacnetNativeType; 37 | 38 | public BaCSharpTypeAttribute(BacnetApplicationTags BacnetNativeType) 39 | { 40 | this.BacnetNativeType = BacnetNativeType; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/BacnetFile.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | using System.IO; 32 | 33 | namespace BaCSharp 34 | { 35 | public class BacnetFile:BaCSharpObject 36 | { 37 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_CHARACTER_STRING)] 38 | public virtual String PROP_FILE_TYPE 39 | { 40 | get { return "Binary"; } 41 | } 42 | public bool m_PROP_READ_ONLY; 43 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_BOOLEAN)] 44 | public virtual bool PROP_READ_ONLY 45 | { 46 | get { return m_PROP_READ_ONLY; } 47 | } 48 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_BOOLEAN)] 49 | public virtual bool PROP_ARCHIVE 50 | { 51 | get { return false; } 52 | } 53 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_ENUMERATED)] 54 | public virtual uint PROP_FILE_ACCESS_METHOD 55 | { 56 | get { return 1; } // FILE_STREAM_ACCESS 57 | } 58 | 59 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_UNSIGNED_INT)] 60 | public virtual uint PROP_FILE_SIZE 61 | { 62 | get { 63 | try 64 | { 65 | FileInfo fi = new FileInfo(FilePath); 66 | return (uint)fi.Length; 67 | } 68 | catch { return 0; } // no way to return -1 or other 69 | } 70 | } 71 | 72 | public String FilePath; 73 | 74 | public BacnetFile(int ObjId, String ObjName, String Description, String FilePath, bool ReadOnly) 75 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_FILE, (uint)ObjId), ObjName, Description) 76 | { 77 | m_PROP_READ_ONLY = ReadOnly; 78 | this.FilePath = FilePath; 79 | } 80 | public BacnetFile() { } 81 | 82 | public virtual byte[] ReadFileBlock(int position, int quantity) 83 | { 84 | try 85 | { 86 | byte[] b=new byte[quantity]; 87 | FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read); 88 | fs.Seek(position, SeekOrigin.Begin); 89 | fs.Read(b,0, quantity); 90 | fs.Close(); 91 | return b; 92 | } 93 | catch{} 94 | 95 | return null; 96 | } 97 | 98 | public virtual bool WriteFileBlock(byte[] block, int position, int quantity) 99 | { 100 | try 101 | { 102 | FileStream fs; 103 | if (position==0) 104 | fs= new FileStream(FilePath, FileMode.Create); 105 | else 106 | fs = new FileStream(FilePath, FileMode.Append); 107 | 108 | fs.Write(block, 0, quantity); 109 | fs.Close(); 110 | return true; 111 | } 112 | catch { } 113 | 114 | return false; 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/BinaryInput.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | 32 | namespace BaCSharp 33 | { 34 | public class BinaryInput : BinaryObject 35 | { 36 | public BinaryInput(int ObjId, String ObjName, String Description, bool InitialValue) 37 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_BINARY_INPUT, (uint)ObjId), ObjName, Description, InitialValue) 38 | { 39 | m_PRESENT_VALUE_ReadOnly = true; 40 | } 41 | public BinaryInput() { } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/BinaryObject.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | 32 | namespace BaCSharp 33 | { 34 | public abstract class BinaryObject : BaCSharpObject 35 | { 36 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_ENUMERATED)] 37 | public virtual uint PROP_POLARITY 38 | { 39 | get { return 0; } 40 | } 41 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_ENUMERATED)] 42 | public virtual uint PROP_EVENT_STATE 43 | { 44 | get { return 0; } 45 | } 46 | 47 | BacnetBitString m_PROP_STATUS_FLAGS = new BacnetBitString(); 48 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_BIT_STRING)] 49 | public virtual BacnetBitString PROP_STATUS_FLAGS 50 | { 51 | get { return m_PROP_STATUS_FLAGS; } 52 | } 53 | 54 | public bool m_PROP_OUT_OF_SERVICE = false; 55 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_BOOLEAN)] 56 | public virtual bool PROP_OUT_OF_SERVICE 57 | { 58 | get { return m_PROP_OUT_OF_SERVICE; } 59 | set 60 | { 61 | m_PROP_OUT_OF_SERVICE = value; 62 | m_PROP_STATUS_FLAGS.SetBit((byte)3, value); 63 | ExternalCOVManagement(BacnetPropertyIds.PROP_OUT_OF_SERVICE); 64 | } 65 | } 66 | 67 | public bool m_PRESENT_VALUE_ReadOnly = false; 68 | public uint m_PROP_PRESENT_VALUE; 69 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_ENUMERATED)] 70 | public virtual uint PROP_PRESENT_VALUE 71 | { 72 | get { return m_PROP_PRESENT_VALUE; } 73 | set 74 | { 75 | if (m_PRESENT_VALUE_ReadOnly == false) 76 | { 77 | if (((value == 0) || (value == 1))) 78 | { 79 | if (value != m_PROP_PRESENT_VALUE) 80 | { 81 | m_PROP_PRESENT_VALUE = value; 82 | ExternalCOVManagement(BacnetPropertyIds.PROP_PRESENT_VALUE); 83 | } 84 | } 85 | else 86 | ErrorCode_PropertyWrite = ErrorCodes.OutOfRange; 87 | } 88 | else 89 | ErrorCode_PropertyWrite = ErrorCodes.WriteAccessDenied; 90 | } 91 | } 92 | 93 | // This property shows the same attribut as the previous, but without restriction 94 | // for internal usage, not for network callbacks 95 | public virtual uint internal_PROP_PRESENT_VALUE 96 | { 97 | get { return m_PROP_PRESENT_VALUE; } 98 | set 99 | { 100 | if (value != m_PROP_PRESENT_VALUE) 101 | { 102 | m_PROP_PRESENT_VALUE = value; ExternalCOVManagement(BacnetPropertyIds.PROP_PRESENT_VALUE); 103 | } 104 | } 105 | } 106 | 107 | public BinaryObject(BacnetObjectId ObjId, String ObjName, String Description, bool InitialValue) 108 | : base(ObjId, ObjName, Description) 109 | { 110 | m_PROP_STATUS_FLAGS.SetBit((byte)0, false); 111 | m_PROP_STATUS_FLAGS.SetBit((byte)1, false); 112 | m_PROP_STATUS_FLAGS.SetBit((byte)2, false); 113 | m_PROP_STATUS_FLAGS.SetBit((byte)3, false); 114 | 115 | m_PROP_PRESENT_VALUE = InitialValue==true ? (uint)1 : 0; 116 | 117 | } 118 | public BinaryObject() { } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/BinaryOutput.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | 32 | namespace BaCSharp 33 | { 34 | public class BinaryOutput : BinaryValueAndOutput 35 | { 36 | public BinaryOutput(int ObjId, String ObjName, String Description, bool InitialValue) 37 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_BINARY_OUTPUT, (uint)ObjId), ObjName, Description, InitialValue, true) 38 | { 39 | } 40 | public BinaryOutput(){} 41 | } 42 | 43 | [Serializable] 44 | public class BinaryValue : BinaryValueAndOutput 45 | { 46 | public BinaryValue(int ObjId, String ObjName, String Description, bool InitialValue, bool WithPriorityArray) 47 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_BINARY_VALUE, (uint)ObjId), ObjName, Description, InitialValue, WithPriorityArray) 48 | { 49 | } 50 | public BinaryValue(){} 51 | } 52 | 53 | [Serializable] 54 | public abstract class BinaryValueAndOutput : BinaryObject 55 | { 56 | public bool UsePriorityArray = false; 57 | 58 | public uint m_PROP_RELINQUISH_DEFAULT; 59 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_ENUMERATED)] 60 | public virtual uint PROP_RELINQUISH_DEFAULT 61 | { 62 | get { return m_PROP_RELINQUISH_DEFAULT; } 63 | set 64 | { 65 | m_PROP_RELINQUISH_DEFAULT = value; 66 | ExternalCOVManagement(BacnetPropertyIds.PROP_PRESENT_VALUE); 67 | } 68 | } 69 | 70 | public BacnetValue[] m_PROP_PRIORITY_ARRAY = new BacnetValue[16]; 71 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_NULL)] 72 | public virtual BacnetValue[] PROP_PRIORITY_ARRAY 73 | { 74 | get { return m_PROP_PRIORITY_ARRAY; } 75 | } 76 | 77 | public BinaryValueAndOutput(BacnetObjectId ObjId, String ObjName, String Description, bool InitialValue, bool WithPriorityArray) 78 | : base(ObjId, ObjName, Description, InitialValue) 79 | { 80 | if (WithPriorityArray == true) 81 | { 82 | UsePriorityArray = true; 83 | m_PROP_RELINQUISH_DEFAULT = InitialValue == true ? (uint)1 : 0; 84 | } 85 | 86 | this.m_PRESENT_VALUE_ReadOnly = false; 87 | } 88 | public BinaryValueAndOutput() { } 89 | 90 | // Do not shows PROP_PRIORITY_ARRAY & PROP_RELINQUISH_DEFAULT if not in use 91 | protected override uint BacnetMethodNametoId(String Name) 92 | { 93 | if ((UsePriorityArray == false) && ((Name == "get_PROP_PRIORITY_ARRAY") || (Name == "get_PROP_RELINQUISH_DEFAULT"))) // Hide these properties 94 | return (uint)((int)BacnetPropertyIds.MAX_BACNET_PROPERTY_ID ); 95 | else 96 | return base.BacnetMethodNametoId(Name); 97 | } 98 | 99 | // Since set_PROP_PRESENT_VALUE offered by the inherited property PROP_PRESENT_VALUE cannot 100 | // receive null value to clear the Priority Array, and do not have the priority 101 | // it is 'override' here with the set2_xxx (which replace set_xx in the call if exist) 102 | public virtual void set2_PROP_PRESENT_VALUE(IList Value, byte WritePriority) 103 | { 104 | if (UsePriorityArray == false) 105 | { 106 | PROP_PRESENT_VALUE = (uint)Value[0].Value; 107 | return; 108 | } 109 | else 110 | { 111 | m_PROP_PRIORITY_ARRAY[(int)WritePriority - 1] = Value[0]; 112 | 113 | bool done = false; 114 | for (int i = 0; i < 16; i++) 115 | { 116 | if (m_PROP_PRIORITY_ARRAY[i].Value != null) // A value is OK 117 | { 118 | PROP_PRESENT_VALUE = (uint)m_PROP_PRIORITY_ARRAY[i].Value; 119 | done = true; 120 | break; 121 | } 122 | } 123 | if (done == false) // Nothing in the array : PROP_PRESENT_VALUE = PROP_RELINQUISH_DEFAULT 124 | { 125 | PROP_PRESENT_VALUE = m_PROP_RELINQUISH_DEFAULT; 126 | } 127 | 128 | return; 129 | } 130 | } 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/Calendar.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | using System.Threading; 32 | 33 | namespace BaCSharp 34 | { 35 | class Calendar: BaCSharpObject 36 | { 37 | 38 | public bool m_PROP_PRESENT_VALUE=false; 39 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_BOOLEAN)] 40 | public virtual bool PROP_PRESENT_VALUE 41 | { 42 | get { return m_PROP_PRESENT_VALUE; } 43 | } 44 | 45 | public BACnetCalendarEntry CalenarEntry = new BACnetCalendarEntry(); 46 | public virtual object PROP_DATE_LIST 47 | { 48 | get { return CalenarEntry; } 49 | set 50 | { 51 | try // null value cause an exception, of course 52 | { 53 | CalenarEntry = (BACnetCalendarEntry)value; 54 | if (CalenarEntry.Entries == null) 55 | CalenarEntry.Entries = new List(); 56 | } 57 | catch { } 58 | 59 | DayChanged(tmrId); 60 | } 61 | } 62 | 63 | private int tmrId = 0; 64 | private object LockObj = new object(); 65 | 66 | public Calendar(int ObjId, String ObjName, String Description) 67 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_CALENDAR,(uint)ObjId), ObjName, Description) 68 | { 69 | CalenarEntry.Entries = new List(); 70 | DayChanged(tmrId); 71 | 72 | } 73 | 74 | public override void Post_NewtonSoft_Json_Deserialization(DeviceObject device) 75 | { 76 | base.Post_NewtonSoft_Json_Deserialization(device); 77 | DayChanged(tmrId); 78 | } 79 | 80 | public override void Dispose() 81 | { 82 | lock (LockObj) 83 | tmrId++; // it is used to 'desactivate the effect' of the timer call sleeping in the ThreadPool 84 | } 85 | 86 | // Two simple methods to add .NET date and range 87 | public void AddDate(DateTime date) 88 | { 89 | BacnetDate bd = new BacnetDate((byte)(date.Year-1900), (byte)date.Month, (byte)date.Day); 90 | CalenarEntry.Entries.Add(bd); 91 | 92 | DayChanged(tmrId); 93 | } 94 | 95 | public void AddRange(DateTime start, DateTime end) 96 | { 97 | BacnetDate st = new BacnetDate((byte)(start.Year-1900), (byte)start.Month, (byte)start.Day); 98 | BacnetDate en = new BacnetDate((byte)(end.Year-1900), (byte)end.Month, (byte)end.Day); 99 | 100 | BacnetDateRange bdr=new BacnetDateRange(st,en); 101 | CalenarEntry.Entries.Add(bdr); 102 | 103 | DayChanged(tmrId); 104 | } 105 | 106 | public void AddEntry(BacnetDateRange bdr) 107 | { 108 | CalenarEntry.Entries.Add(bdr); 109 | } 110 | public void AddEntry(BacnetDate bd) 111 | { 112 | CalenarEntry.Entries.Add(bd); 113 | } 114 | public void AddEntry(BacnetweekNDay bwd) 115 | { 116 | CalenarEntry.Entries.Add(bwd); 117 | } 118 | 119 | Timer tmr; 120 | protected virtual void DayChanged(object o) 121 | { 122 | lock (LockObj) 123 | { 124 | if ((int)o != tmrId) 125 | return; 126 | 127 | tmrId++; // it is used to 'desactivate the effect' of the timer call sleeping in the ThreadPool 128 | 129 | bool NewPresentValue = false; 130 | // Update Present_Value 131 | foreach (object entry in CalenarEntry.Entries) 132 | { 133 | if (entry is BacnetDate) 134 | if (((BacnetDate)entry).IsAFittingDate(DateTime.Now)) 135 | { 136 | NewPresentValue = true; 137 | break; 138 | } 139 | if (entry is BacnetDateRange) 140 | if (((BacnetDateRange)entry).IsAFittingDate(DateTime.Now)) 141 | { 142 | NewPresentValue = true; 143 | break; 144 | } 145 | if (entry is BacnetweekNDay) 146 | if (((BacnetweekNDay)entry).IsAFittingDate(DateTime.Now)) 147 | { 148 | NewPresentValue = true; 149 | break; 150 | } 151 | } 152 | 153 | if (NewPresentValue != m_PROP_PRESENT_VALUE) 154 | { 155 | m_PROP_PRESENT_VALUE = NewPresentValue; 156 | ExternalCOVManagement(BacnetPropertyIds.PROP_PRESENT_VALUE); 157 | } 158 | 159 | // Place a callback for tomorrow 0:0:1 160 | DateTime Now = DateTime.Now; 161 | DateTime Tomorrow = new DateTime(Now.Year, Now.Month, Now.Day, 0, 0, 1).AddDays(1); 162 | tmr = new Timer(new TimerCallback(DayChanged), tmrId, (long)((Tomorrow - Now).TotalMilliseconds), Timeout.Infinite); 163 | } 164 | } 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/CharacterString.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | 32 | namespace BaCSharp 33 | { 34 | public class CharacterString : BaCSharpObject 35 | { 36 | 37 | public BacnetBitString m_PROP_STATUS_FLAGS = new BacnetBitString(); 38 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_BIT_STRING)] 39 | public virtual BacnetBitString PROP_STATUS_FLAGS 40 | { 41 | get { return m_PROP_STATUS_FLAGS; } 42 | } 43 | 44 | public bool m_PRESENT_VALUE_ReadOnly = false; 45 | public String m_PROP_PRESENT_VALUE; 46 | 47 | public virtual String PROP_PRESENT_VALUE 48 | { 49 | get { return m_PROP_PRESENT_VALUE; } 50 | set 51 | { 52 | if (m_PRESENT_VALUE_ReadOnly == false) 53 | { 54 | m_PROP_PRESENT_VALUE = value; 55 | ExternalCOVManagement(BacnetPropertyIds.PROP_PRESENT_VALUE); 56 | } 57 | else 58 | ErrorCode_PropertyWrite = ErrorCodes.WriteAccessDenied; 59 | } 60 | } 61 | 62 | // This property shows the same attribut as the previous, but without restriction 63 | // for internal usage, not for network callbacks 64 | public virtual String internal_PROP_PRESENT_VALUE 65 | { 66 | get { return m_PROP_PRESENT_VALUE; } 67 | set { m_PROP_PRESENT_VALUE = value; ExternalCOVManagement(BacnetPropertyIds.PROP_PRESENT_VALUE); } 68 | } 69 | 70 | public CharacterString(int ObjId, String ObjName, String Description, String InitialValue, bool ReadOnly) 71 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_CHARACTERSTRING_VALUE,(uint)ObjId), ObjName, Description) 72 | { 73 | m_PROP_STATUS_FLAGS.SetBit((byte)0, false); 74 | m_PROP_STATUS_FLAGS.SetBit((byte)1, false); 75 | m_PROP_STATUS_FLAGS.SetBit((byte)2, false); 76 | m_PROP_STATUS_FLAGS.SetBit((byte)3, false); 77 | 78 | m_PRESENT_VALUE_ReadOnly = ReadOnly; 79 | m_PROP_PRESENT_VALUE = InitialValue; 80 | } 81 | public CharacterString() { } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/MultiStateInput.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Linq; 30 | using System.Text; 31 | using System.IO.BACnet; 32 | 33 | namespace BaCSharp 34 | { 35 | 36 | public class MultiStateInput : AnalogInput 37 | { 38 | 39 | public uint m_PROP_NUMBER_OF_STATES; 40 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_UNSIGNED_INT)] 41 | public virtual uint PROP_NUMBER_OF_STATES 42 | { 43 | get { return m_PROP_NUMBER_OF_STATES; } 44 | } 45 | 46 | public BacnetValue[] m_PROP_STATE_TEXT; 47 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_OBJECT_ID)] 48 | public virtual BacnetValue[] PROP_STATE_TEXT 49 | { 50 | get { return m_PROP_STATE_TEXT; } 51 | } 52 | 53 | public MultiStateInput(int ObjId, String ObjName, String Description, uint StatesNumber, uint InitialValue, bool WithPriorityArray) 54 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_MULTI_STATE_INPUT, (uint)ObjId), ObjName, Description, InitialValue, BacnetUnitsId.UNITS_DEGREES_PHASE) 55 | { 56 | // InitialValue must be within 1 and m_PROP_NUMBER_OF_STATES 57 | m_PROP_NUMBER_OF_STATES = StatesNumber; 58 | m_PROP_STATE_TEXT = new BacnetValue[StatesNumber]; 59 | } 60 | public MultiStateInput() { } 61 | 62 | protected override uint BacnetMethodNametoId(String Name) 63 | { 64 | if (Name == "get_PROP_UNITS") // Hide this property 65 | return (uint)((int)BacnetPropertyIds.MAX_BACNET_PROPERTY_ID ); 66 | else 67 | return base.BacnetMethodNametoId(Name); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/MultiStateOutput.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | 32 | namespace BaCSharp 33 | { 34 | 35 | public class MultiStateOutput : MultiStateValueAndOutput 36 | { 37 | public MultiStateOutput(int ObjId, String ObjName, String Description, uint InitialValue, uint StatesNumber) 38 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_MULTI_STATE_OUTPUT, (uint)ObjId), ObjName, Description, InitialValue, StatesNumber, true) 39 | { 40 | } 41 | 42 | public MultiStateOutput() { } 43 | } 44 | 45 | [Serializable] 46 | public class MultiStateValue : MultiStateValueAndOutput 47 | { 48 | public MultiStateValue(int ObjId, String ObjName, String Description, uint InitialValue, uint StatesNumber, bool WithPriorityArray) 49 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_MULTI_STATE_VALUE, (uint)ObjId), ObjName, Description, InitialValue, StatesNumber, WithPriorityArray) 50 | { 51 | } 52 | 53 | public MultiStateValue() { } 54 | } 55 | 56 | // Could be used for MultiStateOutput 57 | // and MultiStateValue 58 | [Serializable] 59 | public abstract class MultiStateValueAndOutput:AnalogValueAndOutput 60 | { 61 | 62 | public uint m_PROP_NUMBER_OF_STATES; 63 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_UNSIGNED_INT)] 64 | public virtual uint PROP_NUMBER_OF_STATES 65 | { 66 | get { return m_PROP_NUMBER_OF_STATES; } 67 | } 68 | 69 | public BacnetValue[] m_PROP_STATE_TEXT; 70 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_OBJECT_ID)] 71 | public virtual BacnetValue[] PROP_STATE_TEXT 72 | { 73 | get { return m_PROP_STATE_TEXT; } 74 | } 75 | 76 | public MultiStateValueAndOutput(BacnetObjectId ObjId, String ObjName, String Description, uint InitialValue, uint StatesNumber, bool WithPriorityArray) 77 | : base(ObjId, ObjName, Description, InitialValue, BacnetUnitsId.UNITS_DEGREES_PHASE, true) 78 | { 79 | // InitialValue must be within 1 and m_PROP_NUMBER_OF_STATES 80 | m_PROP_NUMBER_OF_STATES = StatesNumber; 81 | m_PROP_STATE_TEXT = new BacnetValue[StatesNumber]; 82 | } 83 | 84 | public MultiStateValueAndOutput() { } 85 | 86 | protected override uint BacnetMethodNametoId(String Name) 87 | { 88 | if (Name == "get_PROP_UNITS") // Hide this property 89 | return (uint)((int)BacnetPropertyIds.MAX_BACNET_PROPERTY_ID ); 90 | else 91 | return base.BacnetMethodNametoId(Name); 92 | } 93 | 94 | // Only check the value range, work is after done by the overrided method 95 | public override void set2_PROP_PRESENT_VALUE(IList Value, byte WritePriority) 96 | { 97 | uint newVal = (uint)Value[0].Value; 98 | 99 | if ((newVal > 0) && (newVal <= m_PROP_NUMBER_OF_STATES)) 100 | base.set2_PROP_PRESENT_VALUE(Value, WritePriority); 101 | else 102 | ErrorCode_PropertyWrite=ErrorCodes.OutOfRange; 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/StructuredView.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | 32 | namespace BaCSharp 33 | { 34 | public class StructuredView : BaCSharpObject 35 | { 36 | protected List m_PROP_SUBORDINATE_LIST = new List(); 37 | [BaCSharpType(BacnetApplicationTags.BACNET_APPLICATION_TAG_OBJECT_ID)] 38 | public virtual List PROP_SUBORDINATE_LIST 39 | { 40 | get { return m_PROP_SUBORDINATE_LIST; } 41 | } 42 | 43 | public StructuredView(int ObjId, String ObjName, String Description) 44 | : base(new BacnetObjectId(BacnetObjectTypes.OBJECT_STRUCTURED_VIEW, (uint)ObjId), ObjName, Description) 45 | { 46 | } 47 | 48 | public StructuredView() { } 49 | 50 | public void AddBacnetObject(BaCSharpObject newObj) 51 | { 52 | m_PROP_SUBORDINATE_LIST.Add(new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_OBJECT_ID, newObj.PROP_OBJECT_IDENTIFIER)); 53 | // Each object provided by the server must be added one by one to the DeviceObject 54 | Mydevice.AddBacnetObject(newObj); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/BacnetObjects/TrendLogCustom.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | using System.IO.BACnet; 31 | 32 | namespace BaCSharp 33 | { 34 | // Shows how to customize a base class 35 | 36 | class TrendLogCustom : TrendLog 37 | { 38 | // first a constructor calling the parent constructor 39 | public TrendLogCustom(int ObjId, String ObjName, String Description, uint Logsize, BacnetTrendLogValueType DefaultValueType) 40 | : base(ObjId, ObjName, Description, Logsize, DefaultValueType) { } 41 | // second an empty constructor (needed only by the serialisation process) 42 | public TrendLogCustom() { } 43 | 44 | // This property is inherited from BaCSharpObject, and replaced here 45 | public override string PROP_OBJECT_NAME 46 | { 47 | get 48 | { 49 | return "Custom Trend : " + base.PROP_OBJECT_NAME; 50 | } 51 | } 52 | 53 | // This property is read only in the base class (only get) 54 | public virtual new uint PROP_RECORD_COUNT 55 | { 56 | get 57 | { 58 | return base.PROP_RECORD_COUNT; 59 | } 60 | set 61 | { 62 | if (value == 0) 63 | { 64 | base.Clear(); 65 | } 66 | } 67 | } 68 | // This property is read only in the base class (only get) 69 | public virtual new uint PROP_BUFFER_SIZE 70 | { 71 | get 72 | { 73 | return base.PROP_BUFFER_SIZE; 74 | } 75 | set 76 | { 77 | if (value > 10) // a minimal value 78 | { 79 | if (TrendBuffer != null) 80 | { 81 | // sure it's not the way resize could be done to be full OK 82 | Array.Resize(ref TrendBuffer, (int)value); 83 | m_PROP_BUFFER_SIZE = value; 84 | LogPtr = LogPtr % TrendBuffer.Length; 85 | m_PROP_RECORD_COUNT = (uint)Math.Min(m_PROP_RECORD_COUNT, value); 86 | } 87 | else 88 | m_PROP_BUFFER_SIZE = value; 89 | } 90 | } 91 | } 92 | // This property is brend new 93 | public virtual string PROP_PROFILE_NAME 94 | { 95 | get 96 | { 97 | return "A profile"; 98 | } 99 | } 100 | // This property is brend new and proprietary 101 | public virtual bool PROP_3101 102 | { 103 | get 104 | { return true; } 105 | } 106 | 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: AssemblyTitle("AnotherStorageImplementation")] 6 | [assembly: AssemblyDescription("")] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany("F. Chaxel")] 9 | [assembly: AssemblyProduct("AnotherStorageImplementation")] 10 | [assembly: AssemblyCopyright("Copyright © F. Chaxel 2015")] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture("")] 13 | 14 | [assembly: ComVisible(false)] 15 | 16 | [assembly: Guid("ff6b5fbc-8a64-42d7-b52d-57d788e5a518")] 17 | 18 | [assembly: AssemblyVersion("1.0.0.0")] 19 | [assembly: AssemblyFileVersion("1.0.0.0")] 20 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/nuget.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /AnotherStorageImplementation/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/Bacnet.Room.Simulator.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {07552C4C-AD80-4645-AC91-D6138B5888AA} 9 | WinExe 10 | Properties 11 | Bacnet.Room.Simulator 12 | Bacnet.Room.Simulator 13 | v4.0 14 | 15 | 16 | 512 17 | 18 | 19 | nuage-soleil-meteo-icone-8152.ico 20 | 21 | 22 | true 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | full 26 | AnyCPU 27 | prompt 28 | false 29 | false 30 | false 31 | 32 | 33 | bin\Release\ 34 | TRACE 35 | true 36 | pdbonly 37 | AnyCPU 38 | prompt 39 | 40 | 41 | bin\R\ 42 | TRACE 43 | true 44 | pdbonly 45 | AnyCPU 46 | prompt 47 | false 48 | 49 | 50 | 51 | ..\packages\BACnet.1.0.8.5-alpha\lib\net40\BACnet.dll 52 | True 53 | 54 | 55 | ..\packages\PacketDotNet.0.13.0\lib\net\PacketDotNet.dll 56 | True 57 | 58 | 59 | ..\packages\SharpPcap.4.2.0\lib\net\SharpPcap.dll 60 | True 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | Form 74 | 75 | 76 | Form1.cs 77 | 78 | 79 | 80 | 81 | 82 | 83 | Form1.cs 84 | 85 | 86 | ResXFileCodeGenerator 87 | Resources.Designer.cs 88 | Designer 89 | 90 | 91 | True 92 | Resources.resx 93 | True 94 | 95 | 96 | 97 | 98 | SettingsSingleFileGenerator 99 | Settings.Designer.cs 100 | 101 | 102 | True 103 | Settings.settings 104 | True 105 | 106 | 107 | 108 | 109 | Designer 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | Designer 119 | 120 | 121 | 122 | 123 | 130 | -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/ImgMode/HArret.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ela-compil/BACnet.Examples/5f31d0b5e2372aac9b554976196b4c66edd44c24/Bacnet.Room.Simulator/ImgMode/HArret.png -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/ImgMode/H_Chaud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ela-compil/BACnet.Examples/5f31d0b5e2372aac9b554976196b4c66edd44c24/Bacnet.Room.Simulator/ImgMode/H_Chaud.png -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/ImgMode/H_Froid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ela-compil/BACnet.Examples/5f31d0b5e2372aac9b554976196b4c66edd44c24/Bacnet.Room.Simulator/ImgMode/H_Froid.png -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/Ini.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | namespace Ini 7 | { 8 | /// 9 | /// Create a New INI file to store or load data 10 | /// 11 | public class IniFile 12 | { 13 | public string path; 14 | 15 | [DllImport("kernel32")] 16 | private static extern long WritePrivateProfileString(string section,string key,string val,string filePath); 17 | [DllImport("kernel32")] 18 | private static extern int GetPrivateProfileString(string section,string key,string def,StringBuilder retVal,int size,string filePath); 19 | 20 | /// 21 | /// INIFile Constructor. 22 | /// 23 | /// 24 | public IniFile(string INIPath) 25 | { 26 | path = INIPath; 27 | } 28 | /// 29 | /// Write Data to the INI File 30 | /// 31 | /// 32 | /// Section name 33 | /// 34 | /// Key Name 35 | /// 36 | /// Value Name 37 | public void IniWriteValue(string Section,string Key,string Value) 38 | { 39 | WritePrivateProfileString(Section,Key,Value,this.path); 40 | } 41 | 42 | /// 43 | /// Read Data Value From the Ini File 44 | /// 45 | /// 46 | /// 47 | /// 48 | /// 49 | public string IniReadValue(string Section,string Key, string DefaultValue) 50 | { 51 | StringBuilder temp = new StringBuilder(1024); 52 | int i = GetPrivateProfileString(Section,Key,"",temp,1024,this.path); 53 | if (i != 0) 54 | return temp.ToString(); 55 | else 56 | return DefaultValue; 57 | 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/Program.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Linq; 30 | using System.Windows.Forms; 31 | using System.Threading; 32 | using System.Diagnostics; 33 | using System.Management; 34 | 35 | namespace Bacnet.Room.Simulator 36 | { 37 | 38 | 39 | static class Program 40 | { 41 | public static int Count; 42 | 43 | /// 44 | /// Point d'entrée principal de l'application. 45 | /// 46 | [STAThread] 47 | static void Main() 48 | { 49 | 50 | // Le semaphore sert a donner un id unqiue au noeud Bacnet 51 | Semaphore s = new Semaphore(63, 63, "Bacnet.Room{FAED-FAED}"); 52 | if (s.WaitOne() == true) 53 | { 54 | Count = 64-s.Release(); 55 | s.WaitOne(); 56 | } 57 | 58 | try 59 | { 60 | Application.EnableVisualStyles(); 61 | Application.SetCompatibleTextRenderingDefault(false); 62 | Application.Run(new BacForm()); 63 | } 64 | catch 65 | { 66 | MessageBox.Show("Fatal Error", "Bacnet.Room.Simulator", MessageBoxButtons.OK, MessageBoxIcon.Error); 67 | } 68 | 69 | s.Release(); 70 | } 71 | 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Les informations générales relatives à un assembly dépendent de 6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations 7 | // associées à un assembly. 8 | [assembly: AssemblyTitle("Bacnet.Room.Simulator")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("MicroNetworkTech")] 12 | [assembly: AssemblyProduct("Bacnet.Room.Simulator")] 13 | [assembly: AssemblyCopyright("Copyright © MicroNetworkTech 2014")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly 18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de 19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM 23 | [assembly: Guid("2b922b85-0e05-4323-a905-0c4e011e2700")] 24 | 25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes : 26 | // 27 | // Version principale 28 | // Version secondaire 29 | // Numéro de build 30 | // Révision 31 | // 32 | // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut 33 | // en utilisant '*', comme indiqué ci-dessous : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Ce code a été généré par un outil. 4 | // Version du runtime :4.0.30319.17929 5 | // 6 | // Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si 7 | // le code est régénéré. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Bacnet.Room.Simulator.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées. 17 | /// 18 | // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder 19 | // à l'aide d'un outil, tel que ResGen ou Visual Studio. 20 | // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen 21 | // avec l'option /str ou régénérez votre projet VS. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Bacnet.Room.Simulator.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Remplace la propriété CurrentUICulture du thread actuel pour toutes 51 | /// les recherches de ressources à l'aide de cette classe de ressource fortement typée. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap H_Chaud { 67 | get { 68 | object obj = ResourceManager.GetObject("H_Chaud", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Looks up a localized resource of type System.Drawing.Bitmap. 75 | /// 76 | internal static System.Drawing.Bitmap H_Froid { 77 | get { 78 | object obj = ResourceManager.GetObject("H_Froid", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// Looks up a localized resource of type System.Drawing.Bitmap. 85 | /// 86 | internal static System.Drawing.Bitmap HArret { 87 | get { 88 | object obj = ResourceManager.GetObject("HArret", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\ImgMode\HArret.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | 125 | ..\ImgMode\H_Chaud.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 126 | 127 | 128 | ..\ImgMode\H_Froid.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 129 | 130 | 131 | -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // Ce code a été généré par un outil. 4 | // Version du runtime :4.0.30319.17929 5 | // 6 | // Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si 7 | // le code est régénéré. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Bacnet.Room.Simulator.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ela-compil/BACnet.Examples/5f31d0b5e2372aac9b554976196b4c66edd44c24/Bacnet.Room.Simulator/README.md -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/RoomModel.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Frederic Chaxel 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining 7 | * a copy of this software and associated documentation files (the 8 | * "Software"), to deal in the Software without restriction, including 9 | * without limitation the rights to use, copy, modify, merge, publish, 10 | * distribute, sublicense, and/or sell copies of the Software, and to 11 | * permit persons to whom the Software is furnished to do so, subject to 12 | * the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | * 25 | *********************************************************************/ 26 | using System; 27 | using System.Collections.Generic; 28 | using System.Linq; 29 | using System.Text; 30 | 31 | namespace Bacnet.Room.Simulator 32 | { 33 | // A room with energy losts proportional to internal Temp minus external Temp 34 | // an gains proportional to insuflated Temp minus internal Temp 35 | // and random effects 36 | // and some delays 37 | class RoomModel 38 | { 39 | 40 | double Tempint; 41 | double RollingCounter = 0; 42 | Random random = new Random(); 43 | 44 | const int NBDelay = 10; 45 | double[] EnergieDelay = new double[NBDelay]; 46 | int IdxDelay=0; 47 | 48 | public RoomModel(double Tini) 49 | { 50 | Tempint= Tini; 51 | 52 | } 53 | 54 | double Delay(double newVal) 55 | { 56 | double RetVal; 57 | 58 | EnergieDelay[IdxDelay] = newVal; 59 | 60 | RetVal = EnergieDelay[(IdxDelay + NBDelay - 1) % NBDelay]; 61 | 62 | IdxDelay++; 63 | IdxDelay = IdxDelay % NBDelay; 64 | 65 | return RetVal; 66 | } 67 | 68 | public double GetNextTemp(double TempAirSoufle, double TempExt, int PSoufflage) 69 | { 70 | 71 | double Perte = 0.03 * (Tempint - TempExt); 72 | double Gain = 0.015 * Delay(PSoufflage * (TempAirSoufle - Tempint)) ; 73 | 74 | double Perturbation = 0.0005 * Math.Cos(RollingCounter / 10.0) ; 75 | RollingCounter += 2 * random.NextDouble(); 76 | 77 | Tempint = Tempint - Perte + Gain + Perturbation; 78 | 79 | return Tempint; 80 | 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/nuage-soleil-meteo-icone-8152.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ela-compil/BACnet.Examples/5f31d0b5e2372aac9b554976196b4c66edd44c24/Bacnet.Room.Simulator/nuage-soleil-meteo-icone-8152.ico -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/nuget.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Bacnet.Room.Simulator/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BacnetToDatabase/BacnetToDatabase.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {AB80ADFC-41DD-4E98-87CB-89C358B9E65D} 9 | WinExe 10 | Properties 11 | BacnetToDatabase 12 | BacnetToDatabase 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | true 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | full 22 | AnyCPU 23 | prompt 24 | MinimumRecommendedRules.ruleset 25 | 26 | 27 | bin\Release\ 28 | TRACE 29 | true 30 | pdbonly 31 | AnyCPU 32 | prompt 33 | MinimumRecommendedRules.ruleset 34 | 35 | 36 | 37 | ..\packages\BACnet.1.0.8.5-alpha\lib\net40\BACnet.dll 38 | True 39 | 40 | 41 | ..\packages\PacketDotNet.0.13.0\lib\net\PacketDotNet.dll 42 | True 43 | 44 | 45 | ..\packages\SharpPcap.4.2.0\lib\net\SharpPcap.dll 46 | True 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | Form 62 | 63 | 64 | Main.cs 65 | 66 | 67 | 68 | 69 | Main.cs 70 | 71 | 72 | ResXFileCodeGenerator 73 | Resources.Designer.cs 74 | Designer 75 | 76 | 77 | True 78 | Resources.resx 79 | 80 | 81 | 82 | SettingsSingleFileGenerator 83 | Settings.Designer.cs 84 | 85 | 86 | True 87 | Settings.settings 88 | True 89 | 90 | 91 | 92 | 93 | Always 94 | 95 | 96 | 97 | 104 | -------------------------------------------------------------------------------- /BacnetToDatabase/Main.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BacnetToDatabase 2 | { 3 | partial class Main 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.groupBox1 = new System.Windows.Forms.GroupBox(); 33 | this.m_SearchButton = new System.Windows.Forms.Button(); 34 | this.m_TransferButton = new System.Windows.Forms.Button(); 35 | this.m_list = new System.Windows.Forms.ListView(); 36 | this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 37 | this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); 38 | this.m_delayedStart = new System.Windows.Forms.Timer(this.components); 39 | this.groupBox1.SuspendLayout(); 40 | this.SuspendLayout(); 41 | // 42 | // groupBox1 43 | // 44 | this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 45 | | System.Windows.Forms.AnchorStyles.Left) 46 | | System.Windows.Forms.AnchorStyles.Right))); 47 | this.groupBox1.Controls.Add(this.m_list); 48 | this.groupBox1.Controls.Add(this.m_TransferButton); 49 | this.groupBox1.Controls.Add(this.m_SearchButton); 50 | this.groupBox1.Location = new System.Drawing.Point(12, 12); 51 | this.groupBox1.Name = "groupBox1"; 52 | this.groupBox1.Size = new System.Drawing.Size(381, 259); 53 | this.groupBox1.TabIndex = 0; 54 | this.groupBox1.TabStop = false; 55 | this.groupBox1.Text = "Devices"; 56 | // 57 | // m_SearchButton 58 | // 59 | this.m_SearchButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 60 | this.m_SearchButton.Location = new System.Drawing.Point(300, 229); 61 | this.m_SearchButton.Name = "m_SearchButton"; 62 | this.m_SearchButton.Size = new System.Drawing.Size(75, 23); 63 | this.m_SearchButton.TabIndex = 0; 64 | this.m_SearchButton.Text = "Search"; 65 | this.m_SearchButton.UseVisualStyleBackColor = true; 66 | this.m_SearchButton.Click += new System.EventHandler(this.m_SearchButton_Click); 67 | // 68 | // m_TransferButton 69 | // 70 | this.m_TransferButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 71 | this.m_TransferButton.Location = new System.Drawing.Point(170, 229); 72 | this.m_TransferButton.Name = "m_TransferButton"; 73 | this.m_TransferButton.Size = new System.Drawing.Size(124, 23); 74 | this.m_TransferButton.TabIndex = 1; 75 | this.m_TransferButton.Text = "Transfer To SQL CE Local DB"; 76 | this.m_TransferButton.UseVisualStyleBackColor = true; 77 | this.m_TransferButton.Click += new System.EventHandler(this.m_TransferButton_Click); 78 | // 79 | // m_list 80 | // 81 | this.m_list.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 82 | | System.Windows.Forms.AnchorStyles.Left) 83 | | System.Windows.Forms.AnchorStyles.Right))); 84 | this.m_list.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { 85 | this.columnHeader1, 86 | this.columnHeader2}); 87 | this.m_list.FullRowSelect = true; 88 | this.m_list.GridLines = true; 89 | this.m_list.Location = new System.Drawing.Point(6, 19); 90 | this.m_list.Name = "m_list"; 91 | this.m_list.Size = new System.Drawing.Size(369, 205); 92 | this.m_list.TabIndex = 2; 93 | this.m_list.UseCompatibleStateImageBehavior = false; 94 | this.m_list.View = System.Windows.Forms.View.Details; 95 | // 96 | // columnHeader1 97 | // 98 | this.columnHeader1.Text = "IP"; 99 | this.columnHeader1.Width = 120; 100 | // 101 | // columnHeader2 102 | // 103 | this.columnHeader2.Text = "Name"; 104 | this.columnHeader2.Width = 150; 105 | // 106 | // m_delayedStart 107 | // 108 | this.m_delayedStart.Enabled = true; 109 | this.m_delayedStart.Interval = 500; 110 | this.m_delayedStart.Tick += new System.EventHandler(this.m_delayedStart_Tick); 111 | // 112 | // Main 113 | // 114 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 115 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 116 | this.ClientSize = new System.Drawing.Size(405, 283); 117 | this.Controls.Add(this.groupBox1); 118 | this.Name = "Main"; 119 | this.Text = "Bacnet To Database"; 120 | this.groupBox1.ResumeLayout(false); 121 | this.ResumeLayout(false); 122 | 123 | } 124 | 125 | #endregion 126 | 127 | private System.Windows.Forms.GroupBox groupBox1; 128 | private System.Windows.Forms.Button m_TransferButton; 129 | private System.Windows.Forms.Button m_SearchButton; 130 | private System.Windows.Forms.ListView m_list; 131 | private System.Windows.Forms.ColumnHeader columnHeader1; 132 | private System.Windows.Forms.ColumnHeader columnHeader2; 133 | private System.Windows.Forms.Timer m_delayedStart; 134 | } 135 | } 136 | 137 | -------------------------------------------------------------------------------- /BacnetToDatabase/Main.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2015 Morten Kvistgaard 5 | * Frederic Chaxel (adr, device_id); 59 | itm.SubItems.Add(""); 60 | 61 | //read name 62 | IList values; 63 | if (bacnet_client.ReadPropertyRequest(adr, new BacnetObjectId(BacnetObjectTypes.OBJECT_DEVICE, device_id), BacnetPropertyIds.PROP_OBJECT_NAME, out values)) 64 | itm.SubItems[1].Text = (string)values[0].Value; 65 | 66 | }, null); 67 | } 68 | 69 | private void m_delayedStart_Tick(object sender, EventArgs e) 70 | { 71 | m_delayedStart.Enabled = false; 72 | SendSearch(); 73 | } 74 | 75 | private void SendSearch() 76 | { 77 | bacnet_client.WhoIs(); 78 | } 79 | 80 | private void m_SearchButton_Click(object sender, EventArgs e) 81 | { 82 | SendSearch(); 83 | } 84 | 85 | private void m_TransferButton_Click(object sender, EventArgs e) 86 | { 87 | //get Bacnet selection 88 | if (m_list.SelectedItems.Count <= 0) 89 | { 90 | MessageBox.Show(this, "Please select a device", "No device selected", MessageBoxButtons.OK, MessageBoxIcon.Information); 91 | return; 92 | } 93 | KeyValuePair device = (KeyValuePair)m_list.SelectedItems[0].Tag; 94 | 95 | //open database connection 96 | System.Data.SqlServerCe.SqlCeConnection con = new System.Data.SqlServerCe.SqlCeConnection(@"Data Source=..\..\SampleDatabase.sdf"); 97 | con.Open(); 98 | 99 | //retrieve list of 'properties' 100 | IList value_list; 101 | bacnet_client.ReadPropertyRequest(device.Key, new BacnetObjectId(BacnetObjectTypes.OBJECT_DEVICE, device.Value), BacnetPropertyIds.PROP_OBJECT_LIST, out value_list); 102 | LinkedList object_list = new LinkedList(); 103 | foreach (BacnetValue value in value_list) 104 | { 105 | if (Enum.IsDefined(typeof(BacnetObjectTypes), ((BacnetObjectId)value.Value).Type)) 106 | object_list.AddLast((BacnetObjectId)value.Value); 107 | } 108 | 109 | //go through all 'properties' and store their 'present data' into a SQL database 110 | foreach (BacnetObjectId object_id in object_list) 111 | { 112 | //read all properties 113 | IList values = null; 114 | try 115 | { 116 | if (!bacnet_client.ReadPropertyRequest(device.Key, object_id, BacnetPropertyIds.PROP_PRESENT_VALUE, out values)) 117 | { 118 | MessageBox.Show(this, "Couldn't fetch 'present value' for object: " + object_id.ToString()); 119 | continue; 120 | } 121 | } 122 | catch (Exception) 123 | { 124 | //perhaps the 'present value' is non existing - ignore 125 | continue; 126 | } 127 | 128 | //store in DB 129 | using (System.Data.SqlServerCe.SqlCeCommand com = new System.Data.SqlServerCe.SqlCeCommand("INSERT INTO SampleTable VALUES(@ObjectName,@PropertyId,@Value)", con)) 130 | { 131 | com.Parameters.AddWithValue("@ObjectName", object_id.ToString()); 132 | com.Parameters.AddWithValue("@PropertyId", values[0].Tag.ToString()); 133 | com.Parameters.AddWithValue("@Value", values[0].Value.ToString()); 134 | com.ExecuteNonQuery(); 135 | } 136 | } 137 | 138 | //close DB 139 | con.Close(); 140 | 141 | //done 142 | MessageBox.Show(this, "Done!", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); 143 | } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /BacnetToDatabase/Main.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | -------------------------------------------------------------------------------- /BacnetToDatabase/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace BacnetToDatabase 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new Main()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /BacnetToDatabase/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BacnetToDatabase")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BacnetToDatabase")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("33f2319a-cb86-4e57-9499-5b9a9ebdbee0")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /BacnetToDatabase/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace BacnetToDatabase.Properties 12 | { 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources 26 | { 27 | 28 | private static global::System.Resources.ResourceManager resourceMan; 29 | 30 | private static global::System.Globalization.CultureInfo resourceCulture; 31 | 32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 33 | internal Resources() 34 | { 35 | } 36 | 37 | /// 38 | /// Returns the cached ResourceManager instance used by this class. 39 | /// 40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 41 | internal static global::System.Resources.ResourceManager ResourceManager 42 | { 43 | get 44 | { 45 | if ((resourceMan == null)) 46 | { 47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("BacnetToDatabase.Properties.Resources", typeof(Resources).Assembly); 48 | resourceMan = temp; 49 | } 50 | return resourceMan; 51 | } 52 | } 53 | 54 | /// 55 | /// Overrides the current thread's CurrentUICulture property for all 56 | /// resource lookups using this strongly typed resource class. 57 | /// 58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 59 | internal static global::System.Globalization.CultureInfo Culture 60 | { 61 | get 62 | { 63 | return resourceCulture; 64 | } 65 | set 66 | { 67 | resourceCulture = value; 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /BacnetToDatabase/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /BacnetToDatabase/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace BacnetToDatabase.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BacnetToDatabase/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BacnetToDatabase/nuget.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BacnetToDatabase/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BasicAdviseCOV/BasicAdviseCOV.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {C501E026-4977-49C6-8DCB-5B9600C17FF1} 9 | Exe 10 | Properties 11 | BasicAdviseCOV 12 | BasicAdviseCOV 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | true 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | full 22 | AnyCPU 23 | prompt 24 | MinimumRecommendedRules.ruleset 25 | 26 | 27 | bin\Release\ 28 | TRACE 29 | true 30 | pdbonly 31 | AnyCPU 32 | prompt 33 | MinimumRecommendedRules.ruleset 34 | 35 | 36 | 37 | ..\packages\BACnet.1.0.8.5-alpha\lib\net40\BACnet.dll 38 | True 39 | 40 | 41 | ..\packages\PacketDotNet.0.13.0\lib\net\PacketDotNet.dll 42 | True 43 | 44 | 45 | ..\packages\SharpPcap.4.2.0\lib\net\SharpPcap.dll 46 | True 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 71 | -------------------------------------------------------------------------------- /BasicAdviseCOV/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Les informations générales relatives à un assembly dépendent de 6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations 7 | // associées à un assembly. 8 | [assembly: AssemblyTitle("BasicAdviseCOV")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("BasicAdviseCOV")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly 18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de 19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM 23 | [assembly: Guid("c4f852d0-ffda-4fd6-a2a7-1708b530dd22")] 24 | 25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes : 26 | // 27 | // Version principale 28 | // Version secondaire 29 | // Numéro de build 30 | // Révision 31 | // 32 | // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut 33 | // en utilisant '*', comme indiqué ci-dessous : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /BasicAdviseCOV/nuget.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BasicAdviseCOV/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BasicAlarmListener/BasicAlarmListener.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {91C94BC2-B863-4415-AB5F-2C4D02B2F2CE} 9 | Exe 10 | Properties 11 | BasicAlarmListener 12 | BasicAlarmListener 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | true 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | full 22 | AnyCPU 23 | prompt 24 | MinimumRecommendedRules.ruleset 25 | 26 | 27 | bin\Release\ 28 | TRACE 29 | true 30 | pdbonly 31 | AnyCPU 32 | prompt 33 | MinimumRecommendedRules.ruleset 34 | 35 | 36 | 37 | ..\packages\BACnet.1.0.8.5-alpha\lib\net40\BACnet.dll 38 | True 39 | 40 | 41 | ..\packages\PacketDotNet.0.13.0\lib\net\PacketDotNet.dll 42 | True 43 | 44 | 45 | ..\packages\SharpPcap.4.2.0\lib\net\SharpPcap.dll 46 | True 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | Designer 63 | 64 | 65 | 66 | 67 | 68 | 69 | 76 | -------------------------------------------------------------------------------- /BasicAlarmListener/DeviceDescriptor.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | OBJECT_DEVICE:0 8 | 9 | 10 | OBJECT_DEVICE:0 11 | 12 | 13 | Alarm Listener 14 | 15 | 16 | 8 17 | 18 | 19 | 0 20 | 21 | 22 | Morten Kvistgaard, Frederic Chaxel MIT licence, 2015 23 | 24 | 25 | 61440 26 | 27 | 28 | YABE_2015 29 | 30 | 31 | 0 32 | 33 | 34 | 0 35 | 36 | 37 | 1 38 | 39 | 40 | 14 41 | 42 | 43 | 0000000000001010000000000010000000100000 44 | 45 | 46 | 000000001000000000000000000000000000000000000000000 47 | 48 | 49 | 1476 50 | 51 | 52 | 3 53 | 54 | 55 | 3000 56 | 57 | 58 | 3 59 | 60 | 61 | 62 | 0 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /BasicAlarmListener/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Les informations générales relatives à un assembly dépendent de 6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations 7 | // associées à un assembly. 8 | [assembly: AssemblyTitle("BasicAlarmListener")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("BasicAlarmListener")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly 18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de 19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM 23 | [assembly: Guid("852a93dc-b492-444a-a2c0-7feb57f133cd")] 24 | 25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes : 26 | // 27 | // Version principale 28 | // Version secondaire 29 | // Numéro de build 30 | // Révision 31 | // 32 | // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut 33 | // en utilisant '*', comme indiqué ci-dessous : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /BasicAlarmListener/nuget.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BasicAlarmListener/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BasicReadWrite/BasicReadWrite.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {28F7604F-7DCD-4330-8261-55AEB2B0BAC4} 9 | Exe 10 | Properties 11 | BasicReadWrite 12 | BasicReadWrite 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | true 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | full 22 | AnyCPU 23 | prompt 24 | MinimumRecommendedRules.ruleset 25 | 26 | 27 | bin\Release\ 28 | TRACE 29 | true 30 | pdbonly 31 | AnyCPU 32 | prompt 33 | MinimumRecommendedRules.ruleset 34 | 35 | 36 | 37 | ..\packages\BACnet.1.0.8.5-alpha\lib\net40\BACnet.dll 38 | True 39 | 40 | 41 | ..\packages\PacketDotNet.0.13.0\lib\net\PacketDotNet.dll 42 | True 43 | 44 | 45 | ..\packages\SharpPcap.4.2.0\lib\net\SharpPcap.dll 46 | True 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 71 | -------------------------------------------------------------------------------- /BasicReadWrite/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Les informations générales relatives à un assembly dépendent de 6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations 7 | // associées à un assembly. 8 | [assembly: AssemblyTitle("BasicReadWrite")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("BasicReadWrite")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly 18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de 19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM 23 | [assembly: Guid("225d9cdc-3c22-460a-a7be-7fd54ba86b3d")] 24 | 25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes : 26 | // 27 | // Version principale 28 | // Version secondaire 29 | // Numéro de build 30 | // Révision 31 | // 32 | // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut 33 | // en utilisant '*', comme indiqué ci-dessous : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /BasicReadWrite/nuget.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BasicReadWrite/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BasicServer/BasicServer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {DB89E653-7DBF-45BC-A92E-3754D8091E89} 9 | Exe 10 | Properties 11 | BasicServer 12 | BasicServer 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | true 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | full 22 | AnyCPU 23 | prompt 24 | MinimumRecommendedRules.ruleset 25 | 26 | 27 | bin\Release\ 28 | TRACE 29 | true 30 | pdbonly 31 | AnyCPU 32 | prompt 33 | MinimumRecommendedRules.ruleset 34 | 35 | 36 | 37 | ..\packages\BACnet.1.0.8.5-alpha\lib\net40\BACnet.dll 38 | True 39 | 40 | 41 | ..\packages\PacketDotNet.0.13.0\lib\net\PacketDotNet.dll 42 | True 43 | 44 | 45 | ..\packages\SharpPcap.4.2.0\lib\net\SharpPcap.dll 46 | True 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | Designer 63 | 64 | 65 | 66 | 67 | 68 | 69 | 76 | -------------------------------------------------------------------------------- /BasicServer/DeviceDescriptor.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | OBJECT_DEVICE:12345 8 | 9 | 10 | OBJECT_DEVICE:12345 11 | OBJECT_ANALOG_INPUT:0 12 | OBJECT_ANALOG_VALUE:0 13 | 14 | 15 | Minimal Server Code 16 | 17 | 18 | 8 19 | 20 | 21 | 0 22 | 23 | 24 | Morten Kvistgaard, Frederic Chaxel MIT licence, 2015 25 | 26 | 27 | 61440 28 | 29 | 30 | YABE_2015 31 | 32 | 33 | 0 34 | 35 | 36 | 0 37 | 38 | 39 | 1 40 | 41 | 42 | 14 43 | 44 | 45 | 0000000000001011000000000010000000100000 46 | 47 | 48 | 101000001000000000000000000000000000000000000000000 49 | 50 | 51 | 1476 52 | 53 | 54 | 3 55 | 56 | 57 | 3000 58 | 59 | 60 | 3 61 | 62 | 63 | 64 | 0 65 | 66 | 67 | 68 | 69 | 70 | 71 | A.Sin(wt) 72 | 73 | 74 | 0 75 | 76 | 77 | OBJECT_ANALOG_INPUT:0 78 | 79 | 80 | Readable float object 81 | 82 | 83 | 0 84 | 85 | 86 | False 87 | 88 | 89 | 12 90 | 91 | 92 | 0 93 | 94 | 95 | 0000 96 | 97 | 98 | 62 99 | 100 | 101 | 102 | 103 | 104 | 105 | A value 106 | 107 | 108 | 0 109 | 110 | 111 | OBJECT_ANALOG_VALUE:0 112 | 113 | 114 | Writable unsigned int object 115 | 116 | 117 | 2 118 | 119 | 120 | False 121 | 122 | 123 | 21 124 | 125 | 126 | 0 127 | 128 | 129 | 0000 130 | 131 | 132 | 62 133 | 134 | 135 | 136 | 137 | 138 | -------------------------------------------------------------------------------- /BasicServer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Les informations générales relatives à un assembly dépendent de 6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations 7 | // associées à un assembly. 8 | [assembly: AssemblyTitle("BasicServer")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("BasicServer")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly 18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de 19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM 23 | [assembly: Guid("9d8ca50b-593d-46f9-bc4b-39ed9aaa2188")] 24 | 25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes : 26 | // 27 | // Version principale 28 | // Version secondaire 29 | // Numéro de build 30 | // Révision 31 | // 32 | // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut 33 | // en utilisant '*', comme indiqué ci-dessous : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /BasicServer/nuget.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BasicServer/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /DemoBBMD/Config.txt: -------------------------------------------------------------------------------- 1 | // BBMD Peer List 2 | // IP ; Mask ; Port in decimal 3 | // for IPV6 Mask is not used but must be present : put ::1 for instance 4 | // 2a01:f347:ea97:6a2e:c4:1d24:714a:3de3;::1;47808 5 | // One entry per line 6 | // first char must be / for comment 7 | // No blank line 8 | 172.20.54.222;255.255.255.255;47808 9 | 192.168.0.12;255.255.255.255;47808 10 | -------------------------------------------------------------------------------- /DemoBBMD/DemoBBMD.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {A2CE9357-71B6-40F7-97C7-74AF1E5659A5} 9 | Exe 10 | Properties 11 | DemoBBMD 12 | DemoBBMD 13 | v4.0 14 | 15 | 16 | 512 17 | 18 | 19 | true 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | full 23 | AnyCPU 24 | prompt 25 | MinimumRecommendedRules.ruleset 26 | 27 | 28 | bin\Release\ 29 | TRACE 30 | true 31 | pdbonly 32 | AnyCPU 33 | prompt 34 | MinimumRecommendedRules.ruleset 35 | 36 | 37 | 38 | ..\packages\BACnet.1.0.8.5-alpha\lib\net40\BACnet.dll 39 | True 40 | 41 | 42 | ..\packages\PacketDotNet.0.13.0\lib\net\PacketDotNet.dll 43 | True 44 | 45 | 46 | ..\packages\SharpPcap.4.2.0\lib\net\SharpPcap.dll 47 | True 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Designer 69 | 70 | 71 | 72 | 73 | Always 74 | 75 | 76 | 77 | 84 | -------------------------------------------------------------------------------- /DemoBBMD/DeviceStorage.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | OBJECT_DEVICE:187 8 | 9 | 10 | BBMD Demo Application 11 | 12 | 13 | 8 14 | 15 | 16 | 0 17 | 18 | 19 | F. Chaxel, Morten Kvistgaard, MIT licence, 2015 20 | 21 | 22 | 61440 23 | 24 | 25 | BBMD_FC_2015 26 | 27 | 28 | 0.1.0 29 | 30 | 31 | 0.1.0 32 | 33 | 34 | 1 35 | 36 | 37 | 14 38 | 39 | 40 | 01111111101111000011101110000000011010101 41 | 42 | 43 | 0000000010101010000000000000000100000000111110111111111 44 | 45 | 46 | 47 | 48 | 1476 49 | 50 | 51 | 3 52 | 53 | 54 | 3000 55 | 56 | 57 | 3 58 | 59 | 60 | 61 | 0 62 | 63 | 64 | Free BBMD Demo Tool 65 | 66 | 67 | France 68 | 69 | 70 | 71 | 72 | 73 | 74 | Peer BBMD List 75 | 76 | 77 | 0 78 | 79 | 80 | OBJECT_CHARACTERSTRING_VALUE:0 81 | 82 | 83 | PeerBBMDList 84 | 85 | 86 | 40 87 | 88 | 89 | False 90 | 91 | 92 | 93 | 94 | 95 | 0 96 | 97 | 98 | 0000 99 | 100 | 101 | 102 | 103 | 104 | 105 | Foreign Devices List 106 | 107 | 108 | 0 109 | 110 | 111 | OBJECT_CHARACTERSTRING_VALUE:1 112 | 113 | 114 | ForeignDevicesList 115 | 116 | 117 | 40 118 | 119 | 120 | False 121 | 122 | 123 | 124 | 125 | 126 | 0 127 | 128 | 129 | 0000 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /DemoBBMD/Program.cs: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | * MIT License 3 | * 4 | * Copyright (C) 2014 Morten Kvistgaard 5 | * Copyright (C) 2015 Frederic Chaxel 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining 8 | * a copy of this software and associated documentation files (the 9 | * "Software"), to deal in the Software without restriction, including 10 | * without limitation the rights to use, copy, modify, merge, publish, 11 | * distribute, sublicense, and/or sell copies of the Software, and to 12 | * permit persons to whom the Software is furnished to do so, subject to 13 | * the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included 16 | * in all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | * 26 | *********************************************************************/ 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Linq; 30 | using System.Text; 31 | using System.IO.BACnet; 32 | using System.Threading; 33 | using System.Net; 34 | using System.IO; 35 | using System.Diagnostics; 36 | 37 | // See BacnetActivity arround line 83 to swith form IPV4 to IPV6 38 | 39 | namespace DemoBBMD 40 | { 41 | class Program 42 | { 43 | static void SetBBMDList() 44 | { 45 | StringBuilder BBMDList = new StringBuilder(); 46 | 47 | // Read the BBMD Peer List from the Config.txt file 48 | try 49 | { 50 | StreamReader sr = new StreamReader("Config.txt"); 51 | while (!sr.EndOfStream) 52 | { 53 | String l = sr.ReadLine(); 54 | 55 | if ((l.Length != 0) && (l[0] != '/')) 56 | { 57 | String[] Param = l.Split(';'); 58 | 59 | BacnetActivity.AddPeerBBMD(new IPEndPoint(IPAddress.Parse(Param[0]), Convert.ToInt32(Param[2])), IPAddress.Parse(Param[1])); 60 | 61 | BBMDList.Append(Param[0] + ":" + Param[2] + ";"); 62 | 63 | Console.WriteLine("\tWorking with peer BBMD : {0}:{1}", Param[0], Param[2]); 64 | } 65 | } 66 | sr.Close(); 67 | } 68 | catch { } 69 | 70 | // Update the first CHARACTERSTRING OBJECT Present Value 71 | BacnetObjectId b = new BacnetObjectId(BacnetObjectTypes.OBJECT_CHARACTERSTRING_VALUE, 0); 72 | BacnetActivity.SetBacObjectPresentValue(b, new BacnetValue(BBMDList.ToString())); 73 | } 74 | 75 | static void Main(string[] args) 76 | { 77 | 78 | Console.WriteLine("BBMD Demo Application started on 0xBAC0 Udp port\n\nAll foreign devices accepted (no filtering)\n"); 79 | 80 | // start the FD acceptation at least if BBMD list is empty or corrupted 81 | // and set up the device, see BacnetActivity static constructor 82 | BacnetActivity.AddPeerBBMD(null, null); 83 | 84 | if (BacnetActivity.OpenError == true) 85 | { 86 | Console.WriteLine("\t Error, certainly due to the Udp Port already in use"); 87 | return; 88 | } 89 | 90 | // Set BBMD peers 91 | SetBBMDList(); 92 | 93 | // Update each 10s the second CHARACTERSTRING OBJECT Present Value 94 | BacnetObjectId b = new BacnetObjectId(BacnetObjectTypes.OBJECT_CHARACTERSTRING_VALUE, 1); 95 | for ( ; ; ) 96 | { 97 | Thread.Sleep(10000); 98 | BacnetActivity.SetBacObjectPresentValue(b, new BacnetValue(BacnetActivity.GetFDList())); 99 | } 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /DemoBBMD/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Les informations générales relatives à un assembly dépendent de 6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations 7 | // associées à un assembly. 8 | [assembly: AssemblyTitle("DemoBBMD")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Microsoft")] 12 | [assembly: AssemblyProduct("DemoBBMD")] 13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly 18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de 19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM 23 | [assembly: Guid("2be634fa-2d05-40bc-9698-1be44e02a5fd")] 24 | 25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes : 26 | // 27 | // Version principale 28 | // Version secondaire 29 | // Numéro de build 30 | // Révision 31 | // 32 | // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut 33 | // en utilisant '*', comme indiqué ci-dessous : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DemoBBMD/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /DemoBBMD/nuget.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /DemoBBMD/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MIT_license.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Yabe project 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /ObjectBrowseSample/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ObjectBrowseSample/ObjectBrowseSample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CD8499E5-8FB1-44FC-9B42-BB437C58AAA2} 8 | Exe 9 | Properties 10 | ObjectBrowseSample 11 | ObjectBrowseSample 12 | v4.5 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | ..\packages\BACnet.1.0.8.5-alpha\lib\net40\BACnet.dll 37 | True 38 | 39 | 40 | ..\packages\PacketDotNet.0.13.0\lib\net\PacketDotNet.dll 41 | True 42 | 43 | 44 | ..\packages\SharpPcap.4.2.0\lib\net\SharpPcap.dll 45 | True 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 72 | -------------------------------------------------------------------------------- /ObjectBrowseSample/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO.BACnet; 3 | 4 | namespace ObjectBrowseSample 5 | { 6 | internal class Program 7 | { 8 | private static void Main() 9 | { 10 | var transport = new BacnetIpUdpProtocolTransport(0xBAC0, true); 11 | var client = new BacnetClient(transport); 12 | client.OnIam += OnIAm; 13 | client.Start(); 14 | client.WhoIs(); 15 | Console.ReadLine(); 16 | } 17 | 18 | private static async void OnIAm(BacnetClient sender, BacnetAddress adr, 19 | uint deviceid, uint maxapdu, BacnetSegmentations segmentation, ushort vendorid) 20 | { 21 | Console.WriteLine($"Detected device {deviceid} at {adr}"); 22 | 23 | // In theory each bacnet device should have object of type OBJECT_DEVICE with property PROP_OBJECT_LIST 24 | // This property is a list of all bacnet objects (ids) of that device 25 | 26 | var deviceObjId = new BacnetObjectId(BacnetObjectTypes.OBJECT_DEVICE, deviceid); 27 | var objectIdList = await sender.ReadPropertyAsync(adr, deviceObjId, BacnetPropertyIds.PROP_OBJECT_LIST); 28 | 29 | foreach (var objId in objectIdList) 30 | Console.WriteLine($"{objId}"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ObjectBrowseSample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("ObjectBrowseSample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("ObjectBrowseSample")] 13 | [assembly: AssemblyCopyright("Copyright © 2016")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("cd8499e5-8fb1-44fc-9b42-bb437c58aaa2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /ObjectBrowseSample/nuget.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /ObjectBrowseSample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Bacnet.Room.Simulator 2 | 3 | This windows form application *simulates* an heating/cooling room controler. See the Readme file in the application directory. 4 | 5 | ### BasicReadWrite 6 | 7 | * Send a `Whois` to all devices on the net 8 | * Get back all the `Iam` responses 9 | * Read `Present_Value` property on the object `ANALOG_INPUT:1` provided by the device 1026 10 | * Write `Present_Value` property on the object `ANALOG_OUTPUT:0` provided by the device 4000 11 | 12 | ### BasicAdviseCOV 13 | 14 | * Send a `Whois` to all devices on the net 15 | * Get back all the `Iam` responses 16 | * Advise to `OBJECT_ANALOG_INPUT:1` provided by the device 1026, for 60 secondes 17 | * Write on the console each notification 18 | 19 | ### BasicAlarmListener 20 | 21 | * Can send reponses to `WhoIs` query : own device id is 2000 22 | * Can send responses to `ReadProperty`/`ReadPropertyMultiple` 23 | * Write on the console each `Alarm` or `Event` received (broadcast or unicast) 24 | 25 | ### BasicServer 26 | 27 | * Send an `Iam` message : own device id is 1234 28 | * Can send reponses to `WhoIs` query 29 | * Offers three objects `OBJECT_DEVICE:1234`, `OBJECT_ANALOG_INPUT:0`, `OBJECT_ANALOG_VALUE:0` 30 | * Only `OBJECT_ANALOG_VALUE:0.PRESENT_VALUE` can be writen 31 | * `OBJECT_ANALOG_INPUT_0.PRESENT_VALUE` changes continously: `PRESENT_VALUE = OBJECT_ANALOG_VALUE_0.PRESENT_VALUE * Sin (w.t)` 32 | 33 | ### BBMDDemo 34 | 35 | * BBMD services on a simple device server with only one Device Object 36 | * Foreign devices accepted 37 | * Tested with 38 | * Wago 750/830 (vendor Id 222) 39 | * Newron DoGate (vendor Id 451) 40 | * Sauter EY-AS521 (vendor Id 80) 41 | * Also running on a Raspberry Pi on Linux/Mono 42 | 43 | ### AnotherStorageImplementation 44 | 45 | Shows another way, much complex than the original one in DeviceStorage.cs file (without the Xml descriptor also) to write a server. Each Bacnetobject is a object in the C# code. So a class must be written for each Bacnet object type, but this give the possibility to have a complex behaviour in objects code. Shows also dynamic creation/destruction of objects by a remote client. Actual objects types are : 46 | 47 | * Device 48 | * Structured View 49 | * Analog Input, Analog Value, Analog Output (With Intrinsect reporting) 50 | * Digital Input, Digial Value, Digital Output 51 | * Multistates Input, Multistates Value, Multistates Output (With Intrinsect reporting) 52 | * Characters String 53 | * File 54 | * Trendlog 55 | * Notification Class 56 | * Schedule 57 | * Calendar 58 | 59 | 60 | Objects persistance could be achieved with serialization 61 | 62 | ### RaspberrySample 63 | 64 | This application is similar to BasicServer, for Raspberry Pi with Mono. DeviceDescriptor.xml should be modify in order to access as your want the GPIO pins : 65 | 66 | * `OBJECT_BINARY_INPUT:x` - GPIOX will be configured and used as an input 67 | * `OBJECT_BINARY_OUTPUT:x` - GPIOX will be configured and used as an output 68 | * `PRESENT_VALUE` will be apply to the output at the begining 69 | 70 | When adding new objects, take care to add it also in the `PROP_OBJECT_LIST` of the `DEVICE_OBJECT`. In the original DeviceDescriptor.xml file one can found GPIO4 as input and GPIO7, GPIO8 as output. Also `OBJECT_ANALOG_INPUT:0` get the CPU temperature. Mono should be installed (mono complete not mono runtime it's not enough !), and to start the code in sudo mode : `sudo mono ./RaspberrySample.exe`. DeviceDescriptor.xml must be in the application directory 71 | 72 | Tested on a Raspberry Pi Model B. Similar code based on AnotherStorageImplementation. Run 24/24 acting also as a BBMD somewhere in France. Ready with small modifications (GPIO) for Intel/Edison, Texas/BeagleBone, and a lot of Linux plateforms with Mono installed. 73 | 74 | ### BacnetToDatabase 75 | 76 | A sample application that will transfer all present values from a given device, to a SQL database. (SQL CE Local DB.) 77 | 78 | ### ObjectBrowseSample 79 | 80 | In theory each bacnet device should have object of type OBJECT_DEVICE with property PROP_OBJECT_LIST. This property should contain a list of all bacnet objects (ids) of that device. In this sample we detect bacnet device in local network and try to list its object ids by reading this property. -------------------------------------------------------------------------------- /RaspberrySample/FileGPIO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | 7 | // some light modifications from the original 8 | // https://www.raspberrypi.org/forums/viewtopic.php?p=88063#p88063 9 | 10 | // 11 | // This class works also on Beaglebone, Intel Edison, and a lot of others plateforms 12 | // 13 | 14 | namespace GPIO 15 | { 16 | public static class FileGPIO 17 | { 18 | //GPIO connector on the Pi (P1) (as found next to the yellow RCA video socket on the Rpi circuit board) 19 | //P1-01 = top left, P1-02 = top right 20 | //P1-25 = bottom left, P1-26 = bottom right 21 | //pi connector P1 pin = GPIOnum = slice of pi v1.0 board label 22 | // P1-07 = GPIO4 = GP7 23 | // P1-11 = GPIO17 = GP0 24 | // P1-12 = GPIO18 = GP1 25 | // P1-13 = GPIO21 = GP2 26 | // P1-15 = GPIO22 = GP3 27 | // P1-16 = GPIO23 = GP4 28 | // P1-18 = GPIO24 = GP5 29 | // P1-22 = GPIO25 = GP6 30 | //So to turn on Pin7 on the GPIO connector, pass in 4 as the pin parameter 31 | 32 | public enum enumDirection { IN, OUT }; 33 | 34 | private const string GPIO_PATH ="/sys/class/gpio/"; 35 | 36 | //contains list of pins exported with an OUT direction 37 | static List _OutExported = new List(); 38 | 39 | //contains list of pins exported with an IN direction 40 | static List _InExported = new List(); 41 | 42 | static FileGPIO() 43 | { 44 | CleanUpAllPins(); 45 | } 46 | 47 | //this gets called automatically when we try and output to, or input from, a pin 48 | private static void SetupPin(uint pin, enumDirection direction) 49 | { 50 | try 51 | { 52 | //unexport if it we're using it already 53 | if (_OutExported.Contains(pin) || _InExported.Contains(pin)) UnexportPin(pin); 54 | 55 | //export 56 | File.WriteAllText(GPIO_PATH + "export", pin.ToString()); 57 | 58 | // set i/o direction 59 | File.WriteAllText(GPIO_PATH +"gpio"+pin.ToString() + "/direction", direction.ToString().ToLower()); 60 | 61 | //record the fact that we've setup that pin 62 | if (direction == enumDirection.OUT) 63 | _OutExported.Add(pin); 64 | else 65 | _InExported.Add(pin); 66 | } 67 | catch{} 68 | } 69 | 70 | //no need to setup pin this is done for you 71 | public static void OutputPin(uint pin, bool value) 72 | { 73 | if (Environment.OSVersion.Platform != System.PlatformID.Unix) return; 74 | 75 | //if we havent used the pin before, or if we used it as an input before, set it up 76 | if (!_OutExported.Contains(pin) || _InExported.Contains(pin)) SetupPin(pin, enumDirection.OUT); 77 | 78 | string writeValue = "0"; 79 | if (value) writeValue = "1"; 80 | File.WriteAllText(GPIO_PATH +"gpio"+ pin.ToString() + "/value", writeValue); 81 | 82 | } 83 | 84 | //no need to setup pin this is done for you 85 | public static bool InputPin(uint pin) 86 | { 87 | if (Environment.OSVersion.Platform != System.PlatformID.Unix) return false; 88 | 89 | bool returnValue = false; 90 | 91 | //if we havent used the pin before, or if we used it as an output before, set it up 92 | if (!_InExported.Contains(pin) || _OutExported.Contains(pin) ) SetupPin(pin, enumDirection.IN); 93 | 94 | string filename = GPIO_PATH +"gpio"+ pin.ToString() + "/value"; 95 | if (File.Exists(filename)) 96 | { 97 | string readValue = File.ReadAllText(filename); 98 | if (readValue != null && readValue.Length > 0 && readValue[0] == '1') returnValue = true; 99 | } 100 | else 101 | throw new Exception(string.Format("Cannot read from {0}. File does not exist", pin)); 102 | 103 | return returnValue; 104 | } 105 | 106 | //if for any reason you want to unexport a particular pin use this, otherwise just call CleanUpAllPins when you're done 107 | private static void UnexportPin(uint pin) 108 | { 109 | bool found = false; 110 | if (_OutExported.Contains(pin)) 111 | { 112 | found = true; 113 | _OutExported.Remove(pin); 114 | } 115 | if (_InExported.Contains(pin)) 116 | { 117 | found = true; 118 | _InExported.Remove(pin); 119 | } 120 | 121 | if (found) 122 | { 123 | File.WriteAllText(GPIO_PATH + "unexport", pin.ToString()); 124 | } 125 | } 126 | 127 | public static void CleanUpAllPins() 128 | { 129 | if (Environment.OSVersion.Platform != System.PlatformID.Unix) return; 130 | 131 | for (int i=0;i<30;i++) 132 | try 133 | { 134 | File.WriteAllText(GPIO_PATH + "unexport", i.ToString()); 135 | } 136 | catch { } 137 | } 138 | 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /RaspberrySample/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // Les informations générales relatives à un assembly dépendent de 6 | // l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations 7 | // associées à un assembly. 8 | [assembly: AssemblyTitle("RaspberrySample")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("RasberrySample")] 13 | [assembly: AssemblyCopyright("Copyright ©2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly 18 | // aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de 19 | // COM, affectez la valeur true à l'attribut ComVisible sur ce type. 20 | [assembly: ComVisible(false)] 21 | 22 | // Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM 23 | [assembly: Guid("4640765b-1c38-40c9-8167-9ce1edd444f9")] 24 | 25 | // Les informations de version pour un assembly se composent des quatre valeurs suivantes : 26 | // 27 | // Version principale 28 | // Version secondaire 29 | // Numéro de build 30 | // Révision 31 | // 32 | // Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut 33 | // en utilisant '*', comme indiqué ci-dessous : 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /RaspberrySample/RaspberrySample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {47FC9B60-CC4A-479C-8267-DCEEE53067AC} 9 | Exe 10 | Properties 11 | RasberrySample 12 | RasberrySample 13 | v4.0 14 | Client 15 | 512 16 | 17 | 18 | true 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | full 22 | AnyCPU 23 | prompt 24 | false 25 | false 26 | 27 | 28 | bin\Release\ 29 | TRACE 30 | true 31 | pdbonly 32 | AnyCPU 33 | prompt 34 | false 35 | false 36 | false 37 | 38 | 39 | 40 | ..\packages\BACnet.1.0.8.5-alpha\lib\net40\BACnet.dll 41 | True 42 | 43 | 44 | ..\packages\PacketDotNet.0.13.0\lib\net\PacketDotNet.dll 45 | True 46 | 47 | 48 | ..\packages\SharpPcap.4.2.0\lib\net\SharpPcap.dll 49 | True 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | Always 68 | Designer 69 | 70 | 71 | 72 | 73 | 80 | -------------------------------------------------------------------------------- /RaspberrySample/nuget.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /RaspberrySample/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | --------------------------------------------------------------------------------