Пример #1
0
        private void OnMqttMessageReceived(object sender, MQTTnet.MqttApplicationMessageReceivedEventArgs e)
        {
            Console.WriteLine($"{DateTime.Now} Received MQTT message. Topic: {e.ApplicationMessage.Topic} Payload: {e.ApplicationMessage.ConvertPayloadToString()}");
            try
            {
                string   parm    = null;
                string[] tokens  = e.ApplicationMessage.Topic.Split('/');
                string   payload = e.ApplicationMessage.ConvertPayloadToString();

                if (tokens.Length != 4)
                {
                    throw new InvalidMqttTopicException();
                }

                GenericDevice device = _hub.GetDeviceByLabel <GenericDevice>(tokens[2]) as GenericDevice;
                if (!string.IsNullOrEmpty(payload))
                {
                    parm = payload;
                }

                device.DoAction(tokens[3], parm);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{DateTime.Now} {ex}");
            }
        }
Пример #2
0
        public FusionAssetBase Add(GenericDevice device)
        {
            uint newId = 0;

            for (uint id = 1; id <= 249; id++)
            {
                if (!this.Fusion.Room.Fusion.FusionRoom.UserConfigurableAssetDetails.Contains(id))
                {
                    newId = id;
                    break;
                }
            }

            if (newId > 0)
            {
                this.Fusion.Room.Fusion.FusionRoom.AddAsset(eAssetType.StaticAsset, newId, device.GetType().Name.SplitCamelCase(),
                                                            device.Type.ToString().SplitCamelCase(), Guid.NewGuid().ToString());

                Assets[newId] = this.Fusion.Room.Fusion.FusionRoom.UserConfigurableAssetDetails[newId].Asset;

                Devices[device] = Assets[newId];
                ((FusionStaticAsset)Devices[device]).AddSig(eSigType.String, 1, "IP Address", eSigIoMask.InputSigOnly);
                device.OnlineStatusChange  += new OnlineStatusChangeEventHandler(device_OnlineStatusChange);
                device.IpInformationChange += new IpInformationChangeEventHandler(device_IpInformationChange);

                return(Assets[newId]);
            }
            return(null);
        }
        public static string GenerateDimString(GenericDevice device, int dimLevel)
        {
            string level = Math.Round((decimal)dimLevel / 100 * 32).ToString();

            return("000,!R" + device.ParentZone.zoneNumber.ToString() +
                   "D" + device.deviceNumber.ToString() +
                   "FdP" + level.ToString() + "|\0");
        }
Пример #4
0
 protected void ReportDevice(object sender, GenericDevice device, DeviceStateEnum state)
 {
     if (OnReportDevice != null)
     {
         OnReportDevice(sender, new DeviceEventArgs <GenericDevice> {
             Device = device, State = state
         });
     }
 }
Пример #5
0
        /// <summary>
        /// First it creates a new <see cref="LeapMotionData"/> according to the <see cref="Neurorehab.Scripts.CpDebugger.Udp.GenericDevice"/> received as a parameter. Then, it instantiates a Unity object according to the hand side for each new detection for devices of this type.
        /// </summary>
        /// <param name="genericDevice">The device being checked.</param>
        protected override void CreateNewUnityObject(GenericDevice genericDevice)
        {
            foreach (var values in genericDevice.GetNewDetections(DevicesData.Keys.ToList()))
            {
                var genericDeviceData = (LeapMotionData)CreateGenericDeviceData(genericDevice.DeviceName, values);
                InstantiateUnityObject(genericDeviceData, genericDeviceData.LeftHanded ? 0 : 1);

                AddDeviceDataToList(values.Id, genericDeviceData);
            }
        }
        /// <summary>
        /// Support function, usually called from <see cref="CheckIfUnityObjectExists"/>. First it creates a new <see cref="GenericDeviceData"/> according to the <see cref="GenericDevice"/> received as a parameter. Then, it instantiate a Unity object for each new detection for devices of this type.
        /// </summary>
        /// <param name="genericDevice">The device being checked.</param>
        protected virtual void CreateNewUnityObject(GenericDevice genericDevice)
        {
            foreach (var values in genericDevice.GetNewDetections(DevicesData.Keys.ToList()))
            {
                var genericDeviceData = CreateGenericDeviceData(genericDevice.DeviceName, values);
                AddDeviceDataToList(values.Id, genericDeviceData);

                InstantiateUnityObject(genericDeviceData);
            }
        }
