Ejemplo n.º 1
0
        /// <summary>
        /// The factory method for Core "things". Also iterates the Factory methods that have
        /// been loaded from plugins
        /// </summary>
        /// <param name="dc"></param>
        /// <returns></returns>
        public static IKeyed GetDevice(DeviceConfig dc)
        {
            var key        = dc.Key;
            var name       = dc.Name;
            var type       = dc.Type;
            var properties = dc.Properties;

            var typeName = dc.Type.ToLower();

            // Check "core" types first
            if (typeName == "genericcomm")
            {
                Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
                return(new GenericComm(dc));
            }
            else if (typeName == "ceniodigin104")
            {
                var control = CommFactory.GetControlPropertiesConfig(dc);
                var ipid    = control.IpIdInt;

                return(new CenIoDigIn104Controller(key, name, new Crestron.SimplSharpPro.GeneralIO.CenIoDi104(ipid, Global.ControlSystem)));
            }

            // then check for types that have been added by plugin dlls.
            if (FactoryMethods.ContainsKey(typeName))
            {
                Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from plugin", dc.Type);
                return(FactoryMethods[typeName](dc));
            }

            return(null);
        }
Ejemplo n.º 2
0
        public GenericComm(DeviceConfig config)
            : base(config)
        {
            PropertiesConfig = CommFactory.GetControlPropertiesConfig(config);

            CommPort = CommFactory.CreateCommForDevice(config);
        }
Ejemplo n.º 3
0
        public override EssentialsDevice BuildDevice(DeviceConfig dc)
        {
            Debug.Console(1, "Factory Attempting to create new CEN-DIGIN-104 Device");

            var control = CommFactory.GetControlPropertiesConfig(dc);
            var ipid    = control.IpIdInt;

            return(new CenIoDigIn104Controller(dc.Key, dc.Name, new Crestron.SimplSharpPro.GeneralIO.CenIoDi104(ipid, Global.ControlSystem)));
        }
Ejemplo n.º 4
0
        public GenericComm(DeviceConfig config)
            : base(config)
        {
            PropertiesConfig = CommFactory.GetControlPropertiesConfig(config);

            var commPort = CommFactory.CreateCommForDevice(config);

            //Fixing decision to require '-comPorts' in delcaration for DGE in order to get a device with comports included
            if (commPort == null)
            {
                config.Key = config.Key + "-comPorts";
                commPort   = CommFactory.CreateCommForDevice(config);
            }

            CommPort = commPort;
        }
Ejemplo n.º 5
0
        protected override void CustomSetConfig(DeviceConfig config)
        {
            PropertiesConfig = CommFactory.GetControlPropertiesConfig(config);

            ConfigWriter.UpdateDeviceConfig(config);
        }