public CreateTemplateCode CreateNodeTemplate(Guid uid, string name, string description, string key, Guid needsInterface, Guid providesInterface,
                                                     bool defaultCreated, bool isReadable, bool isReadableFixed, bool isWriteable, bool isWriteableFixed, Base.Templates.NodeDataType dataType,
                                                     int maxInstances, bool isAdapterInterface, bool deleteAble)
        {
            var nodeTemplate = new NodeTemplate
            {
                ObjId       = uid,
                Name        = name,
                Description = description,
                Key         = key,
                This2DefaultMobileVisuTemplate =
                    VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Label),
                NeedsInterface2InterfacesType   = needsInterface,
                ProvidesInterface2InterfaceType = providesInterface,
                DefaultCreated     = defaultCreated,
                IsReadable         = isReadable,
                IsReadableFixed    = isReadableFixed,
                IsWriteable        = isWriteable,
                IsWriteableFixed   = isWriteableFixed,
                This2NodeDataType  = (long)dataType,
                MaxInstances       = maxInstances,
                IsAdapterInterface = isAdapterInterface,
                IsDeleteable       = deleteAble
            };



            _nodeTemplates.Add(uid, nodeTemplate);
            return(CreateTemplateCode.Created);
        }
Exemple #2
0
        private void AddPushButton(VisuMobileTemplateFactory factory)
        {
            var pushButton = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.PushButton);

            factory.CreateVisuMobileTemplate(pushButton, "VISU.OBJECT.PUSH_BUTTON.NAME", "VISU.OBJECT.PUSH_BUTTON.DESCRIPTION", "push-button",
                                             "VISU.CATEGORY.COMMON.NAME", 1, 1, true);

            factory.CreatePropertyTemplate(new Guid("a4339ad8-09bc-46e7-a395-0e1e79bbeab7"), "VISU.APPEARANCE.NODE_VALUE.NAME", "VISU.APPEARANCE.NODE_VALUE.DESCRIPTION", "nodeInstance",
                                           PropertyTemplateType.NodeInstance, pushButton, "VISU.CATEGORY.VALUE.NAME", true, false, null, null, 1, 1);

            factory.CreatePropertyTemplate(new Guid("90461b81-8c04-409f-928a-37bb7eb4e1ea"), "VISU.APPEARANCE.SEND_VALUE.NAME", "VISU.APPEARANCE.SEND_VALUE.DESCRIPTION", "send_value",
                                           PropertyTemplateType.Text, pushButton, "VISU.CATEGORY.VALUE.NAME", true, false, "", true, 1, 2);

            factory.CreatePropertyTemplate(new Guid("e2509320-c72f-410b-bda0-6bd9459cb50f"), "VISU.APPEARANCE.READONLY.NAME", "VISU.APPEARANCE.READONLY.DESCRIPTION", "readonly",
                                           PropertyTemplateType.Bool, pushButton, "VISU.CATEGORY.APPEARANCE.NAME", true, false, "", false, 1, 1);

            factory.CreatePropertyTemplate(new Guid("9c1f9103-f580-47ba-ad30-b21f0a93ac5a"), "VISU.APPEARANCE.TOGGLE.ON.NAME", "VISU.APPEARANCE.TOGGLE.ON.DESCRIPTION", "toggle_on_text",
                                           PropertyTemplateType.Text, pushButton, "VISU.CATEGORY.APPEARANCE.NAME", true, false, "", "On", 1, 2);

            factory.CreatePropertyTemplate(new Guid("1dba9926-dba7-4cd1-a7c3-5cf9b9197bf0"), "VISU.APPEARANCE.TOGGLE.OFF.NAME", "VISU.APPEARANCE.TOGGLE.OFF.DESCRIPTION", "toggle_off_text",
                                           PropertyTemplateType.Text, pushButton, "VISU.CATEGORY.APPEARANCE.NAME", true, false, "", "Off", 1, 3);

            factory.CreatePropertyTemplate(new Guid("2c05f69d-dff1-4110-9a4f-7b6aa886c00d"), "VISU.APPEARANCE.BEHAVIOUR.NAME", "VISU.APPEARANCE.BEHAVIOUR.DESCRIPTION", "behaviour",
                                           PropertyTemplateType.Enum, pushButton, "VISU.CATEGORY.APPEARANCE.NAME", true, false, PropertyHelper.CreateEnumMetaString(typeof(PushButtonBehaviour)), PushButtonBehaviour.SendTrue, 1, 4);



            AddCommonProperty(pushButton, factory);
            AddTextProperty(pushButton, factory);
        }