Пример #7
0
 /// <summary>
 /// This checks where Device of type GenericDevice existing by matching it against other devices using its Type and Serial Number
 /// </summary>
 /// <param name="Device">Device to look for</param>
 /// <returns></returns>
 public bool Contains(GenericDevice device)
 {
     try
     {
         return(Find(x => x.Status.SerialNumber == device.Status.SerialNumber) != null);
     }
     catch
     {
         return(false);
     }
 }
Пример #8
0
        /// <summary>
        /// Removes from the <see cref="DevicesData"/> entries that are no long present in the <see cref="GenericDevice"/> of this device.
        /// </summary>
        /// <param name="genericDevice"></param>
        protected void CleanOldObjects(GenericDevice genericDevice)
        {
            //var idsToKill = new List<string>();

            //var ids = genericDevice.GetDeviceIds();
            //foreach (var processData in DevicesData)
            //{
            //    if (processData.Value.DeviceName == genericDevice.DeviceName && ids.Contains(processData.Key) == false)
            //        idsToKill.Add(processData.Key);
            //}

            //foreach (var key in idsToKill)
            //{
            //    Debug.Log("CleanOldObjects -> Removing device data: " + key);
            //    DevicesData.Remove(key);
            //}
        }
Пример #9
0
            protected override void SetBindings()
            {
                var property = ViewModel;

                _handler = (sender, args) =>
                {
                    if (args.PropertyName == property)
                    {
                        PropertyValue.Text = _parent.ViewModel.Device.Values[property].ToString();
                    }
                };
                if (_parent.ViewModel.Device.Values.ContainsKey(property))
                {
                    PropertyValue.Text = _parent.ViewModel.Device.Values[property].ToString();
                }
                _previousDevice = _parent.ViewModel.Device;
                _previousDevice.PropertyChanged += _handler;
            }
Пример #10
0
        public AirMediaDevice(uint ipId, CrestronControlSystem controlSystem, string deviceType, string description)
        {
            try
            {
                var type = typeof(Am101);
                if (!string.IsNullOrEmpty(deviceType))
                {
                    try
                    {
                        var assembly = Assembly.Load(typeof(Am200).AssemblyName());
                        type = assembly.GetType(deviceType).GetCType();
                    }
                    catch
                    {
                        var assembly = Assembly.Load(typeof(Am101).AssemblyName());
                        type = assembly.GetType(deviceType).GetCType();
                    }
                }

                var ctor = type.GetConstructor(new CType[] { typeof(uint), typeof(CrestronControlSystem) });
                _device             = (GenericDevice)ctor.Invoke(new object[] { ipId, controlSystem });
                _device.Description = description;

                _device.IpInformationChange += AmOnIpInformationChange;
                _device.OnlineStatusChange  += AmOnOnlineStatusChange;
                if (_device is AmX00)
                {
                    ((AmX00)_device).AirMedia.AirMediaChange += AirMediaOnAirMediaChange;
                }
                var regResult = _device.Register();
                if (regResult != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    CloudLog.Error("Error registering {0} with ID 0x{1}, {2}", _device.GetType().Name, _device.ID.ToString("X2"),
                                   regResult);
                }
            }
            catch (Exception e)
            {
                CloudLog.Exception(e, "Error loading Air Media Device");
            }
        }
Пример #11
0
        public GenericZone(XmlNode settings, GatewayList gateways, DeviceStateChangedDelegate stateChanged,
                           FeedbackReceivedFromDeviceDelegate feedbackReceived)
        {
            _zoneName   = settings.Attributes["name"].InnerText;
            _zoneNumber = int.Parse(settings.Attributes["number"].InnerText);

            foreach (XmlNode childNode in settings.ChildNodes)
            {
                GenericDeviceGateway gtw = gateways[childNode.Attributes["gateway"].InnerText];
                Type          typ        = Type.GetType(childNode.Attributes["type"].InnerText);
                GenericDevice dev        = (GenericDevice)Activator.CreateInstance(typ, childNode, this, gtw);
                dev.DeviceEventRaised += feedbackReceived;
                if (dev is IStatefulDevice)
                {
                    ((IStatefulDevice)dev).StateChanged += stateChanged;
                    ((IStatefulDevice)dev).ForceStateRefresh();
                }

                _devices.Add(dev);
            }
        }
