Пример #1
0
        public static SlavePdo[] UploadPdoConfig(IntPtr context, UInt16 slave, UInt16 smIndex)
        {
            int    pdoCount;
            IntPtr ecPdoInfoPtrSet;

            SlavePdo[]      slavePdoSet;
            SyncManagerType syncManagerType;
            DataDirection   dataDirection;

            //
            EcHL.GetSyncManagerType(context, slave, smIndex, out syncManagerType);

            switch (syncManagerType)
            {
            case SyncManagerType.Inputs:
                dataDirection = DataDirection.Input;
                break;

            case SyncManagerType.Outputs:
                dataDirection = DataDirection.Output;
                break;

            default:
                throw new ArgumentException();
            }

            EcHL.UploadPdoConfig(context, slave, smIndex, out ecPdoInfoPtrSet, out pdoCount);

            slavePdoSet = Enumerable.Range(0, pdoCount).Select(index =>
            {
                ec_pdo_info_t ecPdoInfo;
                SlavePdo slavePdo;
                IntPtr ecPdoInfoPtr;

                ecPdoInfoPtr = IntPtr.Add(ecPdoInfoPtrSet, index * Marshal.SizeOf(typeof(ec_pdo_info_t)));
                ecPdoInfo    = Marshal.PtrToStructure <ec_pdo_info_t>(ecPdoInfoPtr);
                slavePdo     = new SlavePdo(null, ecPdoInfo.name, ecPdoInfo.index, 0, true, true, smIndex - 0x1C10);

                slavePdo.SetVariableSet(Enumerable.Range(0, ecPdoInfo.variableCount).Select(index2 =>
                {
                    ec_variable_info_t ecVariableInfo;
                    SlaveVariable slaveVariable;
                    IntPtr ecVariableInfoPtr;

                    ecVariableInfoPtr = IntPtr.Add(ecPdoInfo.variableInfoSet, index2 * Marshal.SizeOf(typeof(ec_variable_info_t)));
                    ecVariableInfo    = Marshal.PtrToStructure <ec_variable_info_t>(ecVariableInfoPtr);
                    slaveVariable     = new SlaveVariable(slavePdo, ecVariableInfo.name, ecVariableInfo.index, ecVariableInfo.subIndex, dataDirection, EcUtilities.GetOneDasDataTypeFromEthercatDataType(ecVariableInfo.dataType));

                    return(slaveVariable);
                }).ToList());

                EcHL.Free(ecPdoInfo.variableInfoSet);

                return(slavePdo);
            }).ToArray();

            EcHL.Free(ecPdoInfoPtrSet);

            return(slavePdoSet);
        }
Пример #2
0
        public override void EvaluateSettings()
        {
            SlavePdo slavePdo;
            int      currentInputIndex;
            int      currentOutputIndex;

            //
            currentInputIndex  = 0;
            currentOutputIndex = 0;
            this.SlaveInfo.DynamicData.PdoSet.Clear();

            // inputs
            this.ModuleSet.ForEach(module =>
            {
                int currentIndex;
                ushort pdoAddress;
                ushort variableAddress;
                ushort syncManager;

                string prefix;

                switch (module.DataDirection)
                {
                case DataDirection.Input:

                    pdoAddress      = 0x1A00;
                    variableAddress = 0x6000;
                    syncManager     = 0x03;
                    prefix          = "RxPDO";
                    currentIndex    = currentInputIndex;
                    currentInputIndex++;

                    break;

                case DataDirection.Output:

                    pdoAddress      = 0x1600;
                    variableAddress = 0x7000;
                    syncManager     = 0x02;
                    prefix          = "TxPDO";
                    currentIndex    = currentOutputIndex;
                    currentOutputIndex++;

                    break;

                default:
                    throw new ArgumentException();
                }

                slavePdo = new SlavePdo(this.SlaveInfo, $"{ prefix } { currentIndex } ({ module.DataType })", (ushort)(pdoAddress + currentIndex), 0, true, true, syncManager);

                slavePdo.SetVariableSet(Enumerable.Range(0, module.Size).Select(currentVariableIndex =>
                {
                    return(new SlaveVariable(slavePdo, $"Var { currentVariableIndex }", (ushort)(variableAddress + currentIndex * 10), 0x01, module.DataDirection, module.DataType));
                }).ToList());

                this.SlaveInfo.DynamicData.PdoSet.Add(slavePdo);
            });
        }