Exemple #3
0
        private void AddWindowMonitor(VisuMobileTemplateFactory factory)
        {
            var monitor = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.WindowMonitor);

            factory.CreateVisuMobileTemplate(monitor, "VISU.OBJECT.WINDOW_MONITOR.NAME", "VISU.OBJECT.WINDOW_MONITOR.DESCRIPTION", "window-monitor",
                                             "VISU.CATEGORY.PRIVATE.NAME", 1, 1, false);
        }
Exemple #4
0
        private void AddNumberBox(VisuMobileTemplateFactory factory)
        {
            var numberBox = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.NumberBox);

            factory.CreateVisuMobileTemplate(numberBox, "VISU.OBJECT.NUMBER_BOX.NAME", "VISU.OBJECT.NUMBER_BOX.DESCRIPTION", "number-box",
                                             "VISU.CATEGORY.COMMON.NAME", 1, 1, true);

            factory.CreatePropertyTemplate(new Guid("a38973e4-0a2f-4849-9919-505142a49400"), "VISU.APPEARANCE.NODE_VALUE.NAME", "VISU.APPEARANCE.NODE_VALUE.DESCRIPTION", "nodeInstance",
                                           PropertyTemplateType.NodeInstance, numberBox, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, null, 1, 1);

            factory.CreatePropertyTemplate(new Guid("137b65c1-31aa-4a10-a9d0-8bdbc621eb7f"), "VISU.APPEARANCE.READONLY.NAME", "VISU.APPEARANCE.READONLY.DESCRIPTION", "readonly",
                                           PropertyTemplateType.Bool, numberBox, "VISU.CATEGORY.APPEARANCE.NAME", true, false, "", false, 1, 2);

            factory.CreatePropertyTemplate(new Guid("da8681a7-d7dc-4553-8a01-4db66b30af3f"), "VISU.APPEARANCE.MIN.NAME", "VISU.APPEARANCE.MIN.DESCRIPTION", "min",
                                           PropertyTemplateType.Integer, numberBox, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, 0, 1, 3);

            factory.CreatePropertyTemplate(new Guid("f70f0342-6ec6-4b99-b39f-197553f17bf9"), "VISU.APPEARANCE.MAX.NAME", "VISU.APPEARANCE.MAX.DESCRIPTION", "max",
                                           PropertyTemplateType.Integer, numberBox, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, 10, 1, 4);

            factory.CreatePropertyTemplate(new Guid("e4d43570-8794-466e-b318-7a4abe17af9c"), "VISU.APPEARANCE.STEP.NAME", "VISU.APPEARANCE.STEP.DESCRIPTION", "step",
                                           PropertyTemplateType.Numeric, numberBox, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, 1, 1, 5);

            AddCommonProperty(numberBox, factory);
            AddTextProperty(numberBox, factory);
        }