Пример #12
0
        private async void OnMqttMessageReceived(object sender, MQTTnet.MqttApplicationMessageReceivedEventArgs e)
        {
            Console.WriteLine($"{DateTime.Now} Received MQTT message. Topic: {e.ApplicationMessage.Topic} Payload: {e.ApplicationMessage.ConvertPayloadToString()}");
            using (var operation =
                       _telemetryClient.StartOperation <RequestTelemetry>($"{this.ToString()}: Message Received"))
            {
                _telemetryClient.TrackEvent("MQTT Message Received",
                                            new Dictionary <string, string>()
                {
                    { "Topic", e.ApplicationMessage.Topic },
                    { "Payload", e.ApplicationMessage.ConvertPayloadToString() },
                });
                try
                {
                    string   parm    = null;
                    string[] tokens  = e.ApplicationMessage.Topic.Split('/');
                    string   payload = e.ApplicationMessage.ConvertPayloadToString();

                    if (tokens.Length != 4)
                    {
                        throw new InvalidMqttTopicException();
                    }

                    GenericDevice device = await _hub.GetDeviceByLabel <GenericDevice>(tokens[2]);

                    if (!string.IsNullOrEmpty(payload))
                    {
                        parm = payload;
                    }

                    await device.DoAction(tokens[3], parm);
                }
                catch (Exception ex)
                {
                    operation.Telemetry.Success = false;
                    _telemetryClient.TrackException(ex);
                    Console.WriteLine($"{DateTime.Now} {ex}");
                }
            }
        }
Пример #13
0
        public GenericTrigger(XmlNode settings, GenericDevice parentDevice)
        {
            string[] parameters = new string[settings.Attributes.Count - 5];
            for (int i = 5; i < settings.Attributes.Count; i++)
            {
                parameters[i - 5] = settings.Attributes[i].InnerText;
            }

            switch (settings.Attributes["senderType"].InnerText)
            {
            case "Remote":
                SenderType = SenderTypeEnum.Remote;
                break;

            case "Device":
                SenderType = SenderTypeEnum.Device;
                break;

            case "Schedule":
                SenderType = SenderTypeEnum.Schedule;
                break;
            }

            Sender = settings.Attributes["sender"].InnerText;

            Type typ = Type.GetType(settings.Attributes["actionType"].InnerText);

            action = (GenericTriggerAction)Activator.CreateInstance(typ, settings.Attributes["action"].InnerText, parameters);

            sequence          = int.Parse(settings.Attributes["sequence"].InnerText);
            this.parentDevice = parentDevice;

            foreach (XmlNode buttonNode in settings.ChildNodes)
            {
                triggerCommands.Add(buttonNode.InnerText);
            }
        }