Пример #3
0
        public static SlavePdo[] UploadPdoConfig(IntPtr context, UInt16 slave, UInt16 smIndex)
        {
            EcHL.GetSyncManagerType(context, slave, smIndex, out var syncManagerType);

            DataDirection dataDirection;

            switch (syncManagerType)
            {
            case SyncManagerType.Inputs:
                dataDirection = DataDirection.Input;
                break;

            case SyncManagerType.Outputs:
                dataDirection = DataDirection.Output;
                break;

            default:
                throw new ArgumentException();
            }

            EcHL.UploadPdoConfig(context, slave, smIndex, out var ecPdoInfoPtrs, out var pdoCount);

            var slavePdos = Enumerable.Range(0, pdoCount).Select(index =>
            {
                var ecPdoInfoPtr = IntPtr.Add(ecPdoInfoPtrs, index * Marshal.SizeOf(typeof(ec_pdo_info_t)));
                var ecPdoInfo    = Marshal.PtrToStructure <ec_pdo_info_t>(ecPdoInfoPtr);
                var slavePdo     = new SlavePdo(null, ecPdoInfo.name, ecPdoInfo.index, 0, true, true, smIndex - 0x1C10);

                slavePdo.SetVariables(Enumerable.Range(0, ecPdoInfo.variableCount).Select(index2 =>
                {
                    var ecVariableInfoPtr = IntPtr.Add(ecPdoInfo.variableInfos, index2 * Marshal.SizeOf(typeof(ec_variable_info_t)));
                    var ecVariableInfo    = Marshal.PtrToStructure <ec_variable_info_t>(ecVariableInfoPtr);
                    var slaveVariable     = new SlaveVariable(slavePdo, ecVariableInfo.name, ecVariableInfo.index, ecVariableInfo.subIndex, dataDirection, ecVariableInfo.dataType);

                    return(slaveVariable);
                }).ToList());

                EcHL.Free(ecPdoInfo.variableInfos);

                return(slavePdo);
            }).ToArray();

            EcHL.Free(ecPdoInfoPtrs);

            return(slavePdos);
        }
Пример #4
0
        public override void EvaluateSettings()
        {
            int consumedBytes;
            int currentPdo;
            int currentIndex;
            int currentBytes;

            SlavePdo currentSlavePdo;

            //
            this.SlaveInfo.DynamicData.PdoSet.Clear();

            // inputs
            consumedBytes = 0;
            currentPdo    = 0;
            currentIndex  = 0;

            this.ModuleSet.Where(module => module.DataDirection == DataDirection.Input).ToList().ForEach(module =>
            {
                if (currentPdo > 4)
                {
                    throw new Exception(ExtensionErrorMessage.AnybusXGatewaySettings_TooManyModules);
                }

                if (module.DataType == OneDasDataType.BOOLEAN)
                {
                    throw new Exception(ExtensionErrorMessage.AnybusXGatewaySettings_InvalidDatatype);
                }

                currentBytes = ((int)module.DataType & 0x0FF) / 8 * module.Size;

                if (consumedBytes + currentBytes > 0x80)
                {
                    throw new Exception(ExtensionErrorMessage.AnybusXGatewaySettings_InvalidSize);
                }

                currentSlavePdo = new SlavePdo(this.SlaveInfo, $"RxPDO { currentIndex } ({ module.Size }x { module.DataType })", (ushort)(0x1A00 + currentPdo), 0, true, true, 0x03);

                currentSlavePdo.SetVariableSet(Enumerable.Range(0, module.Size).Select(currentVariableIndex =>
                {
                    return(new SlaveVariable(currentSlavePdo, $"Var { currentVariableIndex }", (ushort)(0x2000 + currentPdo), (byte)(consumedBytes + currentVariableIndex), DataDirection.Input, module.DataType));
                }).ToList());

                this.SlaveInfo.DynamicData.PdoSet.Add(currentSlavePdo);

                currentIndex++;
                consumedBytes += currentBytes;

                if (consumedBytes == 0x80)
                {
                    consumedBytes = 0;
                    currentBytes  = 0;
                    currentPdo++;
                }
            });

            // outputs
            consumedBytes = 0;
            currentPdo    = 0;
            currentIndex  = 0;

            this.ModuleSet.Where(module => module.DataDirection == DataDirection.Output).ToList().ForEach(module =>
            {
                if (currentPdo > 4)
                {
                    throw new Exception(ExtensionErrorMessage.AnybusXGatewaySettings_TooManyModules);
                }

                if (module.DataType == OneDasDataType.BOOLEAN)
                {
                    throw new Exception(ExtensionErrorMessage.AnybusXGatewaySettings_InvalidDatatype);
                }

                currentBytes = ((int)module.DataType & 0x0FF) / 8 * module.Size;

                if (consumedBytes + currentBytes > 0x80)
                {
                    throw new Exception(ExtensionErrorMessage.AnybusXGatewaySettings_InvalidSize);
                }

                currentSlavePdo = new SlavePdo(this.SlaveInfo, $"TxPDO { currentIndex } ({ module.Size }x { module.DataType })", (ushort)(0x1600 + currentPdo), 0, true, true, 0x02);

                currentSlavePdo.SetVariableSet(Enumerable.Range(0, module.Size).Select(currentVariableIndex =>
                {
                    return(new SlaveVariable(currentSlavePdo, $"Var { currentVariableIndex }", (ushort)(0x2000 + currentPdo), (byte)(consumedBytes + currentVariableIndex), DataDirection.Output, module.DataType));
                }).ToList());

                this.SlaveInfo.DynamicData.PdoSet.Add(currentSlavePdo);

                currentIndex++;
                consumedBytes += currentBytes;

                if (consumedBytes == 0x80)
                {
                    consumedBytes = 0;
                    currentBytes  = 0;
                    currentPdo++;
                }
            });
        }