Exemple #5
0
        private void AddToggleButton(VisuMobileTemplateFactory factory)
        {
            var toggleButton = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.ToggleButton);

            factory.CreateVisuMobileTemplate(toggleButton, "VISU.OBJECT.TOGGLE_BUTTON.NAME", "VISU.OBJECT.TOGGLE_BUTTON.DESCRIPTION", "toggle-button",
                                             "VISU.CATEGORY.COMMON.NAME", 1, 1, true);

            factory.CreatePropertyTemplate(new Guid("8238bcc7-4396-464a-ae8b-d615582fb97b"), "VISU.APPEARANCE.NODE_VALUE.NAME", "VISU.APPEARANCE.NODE_VALUE.DESCRIPTION", "nodeInstance",
                                           PropertyTemplateType.NodeInstance, toggleButton, "VISU.CATEGORY.VALUE.NAME", true, false, null, null, 1, 1);

            factory.CreatePropertyTemplate(new Guid("85d1ccd7-36e6-4129-b34b-f0e9100ac1ee"), "VISU.APPEARANCE.NODE_STATE_VALUE.NAME", "VISU.APPEARANCE.NODE_STATE_VALUE.DESCRIPTION", "nodeInstanceState",
                                           PropertyTemplateType.NodeInstance, toggleButton, "VISU.CATEGORY.VALUE.NAME", true, false, null, null, 1, 2);

            factory.CreatePropertyTemplate(new Guid("3eef3ccb-34f9-4e2c-b804-0236ee32d184"), "VISU.APPEARANCE.READONLY.NAME", "VISU.APPEARANCE.READONLY.DESCRIPTION", "readonly",
                                           PropertyTemplateType.Bool, toggleButton, "VISU.CATEGORY.APPEARANCE.NAME", true, false, "", false, 2, 1);

            factory.CreatePropertyTemplate(new Guid("f487195e-a447-42ca-919d-6fd36e27eddc"), "VISU.APPEARANCE.TOGGLE.ON.NAME", "VISU.APPEARANCE.TOGGLE.ON.DESCRIPTION", "toggle_on_text",
                                           PropertyTemplateType.Text, toggleButton, "VISU.CATEGORY.APPEARANCE.NAME", true, false, "", "On", 2, 2);

            factory.CreatePropertyTemplate(new Guid("336fb367-593e-4165-a3dd-283182e28f18"), "VISU.APPEARANCE.TOGGLE.OFF.NAME", "VISU.APPEARANCE.TOGGLE.OFF.DESCRIPTION", "toggle_off_text",
                                           PropertyTemplateType.Text, toggleButton, "VISU.CATEGORY.APPEARANCE.NAME", true, false, "", "Off", 2, 3);

            AddCommonProperty(toggleButton, factory);
            AddTextProperty(toggleButton, factory);
        }
Exemple #6
0
        private void AddClockControl(VisuMobileTemplateFactory factory)
        {
            var clock = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Clock);

            factory.CreateVisuMobileTemplate(clock, "VISU.OBJECT.CLOCK.NAME", "VISU.OBJECT.CLOCK.DESCRIPTION", "clock",
                                             "VISU.CATEGORY.COMMON.NAME", 1, 1, true);

            factory.UpdateMaxMinValues(clock, 1, 1, 1, 1);
            AddCommonProperty(clock, factory);
        }