Пример #14
0
    private void DoSelectDeviceGUI()
    {
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Settings", m_ShowSettings ? Styles.BoldButtonSelecetd : Styles.BoldButton))
        {
            m_ShowSettings = !m_ShowSettings;
        }

        foreach (var t in m_DeviceTypes)
        {
            if (GUILayout.Button(t == null ? "All" : t.Name, m_SelectedType == t ? Styles.BoldButtonSelecetd : Styles.BoldButton))
            {
                m_SelectedType = t;
            }
        }
        GUILayout.EndHorizontal();


        if (m_ShowSettings)
        {
            DoSettings();
            return;
        }

        GUILayout.BeginHorizontal();
        m_DeviceScrollView = GUILayout.BeginScrollView(m_DeviceScrollView, GUILayout.Height(10 * Styles.FontSize));
        foreach (var d in InputSystem.devices)
        {
            if (m_SelectedType != null && !m_SelectedType.IsAssignableFrom(d.GetType()))
            {
                continue;
            }

            var name = string.Format("{0} (Type = {1}, Id = {2})", d.displayName, d.GetType().Name, d.deviceId);
            if (GUILayout.Button(name, m_Device != null && m_Device.Device == d ? Styles.BoldButtonSelecetd : Styles.BoldButton))
            {
                if (m_Device != null)
                {
                    m_Device.Dispose();
                }

                if (d as Keyboard != null)
                {
                    m_Device = new KeyboardDevice(d);
                }
                else if (d as Mouse != null)
                {
                    m_Device = new MouseDevice(d);
                }
                else if (d as Touchscreen != null)
                {
                    m_Device = new TouchscreenDevice(d);
                }
                else if (d as Sensor != null)
                {
                    m_Device = new SensorDevice(d);
                }
                else if (d as Gamepad != null)
                {
                    m_Device = new GamepadDevice(d);
                }
                else
                {
                    m_Device = new GenericDevice(d);
                }
            }
        }

        foreach (var deviceType in m_DeviceTypes)
        {
            if (deviceType == null || m_SelectedType != deviceType)
            {
                continue;
            }

            if (deviceType == typeof(Touchscreen))
            {
                GUILayout.Label(string.Format("TouchScreen.current = (Id = {0})", Touchscreen.current != null ? Touchscreen.current.deviceId.ToString() : "<null>"), Styles.BoldLabel);
            }
            else if (deviceType == typeof(Keyboard))
            {
                GUILayout.Label(string.Format("Keyboard.current = (Id = {0})", Keyboard.current != null ? Keyboard.current.deviceId.ToString() : "<null>"), Styles.BoldLabel);
            }
            else if (deviceType == typeof(Mouse))
            {
                GUILayout.Label(string.Format("Mouse.current = (Id = {0})", Mouse.current != null ? Mouse.current.deviceId.ToString() : "<null>"), Styles.BoldLabel);
            }
            else if (deviceType == typeof(Sensor))
            {
                DoSensors();
            }
            else if (deviceType == typeof(Gamepad))
            {
                GUILayout.Label(string.Format("Gamepad.current = (Id = {0})", Gamepad.current != null ? Gamepad.current.deviceId.ToString() : "<null>"), Styles.BoldLabel);
            }
            else
            {
                GUILayout.Label(string.Format("Unhandled device type '{0}'", deviceType.GetType().FullName), Styles.BoldLabel);
            }
        }
        GUILayout.EndScrollView();
        GUILayout.EndHorizontal();
    }
Пример #15
0
 public GenericVersion(GenericDevice device)
     : base(device)
 {
 }
Пример #16
0
 public GenericStatus(GenericDevice device)
     : base(device)
 {
 }
Пример #17
0
        private void DataTemplate(GenericDevice item, DeviceViewHolder holder, int position)
        {
            holder.Title.Text = $"Custom boiler {item.Repository}"; // $"Lat: {item.Lat}, Lon: {item.Lon}";

            holder.CardView.SetOnClickCommand(ViewModel.NavigateToGenericDeviceDetailsCommand, item);
        }
