Esempio n. 1
0
        public override List <HeliosInterface> GetInterfaceInstances(HeliosInterfaceDescriptor descriptor, HeliosProfile profile)
        {
            List <HeliosInterface> interfaces = new List <HeliosInterface>();

            if (descriptor == null)
            {
                Logger.Warn("Descriptor is null passed into UniqueHeliosInterfaceFactory.GetInterfaceInstances.");
            }
            else
            {
                if (IsUnique(descriptor, profile))
                {
                    HeliosInterface newInterface = (HeliosInterface)Activator.CreateInstance(descriptor.InterfaceType);
                    if (newInterface == null)
                    {
                        Logger.Warn("New interface is null.");
                    }
                    interfaces.Add(newInterface);
                }
                else
                {
                    Logger.Debug("Unique interface already exists in profile " + descriptor.Name + ". Type: " + descriptor.InterfaceType.BaseType.Name);
                }
            }

            return(interfaces);
        }
Esempio n. 2
0
        public IEnumerable <string> DeserializeInterface(HeliosInterfaceCollection destination, XmlReader xmlReader)
        {
            string interfaceType = xmlReader.GetAttribute("TypeIdentifier");

            ComponentUnsupportedSeverity unsupportedSeverity = ReadUnsupportedSeverity(xmlReader);
            HeliosInterface heliosInterface = (HeliosInterface)CreateNewObject("Interface", interfaceType, unsupportedSeverity);

            if (heliosInterface != null)
            {
                string name = xmlReader.GetAttribute("Name");
                if (xmlReader.IsEmptyElement)
                {
                    // don't read from empty XML element
                    xmlReader.Read();
                }
                else
                {
                    xmlReader.ReadStartElement("Interface");
                    heliosInterface.ReadXml(xmlReader);
                    xmlReader.ReadEndElement();
                }
                heliosInterface.Name = name;
                heliosInterface.UnsupportedSeverity = unsupportedSeverity;
                destination.Add(heliosInterface);
                yield return($"loaded {heliosInterface.TypeIdentifier} {heliosInterface.Name}");
            }
            else
            {
                xmlReader.Skip();
                yield return("failed to load interface");
            }
        }
Esempio n. 3
0
        private object DispCreateNewObject(string type, string typeId)
        {
            switch (type)
            {
            case "Monitor":
                return(new Monitor());

            case "Visual":
                HeliosVisual visual = ConfigManager.ModuleManager.CreateControl(typeId);
                visual.Dispatcher = _dispatcher;
                return(visual);

            case "Interface":
                HeliosInterfaceDescriptor descriptor      = ConfigManager.ModuleManager.InterfaceDescriptors[typeId];
                HeliosInterface           heliosInterface = descriptor != null?descriptor.CreateInstance() : null;

                if (heliosInterface != null)
                {
                    heliosInterface.Dispatcher = _dispatcher;
                }
                return(heliosInterface);

            case "Binding":
                return(new HeliosBinding());
            }
            return(null);
        }
Esempio n. 4
0
        public HeliosInterface DeserializeInterface(XmlReader xmlReader)
        {
            string          interfaceType   = xmlReader.GetAttribute("TypeIdentifier");
            HeliosInterface heliosInterface = (HeliosInterface)CreateNewObject("Interface", interfaceType);

            if (heliosInterface != null)
            {
                String name = xmlReader.GetAttribute("Name");
                if (xmlReader.IsEmptyElement)
                {
                    xmlReader.Read();
                }
                else
                {
                    xmlReader.ReadStartElement("Interface");
                    heliosInterface.ReadXml(xmlReader);
                    xmlReader.ReadEndElement();
                }
                heliosInterface.Name = name;
            }
            else
            {
                xmlReader.Skip();
            }

            return(heliosInterface);
        }
Esempio n. 5
0
        public static string GetReferenceName(HeliosObject refObject)
        {
            StringBuilder sb = new StringBuilder("");

            HeliosInterface refInterface = refObject as HeliosInterface;

            if (refInterface != null)
            {
                sb.Append("Interface;;");
            }

            HeliosVisual refControl = refObject as HeliosVisual;

            if (refControl != null)
            {
                sb.Append("Visual;");
                sb.Append(GetVisualPath(refControl));
                sb.Append(";");
            }

            sb.Append(refObject.TypeIdentifier);
            sb.Append(";");
            sb.Append(refObject.Name);
            sb.Append("");

            return(sb.ToString());
        }
 public AV8BCompositeVisual(string name, Size nativeSize)
     : base(name, nativeSize)
 {
     _defaultInterfaceName = "";
     _defaultBindingName   = "";
     _defaultInterface     = null;
 }