Exemple #7
0
        public void Initialize(AutomaticaContext database, IConfiguration config)
        {
            var factory = new VisuMobileTemplateFactory(database, config);

            var label = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Label);

            factory.CreateVisuMobileTemplate(label, "VISU.OBJECT.LABEL.NAME", "VISU.OBJECT.LABEL.DESCRIPTION", "label", "VISU.CATEGORY.COMMON.NAME", 1, 1, true);

            AddCommonProperty(label, factory);
            AddTextProperty(label, factory);

            factory.CreatePropertyTemplate(new Guid("d7d8dd9d-3c45-44b6-9bbd-d7d00825ebdb"), "VISU.APPEARANCE.NODE_VALUE.NAME", "VISU.APPEARANCE.NODE_VALUE.DESCRIPTION", "nodeInstance",
                                           PropertyTemplateType.NodeInstance, label, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, null, 1, 2);

            var link = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Link);

            factory.CreateVisuMobileTemplate(link, "VISU.OBJECT.LINK.NAME", "VISU.OBJECT.LINK.DESCRIPTION", "link",
                                             "VISU.CATEGORY.COMMON.NAME", 1, 1, true);
            factory.CreatePropertyTemplate(new Guid("bea56e63-47e9-4050-9333-e54de0cdcfb6"), "VISU.APPEARANCE.LINK.NAME", "VISU.APPEARANCE.LINK.DESCRIPTION", "link",
                                           PropertyTemplateType.VisuMobilePage, link, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, null, 1, 2);

            factory.CreatePropertyTemplate(new Guid("fb20bc35-3b9a-4b70-8483-ba79c5cd8cf0"), "VISU.APPEARANCE.AREA_LINK.NAME", "VISU.APPEARANCE.AREA_LINK.DESCRIPTION", "area_link",
                                           PropertyTemplateType.AreaInstanceLink, link, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, null, 1, 2);

            AddTextProperty(link, factory);
            AddCommonProperty(link, factory);

            var slider = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Slider);

            factory.CreateVisuMobileTemplate(slider, "VISU.OBJECT.SLIDER.NAME", "VISU.OBJECT.SLIDER.DESCRIPTION", "slider",
                                             "VISU.CATEGORY.COMMON.NAME", 1, 1, true);

            AddCommonProperty(slider, factory);
            AddTextProperty(slider, factory);

            factory.CreatePropertyTemplate(new Guid("ac6a8a89-6361-48c1-b1d9-82439eeff7ea"), "VISU.APPEARANCE.MIN.NAME", "VISU.APPEARANCE.MIN.DESCRIPTION", "min",
                                           PropertyTemplateType.Integer, slider, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, 0, 1, 2);

            factory.CreatePropertyTemplate(new Guid("55c3b706-62c4-4e9e-b066-798c893a8e9f"), "VISU.APPEARANCE.MAX.NAME", "VISU.APPEARANCE.MAX.DESCRIPTION", "max",
                                           PropertyTemplateType.Integer, slider, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, 100, 1, 2);

            factory.CreatePropertyTemplate(new Guid("e51cbe53-6301-4b11-a523-864f453b7b24"), "VISU.APPEARANCE.NODE_VALUE.NAME", "VISU.APPEARANCE.NODE_VALUE.DESCRIPTION", "nodeInstance",
                                           PropertyTemplateType.NodeInstance, slider, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, null, 1, 2);

            factory.CreatePropertyTemplate(new Guid("1b6b41c9-2494-42d4-893e-63d0d9fec2e7"), "VISU.APPEARANCE.READONLY.NAME", "VISU.APPEARANCE.READONLY.DESCRIPTION", "readonly",
                                           PropertyTemplateType.Bool, slider, "VISU.CATEGORY.APPEARANCE.NAME", true, false, "false", 100, 1, 2);

            AddToggleButton(factory);
            AddNumberBox(factory);


            AddWindowMonitor(factory);
            AddRgbControl(factory);
        }
Exemple #8
0
        public CreateTemplateCode CreateNodeTemplate(Guid uid, string name, string description, string key,
                                                     Guid needsInterface,
                                                     Guid providesInterface, bool defaultCreated, bool isReadable, bool isReadableFixed, bool isWriteable,
                                                     bool isWriteableFixed, Base.Templates.NodeDataType dataType, int maxInstances, bool isAdapterInterface, bool deleteAble)
        {
            try
            {
                var nodeTemplate = Db.NodeTemplates.SingleOrDefault(p => p.ObjId == uid);
                var retValue     = CreateTemplateCode.Updated;

                bool isNewObject = false;
                if (nodeTemplate == null)
                {
                    isNewObject        = true;
                    nodeTemplate       = new NodeTemplate();
                    nodeTemplate.ObjId = uid;
                    retValue           = CreateTemplateCode.Created;
                }

                nodeTemplate.Name        = name;
                nodeTemplate.Description = description;
                nodeTemplate.Key         = key;
                nodeTemplate.This2DefaultMobileVisuTemplate  = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Label);
                nodeTemplate.NeedsInterface2InterfacesType   = needsInterface;
                nodeTemplate.ProvidesInterface2InterfaceType = providesInterface;
                nodeTemplate.DefaultCreated     = defaultCreated;
                nodeTemplate.IsReadable         = isReadable;
                nodeTemplate.IsReadableFixed    = isReadableFixed;
                nodeTemplate.IsWriteable        = isWriteable;
                nodeTemplate.IsWriteableFixed   = isWriteableFixed;
                nodeTemplate.This2NodeDataType  = (long)dataType;
                nodeTemplate.MaxInstances       = maxInstances;
                nodeTemplate.IsAdapterInterface = isAdapterInterface;
                nodeTemplate.IsDeleteable       = deleteAble;

                if (isNewObject)
                {
                    Db.NodeTemplates.Add(nodeTemplate);
                }
                else
                {
                    Db.NodeTemplates.Update(nodeTemplate);
                }

                return(retValue);
            }
            catch (Exception e)
            {
                SystemLogger.Instance.LogError($"Could not create node template {uid}-{name}.{key} {e}");

                throw;
            }
        }