Пример #18
0
        static void Main(string[] args)
        {
            //
            // Creating platform definition and intializing it with relevant information.
            // CreateArmPlatform and Createx86Platform produces same DSDT but some platform
            // specific information in FADT and other firmware tables will get generated
            // to the specifc platform.
            //

            //ArmPlatform Platform = Platforms.CreateArmPlatform(
            x86Platform Platform = Platforms.Createx86Platform(
                OEMID: "MSFT",
                OEMTableID: "EDK2",
                CreatorID: "MSFT",
                Revision: 1, FileName: "DSDT"
                );

            //
            // Set PSCI bit - This is only Avaialble for Arm platforms
            //
            // Platform.PSCISupported = true;

            #region PROC
            Register  reg0_1, reg0_2, reg0_3;
            Processor CPU0 = Platform.AddProcessor("CPU0", 0);
            reg0_1 = new Register(RegisterType.SystemIO, 8, 0, 0x161);
            CPU0.AddCState(1, 20, 1000, reg0_1); // C1 State
            reg0_2 = new Register(RegisterType.SystemIO, 8, 0, 0x162);
            CPU0.AddCState(2, 40, 750, reg0_2);  // C2 State
            reg0_3 = new Register(RegisterType.SystemIO, 8, 0, 0x163);
            CPU0.AddCState(3, 60, 500, reg0_3);  // C3 State

            Processor CPU1 = Platform.AddProcessor("CPU1", 1);
            Register  reg1_1, reg1_2, reg1_3;
            reg1_1 = new Register(RegisterType.SystemIO, 8, 0, 0x164);
            CPU1.AddCState(1, 20, 1000, reg1_1); // C1 State
            reg1_2 = new Register(RegisterType.SystemIO, 8, 0, 0x165);
            CPU1.AddCState(2, 40, 750, reg1_2);  // C2 State
            reg1_3 = new Register(RegisterType.SystemIO, 8, 0, 0x166);
            CPU1.AddCState(3, 60, 500, reg1_3);  // C3 State

            Processor CPU2 = Platform.AddProcessor("CPU2", 2);
            Register  reg2_1, reg2_2, reg2_3;
            reg2_1 = new Register(RegisterType.SystemIO, 8, 0, 0x167);
            CPU2.AddCState(1, 20, 1000, reg2_1); // C1 State
            reg2_2 = new Register(RegisterType.SystemIO, 8, 0, 0x168);
            CPU2.AddCState(2, 40, 750, reg2_2);  // C2 State
            reg2_3 = new Register(RegisterType.SystemIO, 8, 0, 0x169);
            CPU2.AddCState(3, 60, 500, reg2_3);  // C3 State


            Processor CPU3 = Platform.AddProcessor("CPU3", 3);
            Register  reg3_1, reg3_2, reg3_3;
            reg3_1 = new Register(RegisterType.SystemIO, 8, 0, 0x16a);
            CPU3.AddCState(1, 20, 1000, reg3_1); // C1 State
            reg3_2 = new Register(RegisterType.SystemIO, 8, 0, 0x16b);
            CPU3.AddCState(2, 40, 750, reg3_2);  // C2 State
            reg3_3 = new Register(RegisterType.SystemIO, 8, 0, 0x16c);
            CPU3.AddCState(3, 60, 500, reg3_3);  // C3 State

            Platform.AddProcessorAggregator("AGR0");

            //
            // ADD Low Power Idle States to the Platform - only on X86 Socs
            //

            Platform.AddLowPowerIdleState(0, 0x100000, 0xffff000, reg0_1);
            Platform.AddLowPowerIdleState(1, 0x100000, 0xffff000, reg1_2);
            Platform.AddLowPowerIdleState(2, 0x100000, 0xffff000, reg2_3);
            Platform.AddLowPowerIdleState(3, 0x100000, 0xffff000, reg3_1);

            #endregion

            #region UsbDebug

            //
            // This Sections how to add USB Contoller to DSDT and generating DBG2 Table.
            //

            XhciUsbController usb1 = Platform.AddXhciUsbController("USB1", "XHCICONT", 0);
            usb1.Description = "USB Controller with Debug Support";

            //
            // Add Resources to the USB Contoller.
            //

            Memory32Fixed mem = usb1.AddMemory32Fixed(true, 0xf9000000, 0xfffff, "");
            usb1.AddMemory32Fixed(true, 0xf7000000, 0xfffff, "");
            usb1.AddInterrupt(InterruptType.Level, InterruptActiveLevel.ActiveHigh, SharingLevel.Shared, 0x8);
            usb1.AddInterrupt(InterruptType.Level, InterruptActiveLevel.ActiveHigh, SharingLevel.Shared, 0x9);

            //
            // Will mark the usb controller supports Debugging and automatically generate Dbg2 table
            //

            usb1.DebugEnabled   = true;
            mem.DebugAccessSize = DebugAccessSize.DWordAccess;

            //
            // Will Add dependencies based on the provider info. In this Example
            // USB controller have dependencies to PEP and GPIO Controller.
            //

            usb1.ProviderName = "PEP0,GPI0";

            #endregion UsbDebug

            #region DebugDevices

            //
            // This section shows how to add UART debug devices to DSDT.
            //

            SerialPort sp0 = Platform.AddSerialPort(SerialPortType.PL011UART, "UART", "HID3123", 4);
            sp0.DebugEnabled = true;
            sp0.AddMemory32Fixed(true, 0xf9000000, 0xfffff, "");
            sp0.AddMemory32Fixed(true, 0xf7000000, 0xfffff, "");
            sp0.AddInterrupt(InterruptType.Level, InterruptActiveLevel.ActiveHigh, SharingLevel.Shared, 0x8);
            sp0.AddInterrupt(InterruptType.Level, InterruptActiveLevel.ActiveHigh, SharingLevel.Shared, 0x9);

            //
            // This section shows how to add Serial debug devices to DSDT.
            //

            SerialPort sp1 = Platform.AddSerialPort(SerialPortType.Serial, "NSP0", "HID3123", 8);
            sp1.AddDebugMemory32Fixed(true, 0xf123a, 0x123, "MEM", DebugAccessSize.DWordAccess, 0x1, 0x1);
            sp1.AddInterrupt(InterruptType.Level, InterruptActiveLevel.ActiveHigh, SharingLevel.Shared, 0x8);
            sp1.AddInterrupt(InterruptType.Level, InterruptActiveLevel.ActiveHigh, SharingLevel.Shared, 0x9);

            //
            // This section shows how to add KDNET debug device to DSDT.
            //

            KDNet2Usb kdp = Platform.AddKDNet2Usb("KDO0", "HID12331", 0, 0x1234);
            kdp.DebugEnabled = true;

            #endregion DebugDevices

            #region UsbDeviceTree

            //
            // This Sections how to add USB Contoller to DSDT and adding child devices to Usb Controller.
            //

            EhciUsbController usb2 = Platform.AddEhciUsbController("USB2", "EHCICONT", 0);
            usb2.Description = "USB Controller without Debug Support";

            //
            // Add dependency info and resources to the controller.
            //

            usb2.ProviderName = "PEP0";
            usb2.AddMemory32Fixed(true, 0xf8000000, 0xaf, "");
            usb2.AddInterrupt(InterruptType.Level, InterruptActiveLevel.ActiveHigh, SharingLevel.Shared, 0x10);
            usb2.AddGPIOInterrupt(InterruptType.Edge, InterruptActiveLevel.ActiveHigh, SharingLevel.Exclusive, PinConfiguration.Up, 0, 0x32, "GPI0");

            //
            // Adding USB Wake Information.
            //

            usb2.S0W = DeviceState.D3hot;

            //
            // Add USB Hub and add 2 Children to the Hub.
            //

            UsbDevice rhub = usb2.AddUsbDevice("DEV1", 0);
            rhub.AddUsbDevice("DEV2", 2);
            rhub.AddUsbDevice("DEV3", 3);

            #endregion UsbDeviceTree

            #region ButtonArray

            //
            // This sections shows how to add buttons used in windows platforms to DSDT.
            // Button Array supports adding buttons like Windows Home button, Back button,
            // Vol +/-, Power button, Rotation Lock, Search Button etc.,
            //

            ButtonArrayDevice btn = Platform.AddButtonArrayDevice("BTN1", "BTNDEV", 0);
            btn.AddPowerButton(10, "GPI0", PinConfiguration.Up);
            btn.AddSearchButton(11, "GPI0", PinConfiguration.Down);
            btn.AddVolumeDownButton(12, "GPI0", PinConfiguration.Down);

            #endregion ButtonArray

            #region PEP

            //
            // This sections how how to add Pep device to DSDT. This section also demostrates
            // how to use packages and implement static functions.
            //

            Package   p, p1;// p2;
            PEPDevice pep0 = Platform.AddPepDevice("PEP0", "PEPDEV", 0);

            //
            // Add Resources to the PEP device.
            //

            pep0.AddInterrupt(InterruptType.Edge, InterruptActiveLevel.ActiveHigh, SharingLevel.Exclusive, 0x12);
            pep0.AddInterrupt(InterruptType.Edge, InterruptActiveLevel.ActiveHigh, SharingLevel.Exclusive, 0x13);
            pep0.AddInterrupt(InterruptType.Edge, InterruptActiveLevel.ActiveHigh, SharingLevel.Exclusive, 0x14);
            pep0.AddInterrupt(InterruptType.Edge, InterruptActiveLevel.ActiveHigh, SharingLevel.Exclusive, 0x15);
            pep0.AddMemory32Fixed(true, 0xfc428000, 0x4000, "");

            //
            // Implement a method which returns Package(s).
            //

            pep0.AddMethod("CINF").Value = (p = new Package());
            p.add(p1 = new Package());
            p1.add("\\\\_SB_.CPU0");
            p1.add(0x10);
            p.add(p1 = new Package());
            p1.add("\\\\_SB_.CPU1");
            p1.add(0x11);
            p.add(p1 = new Package());
            p1.add("\\\\_SB_.CPU2");
            p1.add(0x12);
            p.add(p1 = new Package());
            p1.add("\\\\_SB_.CPU3");
            p1.add(0x13);

            //
            // Shows how to implement a method which reurns a static Integer.
            //

            pep0.AddMethod("PINF").Value = 4;

            //
            // Shows how to implement a method which return byte array.
            //

            pep0.AddMethod("RINF").Value = new Byte[] { 0x10, 0x20, 0x30, 0x40 };

            //
            // Shows how to implement a method which returns string.
            //

            pep0.AddMethod("SINF").Value = "TEST_PEP";

            #endregion PEP

            #region TZ

            //
            // This section shows how to implement Thermal Zones.
            //

            ThermalZone tz = Platform.AddThermalZone("TZ0_");
            tz.ThermalConstant1_TC1         = 1;
            tz.ThermalConstant2_TC2         = 2;
            tz.ThermalSamplingPeriod_TSP    = 0xa;
            tz.ThermalZonePollingPeriod_TZP = 0;
            tz.ThermalZoneDevices_TZD       = "CPU0,CPU1,CPU2,CPU3";
            tz.PassiveCoolingValue_PSV      = 0xe60;

            #endregion TZ

            #region RTC

            //
            // This section shows how to implement Acpi Time and Alarm device.
            //

            RTCDevice rtc = Platform.AddRTCDevice("RTCD");

            #endregion RTC

            #region GpioController

            //
            // This section shows how to add GPIO Controller to DSDT.
            //

            GpioController gpc = Platform.AddGpioController("GPI0", "GPIOCONT", 0);

            //
            // Add dependency information. GPIO Controller depends on PEP in this example.
            //

            gpc.ProviderName = "PEP0";

            //
            // Add resources to the GPIO Controller.
            //

            gpc.AddMemory32Fixed(true, 0xfd510000, 0x2000, "");
            gpc.AddInterrupt(InterruptType.Level, InterruptActiveLevel.ActiveHigh, SharingLevel.Shared, 0x16);

            #endregion GpioController

            #region SdController

            //
            // This section shows how to add SD Controller to DSDT.
            //

            SdHostController sd = Platform.AddSdHostController("SDC1", "SDCHOST", 0);
            sd.ProviderName = "PEP0";

            #endregion SdController

            #region Battery

            //
            // This section shows how to add Battery to DSDT.
            //

            BatteryDevice bat = Platform.AddBatteryDevice("BAT1", 1);
            bat.ThermalLimit = 10;

            #endregion Battery

            #region DisplaySensor

            //
            // This section shows how to add Display sensor to DSDT.
            //

            DisplaySensor dis = Platform.AddDisplaySensor("DISP", "DISPSENS");
            dis.ProviderName = "PEP0";

            #endregion DisplaySensor

            #region ACAdapter

            //
            // This section shows how to add AC Adapter to DSDT.
            //

            ACAdapter ac = Platform.AddACAdapter("ACA");

            #endregion ACAdapter

            #region HidI2c

            //
            // This section shows how to add HID I2C Device to DSDT.
            // In this case its an ATML touch device.
            //

            HidOverI2C hid = Platform.AddHidI2CDevice("TCH", "ATML1000", 1);
            hid.AddI2CSerialBus(0xf, SlaveMode.ControllerInitiated, 0xffff, AddressMode._7Bit, "I2C1");

            #endregion HidI2c

            #region I2CController

            //
            // This section shows how to add I2C Controller to DSDT.
            //

            I2CController i2c = Platform.AddI2CController("I2C1", "I2CCONTR", 0);
            i2c.AddMemory32Fixed(true, 0xf9999000, 0x400, "");
            i2c.AddInterrupt(InterruptType.Level, InterruptActiveLevel.ActiveHigh, SharingLevel.Exclusive, 40);

            #endregion I2CController

            #region GenericDevice

            //
            // This section shows how to add a generic device. Generic devices can be
            // flexible and can be used to replace any type of internally supported devices
            // in the framework.
            //

            GenericDevice Gen1 = Platform.AddGenericDevice("GEN1", "ABC123", "", 0);
            GenericDevice Gen2 = Gen1.AddGenericDevice("GEN2", "ABC123", "", 1);

            #endregion GenericDevice

            #region Firmware

            //
            // MADT: Generates a MADT table for Arm Version
            //

            // Platform.MadtBaseAddress = 0xEFC213;
            // Platform.AddInterruptControler(CPU0, InterruptType.Edge, 0, 2, 15, 0x1D4F, 0x34DFCD);
            // Platform.AddInterruptControler(CPU1, InterruptType.Edge, 3, 2, 17, 0x52DE, 0x12DCEE);
            // Platform.AddInterruptExtender(0xCD312, 0xFCC234, 13);

            //
            // Madt Table for X86 Soc
            //

            Platform.MadtBaseAddress = 0xEFC213;
            Platform.AddInterruptController(CPU0, 0);
            Platform.AddInterruptController(CPU1, 2);
            Platform.AddInterruptExtender(5, 0xFA23, 7);


            //
            // GTDT: Generates a GTDT table.
            //

            Timers timers = Platform.AddTimers(InterruptType.Edge, 0x1242FE);
            timers.ConfigureTimer(TimerType.PL1, InterruptType.Edge, InterruptActiveLevel.ActiveLow, 10);
            timers.ConfigureTimer(TimerType.NPL1, InterruptType.Edge, InterruptActiveLevel.ActiveLow, 5);
            timers.ConfigureTimer(TimerType.VT, InterruptType.Level, InterruptActiveLevel.ActiveLow, 11);
            timers.ConfigureTimer(TimerType.NPL2, InterruptType.Edge, InterruptActiveLevel.ActiveLow, 21);

            //
            // CSRT: Creates an Entry into DSDT aswell as generate a CSRT Table.
            //

            Byte[]           info = { 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 };
            CoreSystemDevice core = Platform.AddCoreSystemDevice("ABC1", "MSFT123", 2, 1, info);
            core.AddTimerCoreSystemResource(1, info);

            #endregion

            //
            // Generates firmware tables.
            //

            Platform.WriteAsl();
        }
Пример #19
0
 public OpCode(GenericDevice device)
 {
     Initialize(device);
 }
Пример #20
0
 protected void Initialize(GenericDevice device)
 {
     this.ParentDevice = device;
 }
Пример #21
0
 public void Initialize(GenericDevice parent)
 {
     this.ParentDevice = parent;
     InitializeQueue();
 }
Пример #22
0
 public GenericComponent(GenericDevice device)
 {
     Initialize(device);
 }
Пример #23
0
 public OpCodeWrapper(GenericDevice parent)
 {
     Initialize(parent);
 }
 public static string GenerateToggleDeviceStateString(GenericDevice device, int state)
 {
     return("000,!R" + device.ParentZone.zoneNumber.ToString() +
            "D" + device.deviceNumber.ToString() +
            "F" + state.ToString() + "|\0");
 }
Пример #25
0
 public GenericBattery(GenericDevice device)
     : base(device)
 {
 }
Пример #26
0
 public GenericMemorySize(GenericDevice device)
     : base(device)
 {
 }
Пример #27
0
 public override bool IsOfSameType(GenericDevice other)
 {
     return(base.IsOfSameType(other) &&
            this.Memory == (other as MicroXDevice).Memory);
 }