Пример #1
0
 public Port(PortKey portKey, ePortType type, ioPortDirection ioDirection, string portmodelid = null)
 {
     this.PortKey     = portKey;
     this.Type        = type;
     this.ioDirection = ioDirection;
     this.State       = null;
     this.PortModelId = portmodelid;
 }
Пример #2
0
 //should be used only by deserializer
 public Port()
 {
     this.Type        = ePortType.Undefined;
     this.ioDirection = ioPortDirection.Undefined;
     this.PortKey     = default(PortKey);
     this.PortModelId = default(string);
     this.Color       = "#0000FF";
     this.Size        = 18;
 }
Пример #3
0
 public static Type ePortType2Type(ePortType PortType)
 {
     if (PortType == ePortType.Undefined)
     {
         return(null);    //treat string as default
     }
     else if (PortType == ePortType.Integer)
     {
         return(typeof(Int64));
     }
     else if (PortType == ePortType.Decimal || PortType == ePortType.DecimalHigh)
     {
         return(typeof(double));
     }
     else if (PortType == ePortType.Boolean)
     {
         return(typeof(bool));
     }
     else if (PortType == ePortType.Color)
     {
         return(typeof(YColor));
     }
     else if (PortType == ePortType.String)
     {
         return(typeof(string));    //already string
     }
     else if (PortType == ePortType.VideoDescriptor)
     {
         return(typeof(VideoMediaDescriptor));
     }
     else if (PortType == ePortType.AudioDescriptor)
     {
         return(typeof(AudioMediaDescriptor));
     }
     else if (PortType == ePortType.BinaryResourceDescriptor)
     {
         return(typeof(BinaryResourceDescriptor));
     }
     else if (PortType == ePortType.I2CDescriptor)
     {
         return(typeof(I2CCommand));//sos discuss with mits and gepa
     }
     else if (PortType == ePortType.JsonString)
     {
         return(typeof(string));
     }
     else if (PortType == ePortType.Timestamp)
     {
         return(typeof(DateTime));
     }
     else
     {
         DebugEx.Assert($"channel type {PortType} not accounted for");
         return(null);
     }
 }
Пример #4
0
        public Port(PortKey portKey, ePortType type, ioPortDirection ioDirection, string portmodelid = null)
        {
            this.PortKey     = portKey;
            this.Type        = type;
            this.State       = null;
            this.PortModelId = portmodelid;

            DebugEx.Assert(ioDirection != ioPortDirection.Undefined, $"Undefined IO direction for port {portKey}");
            this.ioDirection = ioDirection;
        }
Пример #5
0
        public void Update_Except_States(Port otherPort)
        {
            this.Name        = otherPort.Name;
            this.Description = otherPort.Description;
            this.Type        = otherPort.Type;
            this.Semantics   = otherPort.Semantics;
            this.ioDirection = otherPort.ioDirection;

            this.PortKey     = otherPort.PortKey;
            this.ConfFlags   = otherPort.ConfFlags;
            this.PortModelId = otherPort.PortModelId;
        }
Пример #6
0
        public void Update_Except_States(Port otherPort)
        {
            this.Name        = otherPort.Name;
            this.Description = otherPort.Description;
            this.Type        = otherPort.Type;
            this.Semantics   = otherPort.Semantics;

            DebugEx.Assert(otherPort.ioDirection != ioPortDirection.Undefined, $"Undefined IO direction for port {otherPort.PortKey}");
            if (otherPort.ioDirection != ioPortDirection.Undefined)
            {
                this.ioDirection = otherPort.ioDirection;
            }

            this.PortKey     = otherPort.PortKey;
            this.ConfFlags   = otherPort.ConfFlags;
            this.PortModelId = otherPort.PortModelId;
        }
Пример #7
0
 public static object State2Value(ePortType portType, string state)
 {
     if (portType == ePortType.Undefined)
     {
         return(state);    //treat string as default
     }
     else if (portType == ePortType.String)
     {
         return(state);
     }
     else
     {
         var type = ePortType2Type(portType);
         if (type != null)
         {
             return(Yodiwo.ConvertEx.Convert(state, type));
         }
         else
         {
             throw new Exception($"channel type {portType} not accounted for.");
         }
     }
 }
Пример #8
0
 public static object State2Value(ePortType portType, string state)
 {
     if (portType == ePortType.Undefined)
         return state;    //treat string as default
     else if (portType == ePortType.String)
         return state;
     else
     {
         var type = ePortType2Type(portType);
         if (type != null)
             return Yodiwo.ConvertEx.Convert(state, type);
         else
             throw new Exception($"channel type {portType} not accounted for.");
     }
 }
Пример #9
0
 public static Type ePortType2Type(ePortType PortType)
 {
     if (PortType == ePortType.Undefined)
         return null;    //treat string as default
     else if (PortType == ePortType.Integer)
         return typeof(Int64);
     else if (PortType == ePortType.Decimal || PortType == ePortType.DecimalHigh)
         return typeof(double);
     else if (PortType == ePortType.Boolean)
         return typeof(bool);
     else if (PortType == ePortType.Color)
         return typeof(YColor);
     else if (PortType == ePortType.String)
         return typeof(string);    //already string
     else if (PortType == ePortType.VideoDescriptor)
         return typeof(VideoMediaDescriptor);
     else if (PortType == ePortType.AudioDescriptor)
         return typeof(AudioMediaDescriptor);
     else if (PortType == ePortType.BinaryResourceDescriptor)
         return typeof(BinaryResourceDescriptor);
     else if (PortType == ePortType.I2CDescriptor)
         return typeof(I2CCommand);//sos discuss with mits and gepa
     else if (PortType == ePortType.JsonString)
         return typeof(string);
     else
     {
         DebugEx.Assert($"channel type {PortType} not accounted for");
         throw new Exception($"channel type {PortType} not accounted for");
     }
 }
Пример #10
0
        public void Update_Except_States(Port otherPort)
        {
            this.Name = otherPort.Name;
            this.Description = otherPort.Description;
            this.Type = otherPort.Type;
            this.Semantics = otherPort.Semantics;
            this.ioDirection = otherPort.ioDirection;

            this.PortKey = otherPort.PortKey;
            this.ConfFlags = otherPort.ConfFlags;
            this.PortModelId = otherPort.PortModelId;
        }
Пример #11
0
 //should be used only by deserializer
 public Port()
 {
     this.Type = ePortType.Undefined;
     this.ioDirection = ioPortDirection.Undefined;
     this.PortKey = default(PortKey);
     this.PortModelId = default(string);
     this.Color = "#0000FF";
     this.Size = 18;
 }
Пример #12
0
 public Port(PortKey portKey, ePortType type, ioPortDirection ioDirection, string portmodelid = null)
 {
     this.PortKey = portKey;
     this.Type = type;
     this.ioDirection = ioDirection;
     this.State = null;
     this.PortModelId = portmodelid;
 }