Exemple #9
0
        private void AddChartControl(VisuMobileTemplateFactory factory)
        {
            var chart = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Chart);

            factory.CreateVisuMobileTemplate(chart, "VISU.OBJECT.CHART.NAME", "VISU.OBJECT.CHART.DESCRIPTION", "chart",
                                             "VISU.CATEGORY.COMMON.NAME", 1, 1, true);

            factory.CreatePropertyTemplate(new Guid("6c3f4a8c-4fe1-48cc-af1a-1b5a23d0bdb3"), "VISU.APPEARANCE.NODE_VALUE.NAME", "VISU.APPEARANCE.NODE_VALUE.DESCRIPTION", "nodeInstance",
                                           PropertyTemplateType.NodeInstance, chart, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, null, 1, 1);


            AddCommonProperty(chart, factory);
            AddTextProperty(chart, factory);
        }
Exemple #10
0
        private void AddRgbControl(VisuMobileTemplateFactory factory)
        {
            var rgba = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Rgba);

            factory.CreateVisuMobileTemplate(rgba, "VISU.OBJECT.RGBA.NAME", "VISU.OBJECT.RGBA.DESCRIPTION", "rgba",
                                             "VISU.CATEGORY.COMMON.NAME", 1, 1, true);

            factory.CreatePropertyTemplate(new Guid("6c3f4a8c-4fe1-48cc-af1a-1b5a23d0bdb3"), "VISU.APPEARANCE.NODE_VALUE.NAME", "VISU.APPEARANCE.NODE_VALUE.DESCRIPTION", "nodeInstance",
                                           PropertyTemplateType.NodeInstance, rgba, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, null, 1, 1);

            factory.CreatePropertyTemplate(new Guid("3eef3ccb-34f9-4e2c-b804-0236ee32d184"), "VISU.APPEARANCE.READONLY.NAME", "VISU.APPEARANCE.READONLY.DESCRIPTION", "readonly",
                                           PropertyTemplateType.Bool, rgba, "VISU.CATEGORY.APPEARANCE.NAME", true, false, "", false, 1, 2);

            AddCommonProperty(rgba, factory);
            AddTextProperty(rgba, factory);
        }
Exemple #11
0
        public CreateTemplateCode ChangeDefaultVisuTemplate(Guid uid, VisuMobileObjectTemplateTypes template)
        {
            var nodeTemplate = Db.NodeTemplates.SingleOrDefault(p => p.ObjId == uid);

            if (nodeTemplate == null)
            {
                Db.SaveChanges();
                nodeTemplate = Db.NodeTemplates.SingleOrDefault(p => p.ObjId == uid);

                if (nodeTemplate == null)
                {
                    return(CreateTemplateCode.Error);
                }
            }

            nodeTemplate.This2DefaultMobileVisuTemplate = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(template);

            return(CreateTemplateCode.Updated);
        }
