Ejemplo n.º 1
0
 internal MappingEntry GetMappingEntryForType(Type type)
 {
     if (!_entries.TryGetValue(type, out var mappingEntry))
     {
         mappingEntry = new MappingEntry(PlcObjectResolver.GetMapping(type.Name, _tree, type, true));
         _entries.Add(type, mappingEntry);
     }
     return(mappingEntry);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Return all variable names of an mapping
        /// </summary>
        /// <param name="mapping"></param>
        /// <returns></returns>
        public IEnumerable <string> GetVariablesOf(string mapping)
        {
            var result = new List <string>();

            if (EntriesByName.TryGetValue(mapping, out IEntry entry))
            {
                return(PlcObjectResolver.GetLeafs(entry.PlcObject, result));
            }
            ExceptionThrowHelper.ThrowMappingNotFoundException(mapping);
            return(null);
        }
Ejemplo n.º 3
0
 internal bool UpdateVariables(MappingEntry mappingEntry, string variable)
 {
     if (PlcObjectResolver.AddPlcObjects(mappingEntry.PlcObject, mappingEntry.Variables, new List <string> {
         variable
     }))
     {
         if (mappingEntry.Variables.TryGetValue(variable, out var accessObject))
         {
             mappingEntry.Bindings.Add(variable, new PlcObjectBinding(mappingEntry.BaseBinding.RawData, accessObject.Item2, accessObject.Item1 + accessObject.Item2.ByteOffset, 0));
             return(true);
         }
     }
     return(false);
 }