示例#1
0
文件: Adapter.cs 项目: alljoyn/dsb
        public Adapter()
        {
            byte[] ConfigurationDataPtr;
            if (GetConfiguration(out ConfigurationDataPtr) == ERROR_SUCCESS)
            {
                var temp = System.Text.Encoding.UTF8.GetString(ConfigurationDataPtr);
                m_gateway = new ModbusGateway(System.Text.Encoding.UTF8.GetString(ConfigurationDataPtr));  // The Designated IP address of the Modbus Gateway
            }

            Windows.ApplicationModel.Package        package        = Windows.ApplicationModel.Package.Current;
            Windows.ApplicationModel.PackageId      packageId      = package.Id;
            Windows.ApplicationModel.PackageVersion versionFromPkg = packageId.Version;

            this.Vendor      = "Microsoft";
            this.AdapterName = "Modbus Device System Bridge";

            // the adapter prefix must be something like "com.mycompany" (only alpha num and dots)
            // it is used by the Device System Bridge as root string for all services and interfaces it exposes
            this.ExposedAdapterPrefix   = "com." + this.Vendor.ToLower();
            this.ExposedApplicationGuid = Guid.Parse("{0xd3982475,0x38eb,0x4e53,{0xb8,0xd8,0x54,0x04,0xd8,0x78,0x88,0x1a}}");

            if (null != package && null != packageId)
            {
                this.ExposedApplicationName = packageId.Name;
                this.Version = versionFromPkg.Major.ToString() + "." +
                               versionFromPkg.Minor.ToString() + "." +
                               versionFromPkg.Revision.ToString() + "." +
                               versionFromPkg.Build.ToString();
            }
            else
            {
                this.ExposedApplicationName = "ModbusDeviceSystemBridge";
                this.Version = "0.0.0.0";
            }

            try
            {
                this.Signals         = new List <IAdapterSignal>();
                this.devices         = new List <IAdapterDevice>();
                this.signalListeners = new Dictionary <int, IList <SIGNAL_LISTENER_ENTRY> >();

                //Create Adapter Signals
                this.createSignals();
            }
            catch (OutOfMemoryException ex)
            {
                throw;
            }
        }
示例#2
0
        internal ModbusSensorDevice(
            ModbusGateway GatewayObj,
            string Name,
            string VendorName,
            string Model,
            string Version,
            string SerialNumber,
            string Description)
        {
            this.Gateway         = GatewayObj;
            this.Name            = Name;
            this.Vendor          = VendorName;
            this.Model           = Model;
            this.Version         = Version;
            this.FirmwareVersion = Version;
            this.SerialNumber    = SerialNumber;
            this.Description     = Description;

            try
            {
                this.Properties = new List <IAdapterProperty>();
                this.Methods    = new List <IAdapterMethod>();
                this.Signals    = new List <IAdapterSignal>();

                //Initialize AttributeMap
                AttributeMap.Add("Temperature", 0);
                AttributeMap.Add("Humidity", 1);
                AttributeMap.Add("Temperature Adjustment", 2);
                AttributeMap.Add("Humidity Adjustment", 3);
                AttributeMap.Add("T/H Reading Interval", 4);
                AttributeMap.Add("CO2 Concentration", 5);
                AttributeMap.Add("CO2 Adjustment", 6);
                AttributeMap.Add("CO2 Reading Interval", 7);
            }
            catch (OutOfMemoryException ex)
            {
                throw;
            }
        }