Пример #5
0
        public override void EvaluateSettings()
        {
            Contract.Requires(SelectedModuleSet != null);

            if (!(0 < this.StationNumber && this.StationNumber < 127))
            {
                throw new Exception(ExtensionErrorMessage.EL6731_0010Settings_StationNumberInvalid);
            }

            this.SlaveInfo.DynamicData.PdoSet.Clear();

            foreach (EL6731_0010Module el6731_0010_Module in this.SelectedModuleSet)
            {
                ushort               pdoIndex           = 0;
                ushort               syncManager        = 0;
                ushort               variableIndex      = 0;
                ushort               arrayLength        = 0;
                OneDasDataType       dataType           = default;
                DataDirection        dataDirection      = default;
                List <SlaveVariable> ecSlaveVariableSet = new List <SlaveVariable>();

                if ((int)el6731_0010_Module == 0x50) // word ouput
                {
                    dataType      = OneDasDataType.UINT16;
                    dataDirection = DataDirection.Output;
                    arrayLength   = (ushort)(el6731_0010_Module - 0x50 + 1);
                }
                else if (0xd1 <= (int)el6731_0010_Module && (int)el6731_0010_Module <= 0xdf)
                {
                    dataType      = OneDasDataType.UINT16;
                    dataDirection = DataDirection.Output;
                    arrayLength   = (ushort)(el6731_0010_Module - 0xd1 + 2);
                }
                else if (0x40d0 <= (int)el6731_0010_Module && (int)el6731_0010_Module <= 0x40ff)
                {
                    dataType      = OneDasDataType.UINT16;
                    dataDirection = DataDirection.Output;
                    arrayLength   = (ushort)(el6731_0010_Module - 0x40d0 + 16 + 1);
                }
                else if ((int)el6731_0010_Module == 0x60) // word input
                {
                    dataType      = OneDasDataType.UINT16;
                    dataDirection = DataDirection.Input;
                    arrayLength   = (ushort)(el6731_0010_Module - 0x60 + 1);
                }
                else if (0xe1 <= (int)el6731_0010_Module && (int)el6731_0010_Module <= 0xef)
                {
                    dataType      = OneDasDataType.UINT16;
                    dataDirection = DataDirection.Input;
                    arrayLength   = (ushort)(el6731_0010_Module - 0xe1 + 2);
                }
                else if (0x80d0 <= (int)el6731_0010_Module && (int)el6731_0010_Module <= 0x80fff)
                {
                    dataType      = OneDasDataType.UINT16;
                    dataDirection = DataDirection.Input;
                    arrayLength   = (ushort)(el6731_0010_Module - 0x80d0 + 16 + 1);
                }
                else if (0x10 <= (int)el6731_0010_Module && (int)el6731_0010_Module <= 0x1f) // byte output
                {
                    dataType      = OneDasDataType.UINT8;
                    dataDirection = DataDirection.Output;
                    arrayLength   = (ushort)(el6731_0010_Module - 0x10 + 1);
                }
                else if (0x20 <= (int)el6731_0010_Module && (int)el6731_0010_Module <= 0x2f) // byte input
                {
                    dataType      = OneDasDataType.UINT8;
                    dataDirection = DataDirection.Input;
                    arrayLength   = (ushort)(el6731_0010_Module - 0x20 + 1);
                }
                else
                {
                    throw new Exception(ExtensionErrorMessage.EL6731_0010Settings_ModuleInvalid);
                }

                // improve, implicit?
                switch (dataDirection)
                {
                case DataDirection.Output:
                    pdoIndex      = 0x1600;
                    syncManager   = 2;
                    variableIndex = 0x7000;
                    break;

                case DataDirection.Input:
                    pdoIndex      = 0x1a00;
                    syncManager   = 3;
                    variableIndex = 0x6000;
                    break;
                }

                SlavePdo slavePdo = new SlavePdo(this.SlaveInfo, el6731_0010_Module.ToString(), pdoIndex, 0, true, true, syncManager);
                ushort   offset   = (ushort)this.SlaveInfo.DynamicData.PdoSet.SelectMany(x => x.VariableSet).Where(x => x.DataDirection == dataDirection).Count();

                for (ushort i = (ushort)(offset + 0); i <= offset + arrayLength - 1; i++)
                {
                    ecSlaveVariableSet.Add(new SlaveVariable(slavePdo, i.ToString(), variableIndex, Convert.ToByte(i + 1), dataDirection, dataType));
                }

                slavePdo.SetVariableSet(ecSlaveVariableSet);
                this.SlaveInfo.DynamicData.PdoSet.Add(slavePdo);
            }

            // 1A80 improve! include Variables
            SlavePdo slavePdo2 = new SlavePdo(this.SlaveInfo, "Diagnostics", 0x1a80, 0, true, true, 3);

            slavePdo2.SetVariableSet(new List <SlaveVariable>());
            this.SlaveInfo.DynamicData.PdoSet.Add(slavePdo2);
        }