Exemple #12
0
        private void AddGaugeControl(VisuMobileTemplateFactory factory)
        {
            var chart = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Gauge);

            factory.CreateVisuMobileTemplate(chart, "VISU.OBJECT.GAUGE.NAME", "VISU.OBJECT.GAUGE.DESCRIPTION", "gauge",
                                             "VISU.CATEGORY.COMMON.NAME", 1, 1, true);

            factory.CreatePropertyTemplate(new Guid("85e6e721-d45b-479c-ab44-6672d2f772dc"), "VISU.APPEARANCE.NODE_VALUE.NAME", "VISU.APPEARANCE.NODE_VALUE.DESCRIPTION", "nodeInstance",
                                           PropertyTemplateType.NodeInstance, chart, "VISU.CATEGORY.APPEARANCE.NAME", true, false, null, null, 1, 1);

            factory.CreatePropertyTemplate(new Guid("258fad47-e750-4e3e-9620-9d1afabfef1a"), "VISU.APPEARANCE.GAUGE_TYPE.NAME",
                                           "VISU.APPEARANCE.GAUGE_TYPE.DESCRIPTION", "gauge_type", PropertyTemplateType.Enum, chart,
                                           "VISU.CATEGORY.APPEARANCE.NAME", true, false, PropertyHelper.CreateEnumMetaString(typeof(GaugeType)),
                                           (int)GaugeType.Circular, 0, 0);


            factory.CreatePropertyTemplate(new Guid("da0c1047-bfd0-4095-b0ac-781a3808e162"), "VISU.APPEARANCE.SCALE_START.NAME",
                                           "VISU.APPEARANCE.SCALE_START.DESCRIPTION", "scale_start", PropertyTemplateType.Integer, chart,
                                           "VISU.CATEGORY.APPEARANCE.NAME", true, false, null,
                                           0, 0, 10);

            factory.CreatePropertyTemplate(new Guid("d1d5ce5f-94e2-48c1-a065-89557f12dca4"), "VISU.APPEARANCE.SCALE_END.NAME",
                                           "VISU.APPEARANCE.SCALE_END.DESCRIPTION", "scale_end", PropertyTemplateType.Integer, chart,
                                           "VISU.CATEGORY.APPEARANCE.NAME", true, false, null,
                                           100, 0, 11);

            factory.CreatePropertyTemplate(new Guid("81bbbbc1-2b14-4e44-9f6d-ee7ebacc6dcf"), "VISU.APPEARANCE.TICKS.NAME",
                                           "VISU.APPEARANCE.TICKS.DESCRIPTION", "ticks", PropertyTemplateType.Numeric, chart,
                                           "VISU.CATEGORY.APPEARANCE.NAME", true, false, null,
                                           1, 0, 12);



            AddCommonProperty(chart, factory);
            AddTextProperty(chart, factory);
        }
Exemple #13
0
        private static void AddBoard(AutomaticaContext context, IDatabaseBoardType boardType)
        {
            var board             = context.BoardTypes.SingleOrDefault(a => a.Type == GuidTemplateTypeAttribute.GetFromEnum(boardType.BoardType));
            var boardNodeTemplate = context.NodeTemplates.SingleOrDefault(a => a.ObjId == board.Type);

            var boardInterfaceType = context.InterfaceTypes.SingleOrDefault(a => a.Type == board.Type);

            if (boardInterfaceType == null)
            {
                boardInterfaceType = new InterfaceType
                {
                    Type                = board.Type,
                    Name                = board.Name,
                    Description         = board.Description,
                    IsDriverInterface   = false,
                    MaxChilds           = int.MaxValue,
                    MaxInstances        = 1,
                    CanProvideBoardType = false
                };

                context.InterfaceTypes.Add(boardInterfaceType);
            }

            if (boardNodeTemplate == null)
            {
                boardNodeTemplate = new NodeTemplate
                {
                    ObjId              = board.Type,
                    DefaultCreated     = false,
                    Description        = board.Description,
                    Name               = board.Name,
                    IsAdapterInterface = false,
                    IsDeleteable       = false,
                    IsReadable         = false,
                    IsReadableFixed    = true,
                    IsWriteable        = false,
                    IsWriteableFixed   = true,
                    Key          = board.Name.Replace(" ", ""),
                    MaxInstances = 1,
                    NeedsInterface2InterfacesType   = board.Type,
                    ProvidesInterface2InterfaceType = board.Type,
                    This2NodeDataType = (int)NodeDataType.NoAttribute,
                    This2DefaultMobileVisuTemplate = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Label),
                };

                context.NodeTemplates.Add(boardNodeTemplate);
            }
            context.SaveChanges();


            foreach (var boardInterface in boardType.GetBoardInterfaces())
            {
                var boardInt = context.BoardInterfaces.SingleOrDefault(a => a.ObjId == boardInterface.ObjId);
                if (boardInt == null)
                {
                    context.BoardInterfaces.Add(boardInterface);

                    var nodeTemplate = new NodeTemplate
                    {
                        ObjId              = boardInterface.ObjId,
                        DefaultCreated     = false,
                        Description        = boardInterface.Description,
                        Name               = boardInterface.Name,
                        IsAdapterInterface = false,
                        IsDeleteable       = false,
                        IsReadable         = false,
                        IsReadableFixed    = true,
                        IsWriteable        = false,
                        IsWriteableFixed   = true,
                        Key          = boardInterface.Name.Replace(" ", ""),
                        MaxInstances = 1,
                        NeedsInterface2InterfacesType   = boardNodeTemplate.ObjId,
                        ProvidesInterface2InterfaceType = boardInterface.This2InterfaceType,
                        This2NodeDataType = (int)NodeDataType.NoAttribute,
                        This2DefaultMobileVisuTemplate = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Label),
                    };

                    context.NodeTemplates.Add(nodeTemplate);
                }
            }
        }
