static void Main(string[] args) { InitDeviceObjects(); // Force the JIT compiler to make some job before network access device.Cli2Native(); // Remove reference to the NewtonSoft.Json dll if persistence // not required or simplest solution implemented SaveAndRestoreBackSample(); BacnetActivity.StartActivity(device); Console.WriteLine("Running ..."); // A simple activity int i = 0; for (; ;) { Thread.Sleep(500); lock (device) // required for all change { // A direct write into the attribut value could be made // if status change for protected to public // but this one force the COV management if needed ana0.internal_PROP_PRESENT_VALUE = 100 * Math.Sin(0.1 * (i++)); } } }
static void Main(string[] args) { // The First Device with 1 Device Object and 1 AnalogInput DeviceObject Dev1 = new DeviceObject(1234, "Device 1", "The First Device", false); AnalogInput <float> Temp = new AnalogInput <float> ( 0, "Temperature", "Temperature", 0, BacnetUnitsId.UNITS_DEGREES_CELSIUS ); Dev1.AddBacnetObject(Temp); Temp.internal_PROP_PRESENT_VALUE = 22.6f; // The Second Device with 1 Device Object and also 1 AnalogInput DeviceObject Dev2 = new DeviceObject(5678, "Device 2", "The Second Device", false); AnalogInput <float> Windspeed = new AnalogInput <float> ( 1, "Windspeed", "Wind speed", 0, BacnetUnitsId.UNITS_KILOMETERS_PER_HOUR ); Dev2.AddBacnetObject(Windspeed); Windspeed.internal_PROP_PRESENT_VALUE = 0.2f; // Force the JIT compiler to make some job before network access Dev2.Cli2Native(); // Start the activity for both device BacnetActivity BacAc1 = new BacnetActivity(); BacAc1.StartActivity(Dev1); BacnetActivity BacAc2 = new BacnetActivity(); BacAc2.StartActivity(Dev2); // Some animation ! for (; ;) { Thread.Sleep(1000); // a Ramp on an object if (Temp.internal_PROP_PRESENT_VALUE < 30) { Temp.internal_PROP_PRESENT_VALUE = Temp.internal_PROP_PRESENT_VALUE + 1; } else { Temp.internal_PROP_PRESENT_VALUE = 10f; } } }
void InitBacnetDictionary() { uint deviceId; if (UInt32.TryParse(BacnetDeviceId, out deviceId) == false) { deviceId = 12345; // default value } device = new DeviceObject(deviceId, "Weather2 to Bacnet ", "Weather2 data", false); if ((UserAccessKey != null) && (Latitude != null) && (Longitude != null)) { Temp = new AnalogInput <float> ( 0, "Temperature", "Temperature", 0, BacnetUnitsId.UNITS_DEGREES_CELSIUS ); // 24h trendlog TrendTemp = new TrendLog(0, "Temperature Trend", "Temperature Trend", 6 * 24, BacnetTrendLogValueType.TL_TYPE_SIGN); Windspeed = new AnalogInput <float> ( 1, "Windspeed", "Wind speed", 0, BacnetUnitsId.UNITS_KILOMETERS_PER_HOUR ); Humidity = new AnalogInput <float> ( 2, "Humidity", "Humidity", 0, BacnetUnitsId.UNITS_PERCENT ); Pressure = new AnalogInput <float> ( 3, "Pressure", "Pressure", 0, BacnetUnitsId.UNITS_HECTOPASCALS ); DewPoint = new AnalogInput <float> ( 4, "DewPoint", "Dew Point", 0, BacnetUnitsId.UNITS_DEGREES_CELSIUS ); VaporPressure = new AnalogInput <float> ( 5, "VaporPressure", "Equilibrium Vapor Pressure", 0, BacnetUnitsId.UNITS_HECTOPASCALS ); Windsdir = new CharacterString (0, "Winddir", "Wind Direction", "Not available", false); WeatherDescr = new CharacterString (1, "WeatherDescr", "Weather Description", "Not available", false); SunRise = new BacnetDateTime(0, "Sunrise", "Sun up time"); SunSet = new BacnetDateTime(1, "Sunset", "Sun down time"); Updatetime = new BacnetDateTime(2, "Updatetime", "Date & Time of the current values"); NextUpdatetime = new BacnetDateTime(3, "NextUpdatetime", "Date & Time of the next request"); device.AddBacnetObject(Temp); device.AddBacnetObject(TrendTemp); device.AddBacnetObject(Windspeed); device.AddBacnetObject(Humidity); device.AddBacnetObject(Pressure); device.AddBacnetObject(DewPoint); device.AddBacnetObject(VaporPressure); device.AddBacnetObject(Windsdir); device.AddBacnetObject(WeatherDescr); device.AddBacnetObject(SunRise); device.AddBacnetObject(SunSet); device.AddBacnetObject(Updatetime); device.AddBacnetObject(NextUpdatetime); device.AddBacnetObject(new NotificationClass(0, "Notification", "Notification")); } else { device.m_PROP_SYSTEM_STATUS = BacnetDeviceStatus.NON_OPERATIONAL; } // Force the JIT compiler to make some job before network access device.Cli2Native(); BacnetActivity.StartActivity(device); }