Пример #6
0
        public static void CreateDynamicData(string esiDirectoryPath, IExtensionFactory extensionFactory, SlaveInfo slaveInfo)
        {
            string          name;
            string          description;
            List <SlavePdo> pdoSet;

            byte[] base64ImageData;

            // find ESI
            if (slaveInfo.Csa != 0)
            {
                (slaveInfo.SlaveEsi, slaveInfo.SlaveEsi_Group) = EsiUtilities.FindEsi(esiDirectoryPath, slaveInfo.Manufacturer, slaveInfo.ProductCode, slaveInfo.Revision);
            }

            //
            pdoSet          = new List <SlavePdo>();
            base64ImageData = new byte[] { };

            name        = slaveInfo.SlaveEsi.Type.Value;
            description = slaveInfo.SlaveEsi.Name.FirstOrDefault()?.Value;

            if (description.StartsWith(name))
            {
                description = description.Substring(name.Length);
            }
            else if (string.IsNullOrWhiteSpace(description))
            {
                description = "no description available";
            }

            // PDOs
            foreach (DataDirection dataDirection in Enum.GetValues(typeof(DataDirection)))
            {
                IEnumerable <PdoType> pdoTypeSet = null;

                switch (dataDirection)
                {
                case DataDirection.Output:
                    pdoTypeSet = slaveInfo.SlaveEsi.RxPdo;
                    break;

                case DataDirection.Input:
                    pdoTypeSet = slaveInfo.SlaveEsi.TxPdo;
                    break;
                }

                foreach (PdoType pdoType in pdoTypeSet)
                {
                    int      syncManager;
                    ushort   pdoIndex;
                    string   pdoName;
                    SlavePdo slavePdo;

                    var osMax = Convert.ToUInt16(pdoType.OSMax);

                    if (osMax == 0)
                    {
                        pdoName     = pdoType.Name.First().Value;
                        pdoIndex    = (ushort)EsiUtilities.ParseHexDecString(pdoType.Index.Value);
                        syncManager = pdoType.SmSpecified ? pdoType.Sm : -1;

                        slavePdo = new SlavePdo(slaveInfo, pdoName, pdoIndex, osMax, pdoType.Fixed, pdoType.Mandatory, syncManager);

                        pdoSet.Add(slavePdo);

                        IList <SlaveVariable> slaveVariableSet = pdoType.Entry.Select(x =>
                        {
                            var variableIndex = (ushort)EsiUtilities.ParseHexDecString(x.Index.Value);
                            var subIndex      = Convert.ToByte(x.SubIndex);
                            //// Improve. What about -1 if SubIndex does not exist?
                            return(new SlaveVariable(slavePdo, x.Name?.FirstOrDefault()?.Value, variableIndex, subIndex, dataDirection, EcUtilities.GetOneDasDataTypeFromEthercatDataType(x.DataType?.Value), (byte)x.BitLen));
                        }).ToList();

                        slavePdo.SetVariableSet(slaveVariableSet);
                    }
                    else
                    {
                        for (ushort indexOffset = 0; indexOffset <= osMax - 1; indexOffset++)
                        {
                            pdoName     = $"{pdoType.Name.First().Value} [{indexOffset}]";
                            pdoIndex    = (ushort)((ushort)EsiUtilities.ParseHexDecString(pdoType.Index.Value) + indexOffset);
                            syncManager = pdoType.SmSpecified ? pdoType.Sm : -1;
                            var indexOffset_Tmp = indexOffset;

                            slavePdo = new SlavePdo(slaveInfo, pdoName, pdoIndex, osMax, pdoType.Fixed, pdoType.Mandatory, syncManager);

                            pdoSet.Add(slavePdo);

                            IList <SlaveVariable> slaveVariableSet = pdoType.Entry.Select(x =>
                            {
                                var variableIndex = (ushort)EsiUtilities.ParseHexDecString(x.Index.Value);
                                var subIndex      = (byte)(byte.Parse(x.SubIndex) + indexOffset_Tmp);
                                //// Improve. What about -1 if SubIndex does not exist?
                                return(new SlaveVariable(slavePdo, x.Name.FirstOrDefault()?.Value, variableIndex, subIndex, dataDirection, EcUtilities.GetOneDasDataTypeFromEthercatDataType(x.DataType?.Value), (byte)x.BitLen));
                            }).ToList();

                            slavePdo.SetVariableSet(slaveVariableSet);
                        }
                    }
                }
            }

            // image data
            if (slaveInfo.SlaveEsi_Group.ItemElementName == ItemChoiceType1.ImageData16x14)
            {
                base64ImageData = (byte[])slaveInfo.SlaveEsi_Group.Item;
            }

            if (slaveInfo.SlaveEsi.ItemElementName.ToString() == nameof(ItemChoiceType1.ImageData16x14))
            {
                base64ImageData = (byte[])slaveInfo.SlaveEsi.Item;
            }

            // attach dynamic data
            slaveInfo.DynamicData = new SlaveInfoDynamicData(name, description, pdoSet, base64ImageData);

            // execute extension logic
            ExtensibilityHelper.UpdateSlaveExtensions(extensionFactory, slaveInfo);

            slaveInfo.SlaveExtensionSet.ToList().ForEach(slaveExtension =>
            {
                slaveExtension.EvaluateSettings();
            });
        }