Exemple #14
0
        private static void AddSystemTemplates(AutomaticaContext context)
        {
            var usbIr = new NodeTemplate
            {
                ObjId       = new Guid("4d2cf0d47fe947058271787d5626fbe6"),
                Name        = "COMMON.INTERFACES.USB_IR.NAME",
                Description = "COMMON.INTERFACES.USB_IR.DESCRIPTION",
                Key         = "usbir",
                NeedsInterface2InterfacesType   = GuidTemplateTypeAttribute.GetFromEnum(InterfaceTypeEnum.Usb),
                ProvidesInterface2InterfaceType = GuidTemplateTypeAttribute.GetFromEnum(InterfaceTypeEnum.UsbIr),
                This2DefaultMobileVisuTemplate  = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Label),
                IsDeleteable       = true,
                DefaultCreated     = false,
                IsReadable         = false,
                IsReadableFixed    = true,
                IsWriteable        = false,
                IsWriteableFixed   = true,
                MaxInstances       = int.MaxValue,
                This2NodeDataType  = (int)NodeDataType.NoAttribute,
                IsAdapterInterface = true
            };

            if (context.NodeTemplates.SingleOrDefault(a => a.ObjId == usbIr.ObjId) == null)
            {
                context.NodeTemplates.Add(usbIr);
                context.SaveChanges();
            }


            var usbrs485 = new NodeTemplate
            {
                ObjId       = new Guid("acf16ee90377485588341fe1e67d6a93"),
                Name        = "COMMON.INTERFACES.RS485.NAME",
                Description = "COMMON.INTERFACES.RS485.DESCRIPTION",
                Key         = "usbrs485",
                NeedsInterface2InterfacesType   = GuidTemplateTypeAttribute.GetFromEnum(InterfaceTypeEnum.Usb),
                ProvidesInterface2InterfaceType = GuidTemplateTypeAttribute.GetFromEnum(InterfaceTypeEnum.Rs485),
                This2DefaultMobileVisuTemplate  = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Label),
                IsDeleteable       = true,
                DefaultCreated     = false,
                IsReadable         = false,
                IsReadableFixed    = true,
                IsWriteable        = false,
                IsWriteableFixed   = true,
                MaxInstances       = int.MaxValue,
                This2NodeDataType  = (int)NodeDataType.NoAttribute,
                IsAdapterInterface = true
            };

            if (context.NodeTemplates.SingleOrDefault(a => a.ObjId == usbrs485.ObjId) == null)
            {
                context.NodeTemplates.Add(usbrs485);
                context.SaveChanges();
            }

            var usbrs232 = new NodeTemplate
            {
                ObjId       = new Guid("09d3b6b4391847e091aa5a540a7bd67f"),
                Name        = "COMMON.INTERFACES.RS232.NAME",
                Description = "COMMON.INTERFACES.RS232.DESCRIPTION",
                Key         = "usbrs232",
                NeedsInterface2InterfacesType   = GuidTemplateTypeAttribute.GetFromEnum(InterfaceTypeEnum.Usb),
                ProvidesInterface2InterfaceType = GuidTemplateTypeAttribute.GetFromEnum(InterfaceTypeEnum.Rs232), This2DefaultMobileVisuTemplate = VisuMobileObjectTemplateTypeAttribute.GetFromEnum(VisuMobileObjectTemplateTypes.Label),
                IsDeleteable       = true,
                DefaultCreated     = false,
                IsReadable         = false,
                IsReadableFixed    = true,
                IsWriteable        = false,
                IsWriteableFixed   = true,
                MaxInstances       = int.MaxValue,
                This2NodeDataType  = (int)NodeDataType.NoAttribute,
                IsAdapterInterface = true
            };

            if (context.NodeTemplates.SingleOrDefault(a => a.ObjId == usbrs232.ObjId) == null)
            {
                context.NodeTemplates.Add(usbrs232);
                context.SaveChanges();
            }
        }