Exemple #1
0
        //------------------------------------------------------------------------------------------------------------------------
        private Thing ReconstructThing(ThingDescriptor thdesc)
        {
            if (!LookupThingType.ContainsKey(thdesc.Type))
            {
                DebugEx.TraceError("Not Valid type in: " + thdesc.Name.ToLowerInvariant());
                return(null);
            }
            if (!LookupPortDirection.ContainsKey(thdesc.IO.ToLowerInvariant()))
            {
                DebugEx.TraceError("Not Valid IO in: " + thdesc.Name);
                return(null);
            }

            Thing thing = new Thing()
            {
                Name    = thdesc?.Name,
                Config  = null,
                UIHints = new ThingUIHints()
                {
                    IconURI = thdesc?.FriendlyIcon
                }
            };

            thing.Ports = new List <Port>()
            {
                new Port()
                {
                    ioDirection = LookupPortDirection[thdesc.IO],
                    Name        = thing.Name + "Value",
                    Type        = LookupThingType[thdesc.Type],
                    PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "0"),
                    State       = LookupThingState[LookupThingType[thdesc.Type]],
                }
            };
            return(thing);
        }
Exemple #2
0
        //------------------------------------------------------------------------------------------------------------------------
        private Thing ReconstructThing(ThingDescriptor thdesc)
        {
            if (!LookupThingType.ContainsKey(thdesc.Type))
            {
                DebugEx.TraceError("Not Valid type in: " + thdesc.Name.ToLowerInvariant());
                return null;
            }
            if (!LookupPortDirection.ContainsKey(thdesc.IO.ToLowerInvariant()))
            {
                DebugEx.TraceError("Not Valid IO in: " + thdesc.Name);
                return null;
            }

            Thing thing = new Thing()
            {
                Name = thdesc?.Name,
                Config = null,
                UIHints = new ThingUIHints()
                {
                    IconURI = thdesc?.FriendlyIcon
                }
            };
            thing.Ports = new List<Port>()
            {
                new Port() {
                    ioDirection = LookupPortDirection[thdesc.IO],
                    Name =thing.Name +"Value",
                    Type = LookupThingType[thdesc.Type],
                     PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0"),
                     State = LookupThingState[LookupThingType[thdesc.Type]],
                }
            };
            return thing;
        }