Esempio n. 7
0
 public void SerializeInterface(HeliosInterface heliosInterface, XmlWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("Interface");
     xmlWriter.WriteAttributeString("TypeIdentifier", heliosInterface.TypeIdentifier);
     xmlWriter.WriteAttributeString("Name", heliosInterface.Name);
     heliosInterface.WriteXml(xmlWriter);
     xmlWriter.WriteEndElement(); // Interface
 }
Esempio n. 8
0
 protected CompositeVisual(string name, Size nativeSize)
     : base(name, nativeSize)
 {
     PersistChildren             = false;
     Children.CollectionChanged += Children_CollectionChanged;
     _defaultBindingName         = "";
     _defaultInterface           = null;
     _defaultInputBindings       = new List <DefaultInputBinding>();
     _defaultOutputBindings      = new List <DefaultOutputBinding>();
 }
Esempio n. 9
0
 public void SerializeInterface(HeliosInterface heliosInterface, XmlWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("Interface");
     xmlWriter.WriteAttributeString("TypeIdentifier", heliosInterface.TypeIdentifier);
     xmlWriter.WriteAttributeString("Name", heliosInterface.Name);
     if (heliosInterface.UnsupportedSeverity != default)
     {
         xmlWriter.WriteAttributeString("UnsupportedSeverity", heliosInterface.UnsupportedSeverity.ToString());
     }
     heliosInterface.WriteXml(xmlWriter);
     xmlWriter.WriteEndElement(); // Interface
 }
Esempio n. 10
0
 public HeliosInterfaceEditor CreateInterfaceEditor(HeliosInterface item, HeliosProfile profile)
 {
     HeliosInterfaceEditor editor = null;
     if (item != null)
     {
         HeliosInterfaceDescriptor descriptor = _interfaceDescriptors[item.GetType()];
         if (descriptor != null && descriptor.InterfaceEditorType != null)
         {
             editor = (HeliosInterfaceEditor)Activator.CreateInstance(descriptor.InterfaceEditorType);
             editor.Interface = item;
             editor.Profile = profile;
         }
     }
     return editor;
 }
Esempio n. 11
0
        public HeliosInterfaceEditor CreateInterfaceEditor(HeliosInterface item, HeliosProfile profile)
        {
            HeliosInterfaceEditor editor = null;

            if (item != null)
            {
                HeliosInterfaceDescriptor descriptor = _interfaceDescriptors[item.GetType()];
                if (descriptor != null && descriptor.InterfaceEditorType != null)
                {
                    editor           = (HeliosInterfaceEditor)Activator.CreateInstance(descriptor.InterfaceEditorType);
                    editor.Interface = item;
                    editor.Profile   = profile;
                }
            }
            return(editor);
        }
Esempio n. 12
0
 public void DeserializeInterfaces(HeliosInterfaceCollection destination, XmlReader xmlReader)
 {
     if (!xmlReader.IsEmptyElement)
     {
         xmlReader.ReadStartElement("Interfaces");
         while (xmlReader.NodeType != XmlNodeType.EndElement)
         {
             HeliosInterface heliosInterface = DeserializeInterface(xmlReader);
             if (heliosInterface != null)
             {
                 destination.Add(heliosInterface);
             }
         }
         xmlReader.ReadEndElement();
     }
     else
     {
         xmlReader.Read();
     }
 }
Esempio n. 13
0
        private object DispCreateNewObject(string type, string typeId)
        {
            switch (type)
            {
            case "Monitor":
                return(new Monitor());

            case "Visual":
                HeliosVisual visual = ConfigManager.ModuleManager.CreateControl(typeId);
                if (visual == null)
                {
                    ConfigManager.LogManager.LogError("Ignoring control not supported by this version of Helios: " + typeId);
                    return(null);
                }
                visual.Dispatcher = _dispatcher;
                return(visual);

            case "Interface":
                HeliosInterfaceDescriptor descriptor = ConfigManager.ModuleManager.InterfaceDescriptors[typeId];
                if (descriptor == null)
                {
                    ConfigManager.LogManager.LogError("Ignoring interface not supported by this version of Helios: " + typeId);
                    return(null);
                }
                HeliosInterface heliosInterface = descriptor != null?descriptor.CreateInstance() : null;

                if (heliosInterface != null)
                {
                    heliosInterface.Dispatcher = _dispatcher;
                }
                return(heliosInterface);

            case "Binding":
                return(new HeliosBinding());
            }
            return(null);
        }
