Exemple #1
0
        /// <summary>
        /// Initializes the device tags.
        /// </summary>
        public override void InitDeviceTags()
        {
            if (opcDeviceConfig == null)
            {
                return;
            }

            foreach (SubscriptionConfig subscriptionConfig in opcDeviceConfig.Subscriptions)
            {
                TagGroup tagGroup = new TagGroup(subscriptionConfig.DisplayName);

                foreach (ItemConfig itemConfig in subscriptionConfig.Items)
                {
                    DeviceTag deviceTag = tagGroup.AddTag(itemConfig.TagCode, itemConfig.DisplayName);
                    deviceTag.Aux  = new DeviceTagMeta();
                    itemConfig.Tag = deviceTag;

                    if (itemConfig.IsString)
                    {
                        deviceTag.DataLen  = DriverUtils.GetTagDataLength(itemConfig.DataLength);
                        deviceTag.DataType = TagDataType.Unicode;
                        deviceTag.Format   = TagFormat.String;
                    }
                    else if (itemConfig.IsArray)
                    {
                        deviceTag.DataLen = itemConfig.DataLength;
                    }
                }

                DeviceTags.AddGroup(tagGroup);
            }
        }
Exemple #2
0
 /// <summary>
 /// Initializes the device tags.
 /// </summary>
 public override void InitDeviceTags()
 {
     foreach (CnlPrototypeGroup group in CnlPrototypeFactory.GetCnlPrototypeGroups())
     {
         DeviceTags.AddGroup(group.ToTagGroup());
     }
 }
Exemple #3
0
        /// <summary>
        /// Initializes the device tags.
        /// </summary>
        public override void InitDeviceTags()
        {
            TagGroup tagGroup = new TagGroup();

            tagGroup.AddTag(TagCode.Mail, TagName.Mail).Format             = TagFormat.IntNumber;
            tagGroup.AddTag(TagCode.MailAttach, TagName.MailAttach).Format = TagFormat.IntNumber;
            DeviceTags.AddGroup(tagGroup);
        }
Exemple #4
0
        /// <summary>
        /// Initializes the device tags.
        /// </summary>
        public override void InitDeviceTags()
        {
            TagGroup tagGroup = new TagGroup("Inputs");

            tagGroup.AddTag("Sin", "Sine");
            tagGroup.AddTag("Sqr", "Square").Format = TagFormat.OffOn;
            tagGroup.AddTag("Tr", "Triangle");
            DeviceTags.AddGroup(tagGroup);

            tagGroup = new TagGroup("Outputs");
            tagGroup.AddTag("DO", "Relay State").Format = TagFormat.OffOn;
            tagGroup.AddTag("AO", "Analog Output");
            DeviceTags.AddGroup(tagGroup);
        }
Exemple #5
0
        /// <summary>
        /// Initializes the device tags.
        /// </summary>
        public override void InitDeviceTags()
        {
            DeviceTemplate deviceTemplate = GetDeviceTemplate();

            if (deviceTemplate == null)
            {
                return;
            }

            // create device model
            deviceModel      = CreateDeviceModel();
            deviceModel.Addr = (byte)NumAddress;

            // add model elements and device tags
            foreach (ElemGroupConfig elemGroupConfig in deviceTemplate.ElemGroups)
            {
                bool      groupActive   = elemGroupConfig.Active;
                bool      groupCommands = groupActive && elemGroupConfig.ReadOnlyEnabled;
                ElemGroup elemGroup     = null;
                TagGroup  tagGroup      = new TagGroup(elemGroupConfig.Name)
                {
                    Hidden = !groupActive
                };
                int elemIndex = 0;

                if (groupActive)
                {
                    elemGroup             = deviceModel.CreateElemGroup(elemGroupConfig.DataBlock);
                    elemGroup.Name        = elemGroupConfig.Name;
                    elemGroup.Address     = (ushort)elemGroupConfig.Address;
                    elemGroup.StartTagIdx = DeviceTags.Count;
                }

                foreach (ElemConfig elemConfig in elemGroupConfig.Elems)
                {
                    // add model element
                    if (groupActive)
                    {
                        Elem elem = elemGroup.CreateElem();
                        elem.Name      = elemConfig.Name;
                        elem.ElemType  = elemConfig.ElemType;
                        elem.ByteOrder = ModbusUtils.ParseByteOrder(elemConfig.ByteOrder) ??
                                         deviceTemplate.Options.GetDefaultByteOrder(ModbusUtils.GetDataLength(elemConfig.ElemType));
                        elemGroup.Elems.Add(elem);
                    }

                    // add model command
                    if (groupCommands && !elemConfig.ReadOnly && !string.IsNullOrEmpty(elemConfig.TagCode))
                    {
                        deviceModel.Cmds.Add(
                            CreateModbusCmd(deviceTemplate.Options, elemGroupConfig, elemConfig, elemIndex));
                    }

                    // add device tag
                    tagGroup.AddTag(elemConfig.TagCode, elemConfig.Name).SetFormat(GetTagFormat(elemConfig));
                    elemIndex++;
                }

                if (groupActive)
                {
                    elemGroup.InitReqPDU();
                    elemGroup.InitReqADU(deviceModel.Addr, transMode);
                    deviceModel.ElemGroups.Add(elemGroup);
                }

                DeviceTags.AddGroup(tagGroup);
            }

            // add model commands
            foreach (CmdConfig cmdConfig in deviceTemplate.Cmds)
            {
                deviceModel.Cmds.Add(CreateModbusCmd(deviceTemplate.Options, cmdConfig));
            }

            deviceModel.InitCmdMap();
            CanSendCommands = deviceModel.Cmds.Count > 0;
            InitModbusPoll();
        }
 /// <summary>
 /// Initializes the device tags.
 /// </summary>
 public override void InitDeviceTags()
 {
     DeviceTags.AddGroup(CnlPrototypeFactory.GetCnlPrototypeGroup().ToTagGroup());
 }