Пример #7
0
        public static void CreateDynamicData(string esiDirectoryPath, SlaveInfo slave)
        {
            // find ESI
            if (slave.Csa != 0)
            {
                (slave.Esi, slave.EsiGroup) = EsiUtilities.FindEsi(esiDirectoryPath, slave.Manufacturer, slave.ProductCode, slave.Revision);
            }

            //
            var pdos            = new List <SlavePdo>();
            var base64ImageData = new byte[] { };

            var name        = slave.Esi.Type.Value;
            var description = slave.Esi.Name.FirstOrDefault()?.Value;

            if (description.StartsWith(name))
            {
                description = description.Substring(name.Length);
            }

            else if (string.IsNullOrWhiteSpace(description))
            {
                description = "no description available";
            }

            // PDOs
            foreach (DataDirection dataDirection in Enum.GetValues(typeof(DataDirection)))
            {
                IEnumerable <PdoType> pdoTypes = null;

                switch (dataDirection)
                {
                case DataDirection.Output:
                    pdoTypes = slave.Esi.RxPdo;
                    break;

                case DataDirection.Input:
                    pdoTypes = slave.Esi.TxPdo;
                    break;
                }

                foreach (var pdoType in pdoTypes)
                {
                    var osMax = Convert.ToUInt16(pdoType.OSMax);

                    if (osMax == 0)
                    {
                        var pdoName     = pdoType.Name.First().Value;
                        var pdoIndex    = (ushort)EsiUtilities.ParseHexDecString(pdoType.Index.Value);
                        var syncManager = pdoType.SmSpecified ? pdoType.Sm : -1;

                        var slavePdo = new SlavePdo(slave, pdoName, pdoIndex, osMax, pdoType.Fixed, pdoType.Mandatory, syncManager);

                        pdos.Add(slavePdo);

                        var slaveVariables = pdoType.Entry.Select(x =>
                        {
                            var variableIndex = (ushort)EsiUtilities.ParseHexDecString(x.Index.Value);
                            var subIndex      = Convert.ToByte(x.SubIndex);
                            //// Improve. What about -1 if SubIndex does not exist?
                            return(new SlaveVariable(slavePdo, x.Name?.FirstOrDefault()?.Value, variableIndex, subIndex, dataDirection, EcUtilities.ParseEtherCatDataType(x.DataType?.Value), (byte)x.BitLen));
                        }).ToList();

                        slavePdo.SetVariables(slaveVariables);
                    }
                    else
                    {
                        for (ushort indexOffset = 0; indexOffset <= osMax - 1; indexOffset++)
                        {
                            var pdoName         = $"{pdoType.Name.First().Value} [{indexOffset}]";
                            var pdoIndex        = (ushort)((ushort)EsiUtilities.ParseHexDecString(pdoType.Index.Value) + indexOffset);
                            var syncManager     = pdoType.SmSpecified ? pdoType.Sm : -1;
                            var indexOffset_Tmp = indexOffset;

                            var slavePdo = new SlavePdo(slave, pdoName, pdoIndex, osMax, pdoType.Fixed, pdoType.Mandatory, syncManager);

                            pdos.Add(slavePdo);

                            var slaveVariables = pdoType.Entry.Select(x =>
                            {
                                var variableIndex = (ushort)EsiUtilities.ParseHexDecString(x.Index.Value);
                                var subIndex      = (byte)(byte.Parse(x.SubIndex) + indexOffset_Tmp);
                                //// Improve. What about -1 if SubIndex does not exist?
                                return(new SlaveVariable(slavePdo, x.Name.FirstOrDefault()?.Value, variableIndex, subIndex, dataDirection, EcUtilities.ParseEtherCatDataType(x.DataType?.Value), (byte)x.BitLen));
                            }).ToList();

                            slavePdo.SetVariables(slaveVariables);
                        }
                    }
                }
            }

            // image data
            if (slave.EsiGroup.ItemElementName == ItemChoiceType1.ImageData16x14)
            {
                base64ImageData = (byte[])slave.EsiGroup.Item;
            }

            if (slave.Esi.ItemElementName.ToString() == nameof(ItemChoiceType1.ImageData16x14))
            {
                base64ImageData = (byte[])slave.Esi.Item;
            }

            // attach dynamic data
            slave.DynamicData = new SlaveInfoDynamicData(name, description, pdos, base64ImageData);

            // add DC extension to extensions
            if (slave.Esi.Dc is not null &&
                !slave.Extensions.Any(extension => extension.GetType() == typeof(DistributedClocksExtension)))
            {
                slave.Extensions.Add(new DistributedClocksExtension(slave));
            }

            // execute extension logic
            slave.Extensions.ToList().ForEach(extension =>
            {
                extension.EvaluateSettings();
            });
        }