Esempio n. 14
0
        protected override void OnProfileChanged(HeliosProfile oldProfile)
        {
            base.OnProfileChanged(oldProfile);
            if (!DesignMode)
            {
                return;
            }

            /// grab the default interface, if it exists
            if (_defaultInterfaceName == "")
            {
                return;
            }
            if (!Profile.Interfaces.ContainsKey(_defaultInterfaceName))
            {
                ConfigManager.LogManager.LogError("Cannot find default interface " + _defaultInterfaceName);
                return;
            }
            _defaultInterface = Profile.Interfaces[_defaultInterfaceName];

            /// looping for all default input bindings to assign the value
            foreach (DefaultInputBinding defaultBinding in _defaultInputBindings)
            {
                if (!Children.ContainsKey(defaultBinding.ChildName))
                {
                    ConfigManager.LogManager.LogError("Cannot find child " + defaultBinding.ChildName);
                    continue;
                }
                ConfigManager.LogManager.LogDebug("Auto binding child " + defaultBinding.ChildName);
                HeliosVisual child = Children[defaultBinding.ChildName];
                if (!child.Actions.ContainsKey(defaultBinding.DeviceActionName))
                {
                    ConfigManager.LogManager.LogError("Cannot find action " + defaultBinding.DeviceActionName);
                    continue;
                }
                if (!_defaultInterface.Triggers.ContainsKey(defaultBinding.InterfaceTriggerName))
                {
                    ConfigManager.LogManager.LogError("Cannot find interface trigger " + defaultBinding.InterfaceTriggerName);
                    continue;
                }
                ConfigManager.LogManager.LogDebug("Auto binding trigger " + defaultBinding.InterfaceTriggerName + " to " + defaultBinding.DeviceActionName);
                child.OutputBindings.Add(CreateNewBinding(_defaultInterface.Triggers[defaultBinding.InterfaceTriggerName],
                                                          child.Actions[defaultBinding.DeviceActionName]));

                //child.OutputBindings.Add(
                //    new HeliosBinding(_defaultInterface.Triggers[defaultBinding.InterfaceTriggerName],
                //        child.Actions[defaultBinding.DeviceActionName]));
            }

            /// now looping for all default output bindings to assign the value
            foreach (DefaultOutputBinding defaultBinding in _defaultOutputBindings)
            {
                if (!Children.ContainsKey(defaultBinding.ChildName))
                {
                    ConfigManager.LogManager.LogError("Cannot find child " + defaultBinding.ChildName);
                    continue;
                }
                HeliosVisual child = Children[defaultBinding.ChildName];
                if (!child.Triggers.ContainsKey(defaultBinding.DeviceTriggerName))
                {
                    ConfigManager.LogManager.LogError("Cannot find trigger " + defaultBinding.DeviceTriggerName);
                    continue;
                }
                if (!_defaultInterface.Actions.ContainsKey(defaultBinding.InterfaceActionName))
                {
                    ConfigManager.LogManager.LogError("Cannot find action " + defaultBinding.InterfaceActionName);
                    continue;
                }
                ConfigManager.LogManager.LogDebug("Child Output binding trigger " + defaultBinding.DeviceTriggerName + " to " + defaultBinding.InterfaceActionName);
                child.OutputBindings.Add(CreateNewBinding(child.Triggers[defaultBinding.DeviceTriggerName],
                                                          _defaultInterface.Actions[defaultBinding.InterfaceActionName]));
                //            child.OutputBindings.Add(
                //new HeliosBinding(child.Triggers[defaultBinding.DeviceTriggerName],
                //                  _defaultInterface.Actions[defaultBinding.InterfaceActionName]));
            }
        }
Esempio n. 15
0
 public void SerializeInterface(HeliosInterface heliosInterface, XmlWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("Interface");
     xmlWriter.WriteAttributeString("TypeIdentifier", heliosInterface.TypeIdentifier);
     xmlWriter.WriteAttributeString("Name", heliosInterface.Name);
     heliosInterface.WriteXml(xmlWriter);
     xmlWriter.WriteEndElement(); // Interface
 }
Esempio n. 16
0
        protected override void OnProfileChanged(HeliosProfile oldProfile)
        {
            base.OnProfileChanged(oldProfile);
            if (!DesignMode)
            {
                return;
            }

            // grab the default interface, if it exists
            foreach (Type supportedInterface in SupportedInterfaces)
            {
                _defaultInterface = Profile.Interfaces.FirstOrDefault(i => supportedInterface.IsInstanceOfType(i));
                if (_defaultInterface != null)
                {
                    Logger.Info($"{Name} auto binding to interface '{_defaultInterface.Name}'");
                    break;
                }
            }

            if (_defaultInterface == null)
            {
                Logger.Info($"{Name} could not locate any supported interface for auto binding");
                return;
            }

            // looping for all default input bindings to assign the value
            foreach (DefaultInputBinding defaultBinding in _defaultInputBindings)
            {
                if (!Children.ContainsKey(defaultBinding.ChildName))
                {
                    Logger.Error("Cannot find child " + defaultBinding.ChildName);
                    continue;
                }
                Logger.Debug("Auto binding child " + defaultBinding.ChildName);
                HeliosVisual child = Children[defaultBinding.ChildName];
                if (!child.Actions.ContainsKey(defaultBinding.DeviceActionName))
                {
                    Logger.Error("Cannot find action " + defaultBinding.DeviceActionName);
                    continue;
                }
                if (defaultBinding.InterfaceTriggerName != "")
                {
                    if (!_defaultInterface.Triggers.ContainsKey(defaultBinding.InterfaceTriggerName))
                    {
                        Logger.Error("Cannot find interface trigger " + defaultBinding.InterfaceTriggerName);
                        continue;
                    }

                    Logger.Debug("Auto binding trigger " + defaultBinding.InterfaceTriggerName + " to " + defaultBinding.ChildName + defaultBinding.DeviceActionName);
                    child.OutputBindings.Add(CreateNewBinding(_defaultInterface.Triggers[defaultBinding.InterfaceTriggerName],
                                                              child.Actions[defaultBinding.DeviceActionName]));
                }
                else
                {
                    if (!Triggers.ContainsKey(defaultBinding.DeviceTriggerName))
                    {
                        Logger.Error("Cannot find interface trigger " + defaultBinding.DeviceTriggerName);
                        continue;
                    }

                    Logger.Debug("Auto binding trigger " + defaultBinding.DeviceTriggerName + " to " + defaultBinding.ChildName + defaultBinding.DeviceActionName);
                    child.OutputBindings.Add(CreateNewBinding(Triggers[defaultBinding.DeviceTriggerName],
                                                              child.Actions[defaultBinding.DeviceActionName], defaultBinding.DeviceTriggerBindingValue));
                }

                //child.OutputBindings.Add(
                //    new HeliosBinding(_defaultInterface.Triggers[defaultBinding.InterfaceTriggerName],
                //        child.Actions[defaultBinding.DeviceActionName]));
            }

            // now looping for all default output bindings to assign the value
            foreach (DefaultOutputBinding defaultBinding in _defaultOutputBindings)
            {
                if (!Children.ContainsKey(defaultBinding.ChildName))
                {
                    Logger.Error("Cannot find child " + defaultBinding.ChildName);
                    continue;
                }
                HeliosVisual child = Children[defaultBinding.ChildName];
                if (!child.Triggers.ContainsKey(defaultBinding.DeviceTriggerName))
                {
                    Logger.Error("Cannot find trigger " + defaultBinding.DeviceTriggerName);
                    continue;
                }
                if (!_defaultInterface.Actions.ContainsKey(defaultBinding.InterfaceActionName))
                {
                    Logger.Error("Cannot find action " + defaultBinding.InterfaceActionName);
                    continue;
                }
                Logger.Debug("Child Output binding trigger " + defaultBinding.DeviceTriggerName + " to " + defaultBinding.InterfaceActionName);
                child.OutputBindings.Add(CreateNewBinding(child.Triggers[defaultBinding.DeviceTriggerName],
                                                          _defaultInterface.Actions[defaultBinding.InterfaceActionName]));

                //            child.OutputBindings.Add(
                //new HeliosBinding(child.Triggers[defaultBinding.DeviceTriggerName],
                //                  _defaultInterface.Actions[defaultBinding.InterfaceActionName]));
            }
        }