Пример #8
0
        public override void EvaluateSettings()
        {
            // dont forget validation!



            //this.SlaveInfo.DynamicData.PdoSet.Clear();

            //foreach (EL6751_0010Module el6751_0010_Module in this.SelectedModuleSet)
            //{
            //    ushort pdoIndex = 0;
            //    ushort syncManager = 0;
            //    ushort variableIndex = 0;
            //    ushort arrayLength = 0;
            //    OneDasDataType dataType = default;
            //    DataDirection dataDirection = default;
            //    List<SlaveVariable> ecSlaveVariableSet = new List<SlaveVariable>();

            //    if ((int)el6751_0010_Module == 0x50) // word ouput
            //    {
            //        dataType = OneDasDataType.UINT16;
            //        dataDirection = DataDirection.Output;
            //        arrayLength = (ushort)(el6751_0010_Module - 0x50 + 1);
            //    }
            //    else if (0xd1 <= (int)el6751_0010_Module && (int)el6751_0010_Module <= 0xdf)
            //    {
            //        dataType = OneDasDataType.UINT16;
            //        dataDirection = DataDirection.Output;
            //        arrayLength = (ushort)(el6751_0010_Module - 0xd1 + 2);
            //    }
            //    else if (0x40d0 <= (int)el6751_0010_Module && (int)el6751_0010_Module <= 0x40ff)
            //    {
            //        dataType = OneDasDataType.UINT16;
            //        dataDirection = DataDirection.Output;
            //        arrayLength = (ushort)(el6751_0010_Module - 0x40d0 + 16 + 1);
            //    }
            //    else if ((int)el6751_0010_Module == 0x60) // word input
            //    {
            //        dataType = OneDasDataType.UINT16;
            //        dataDirection = DataDirection.Input;
            //        arrayLength = (ushort)(el6751_0010_Module - 0x60 + 1);
            //    }
            //    else if (0xe1 <= (int)el6751_0010_Module && (int)el6751_0010_Module <= 0xef)
            //    {
            //        dataType = OneDasDataType.UINT16;
            //        dataDirection = DataDirection.Input;
            //        arrayLength = (ushort)(el6751_0010_Module - 0xe1 + 2);
            //    }
            //    else if (0x80d0 <= (int)el6751_0010_Module && (int)el6751_0010_Module <= 0x80fff)
            //    {
            //        dataType = OneDasDataType.UINT16;
            //        dataDirection = DataDirection.Input;
            //        arrayLength = (ushort)(el6751_0010_Module - 0x80d0 + 16 + 1);
            //    }
            //    else if (0x10 <= (int)el6751_0010_Module && (int)el6751_0010_Module <= 0x1f) // byte output
            //    {
            //        dataType = OneDasDataType.UINT8;
            //        dataDirection = DataDirection.Output;
            //        arrayLength = (ushort)(el6751_0010_Module - 0x10 + 1);
            //    }
            //    else if (0x20 <= (int)el6751_0010_Module && (int)el6751_0010_Module <= 0x2f) // byte input
            //    {
            //        dataType = OneDasDataType.UINT8;
            //        dataDirection = DataDirection.Input;
            //        arrayLength = (ushort)(el6751_0010_Module - 0x20 + 1);
            //    }
            //    else
            //    {
            //        throw new Exception("Invalid module.");
            //    }

            //    // improve, implicit?
            //    switch (dataDirection)
            //    {
            //        case DataDirection.Output:
            //            pdoIndex = 0x1600;
            //            syncManager = 2;
            //            variableIndex = 0x7000;
            //            break;
            //        case DataDirection.Input:
            //            pdoIndex = 0x1a00;
            //            syncManager = 3;
            //            variableIndex = 0x6000;
            //            break;
            //    }

            //    SlavePdo slavePdo = new SlavePdo(this.SlaveInfo, el6751_0010_Module.ToString(), pdoIndex, 0, true, true, syncManager);
            //    ushort offset = (ushort)this.SlaveInfo.DynamicData.PdoSet.SelectMany(x => x.VariableSet).Where(x => x.DataDirection == dataDirection).Count();

            //    for (ushort i = (ushort)(offset + 0); i <= offset + arrayLength - 1; i++)
            //    {
            //        ecSlaveVariableSet.Add(new SlaveVariable(slavePdo, i.ToString(), variableIndex, Convert.ToByte(i + 1), InfrastructureHelper.GetBitLength(dataType, false), dataDirection, dataType));
            //    }

            //    slavePdo.SetVariableSet(ecSlaveVariableSet);
            //    this.SlaveInfo.DynamicData.PdoSet.Add(slavePdo);
            //}

            //// 1A80 improve! include Variables
            //SlavePdo slavePdo2 = new SlavePdo(this.SlaveInfo, "Diagnostics", 0x1a80, 0, true, true, 3);
            //slavePdo2.SetVariableSet(new List<SlaveVariable>());
            //this.SlaveInfo.DynamicData.PdoSet.Add(slavePdo2);



            SlavePdo slavePdo;

            this.SlaveInfo.DynamicData.PdoSet.Clear();

            // EL6751-0010 (CANopen Slave)_IN
            slavePdo = new SlavePdo(this.SlaveInfo, "EL6751-0010 (CANopen Slave)_IN", 0x1A00, 0, true, true, 0x03);

            slavePdo.SetVariableSet(new List <SlaveVariable>
            {
                new SlaveVariable(slavePdo, "CAN RxPDO 1", 0x6000, 0x01, DataDirection.Input, OneDasDataType.INT8)
            });

            this.SlaveInfo.DynamicData.PdoSet.Add(slavePdo);

            // CANopen Status
            slavePdo = new SlavePdo(this.SlaveInfo, "CANopen Status", 0x1A83, 0, true, true, 0x03);

            slavePdo.SetVariableSet(new List <SlaveVariable>
            {
                new SlaveVariable(slavePdo, "CANopenState", 0xF100, 0x01, DataDirection.Input, OneDasDataType.UINT16),
                new SlaveVariable(slavePdo, "TxPDO State", 0x1800, 0x07, DataDirection.Input, OneDasDataType.BOOLEAN)
            });

            this.SlaveInfo.DynamicData.PdoSet.Add(slavePdo);

            // CAN Diagnosis
            slavePdo = new SlavePdo(this.SlaveInfo, "CAN Diagnosis", 0x1A84, 0, true, true, 0x03);

            slavePdo.SetVariableSet(new List <SlaveVariable>
            {
                new SlaveVariable(slavePdo, "Device Diag", 0xF101, 0x0D, DataDirection.Input, OneDasDataType.BOOLEAN),
                new SlaveVariable(slavePdo, "Sync Error", 0xF101, 0x0E, DataDirection.Input, OneDasDataType.BOOLEAN),
                new SlaveVariable(slavePdo, "Device Toggle", 0xF101, 0x0F, DataDirection.Input, OneDasDataType.BOOLEAN),
                new SlaveVariable(slavePdo, "Device State", 0xF101, 0x10, DataDirection.Input, OneDasDataType.BOOLEAN),
                new SlaveVariable(slavePdo, "Cycle Counter", 0xF101, 0x11, DataDirection.Input, OneDasDataType.UINT16),
                new SlaveVariable(slavePdo, "Slave Status Counter", 0xF101, 0x12, DataDirection.Input, OneDasDataType.UINT8),
                new SlaveVariable(slavePdo, "Actual Cycle Time", 0xF101, 0x14, DataDirection.Input, OneDasDataType.UINT16),

                new SlaveVariable(slavePdo, "Rx error counter", 0xF108, 0x21, DataDirection.Input, OneDasDataType.UINT8),
                new SlaveVariable(slavePdo, "Tx error counter", 0xF108, 0x22, DataDirection.Input, OneDasDataType.UINT8),
                new SlaveVariable(slavePdo, "Bus off", 0xF108, 0x01, DataDirection.Input, OneDasDataType.BOOLEAN),
                new SlaveVariable(slavePdo, "Warning limit reached", 0xF108, 0x02, DataDirection.Input, OneDasDataType.BOOLEAN),
                new SlaveVariable(slavePdo, "Rx overflow", 0xF108, 0x03, DataDirection.Input, OneDasDataType.BOOLEAN),
                new SlaveVariable(slavePdo, "Tx overflow", 0xF108, 0x04, DataDirection.Input, OneDasDataType.BOOLEAN),
                new SlaveVariable(slavePdo, "Ack error", 0xF108, 0x05, DataDirection.Input, OneDasDataType.BOOLEAN),
            });

            this.SlaveInfo.DynamicData.PdoSet.Add(slavePdo);
        }