Beispiel #1
0
        private void SetStatusVariable(SVIDMapInfo mi, SecsItem secsItem_SV)
        {
            //2.) Get value from secs item
            object val = null;

            SVIDAttribute svAttr = mi.SVIDInfo;

            if (secsItem_SV is SecsItemU1)
            {
                if (svAttr.Size == 1)
                {
                    val = ((SecsItemU1)secsItem_SV).Value[0];
                }
                else
                {
                    val = ((SecsItemU1)secsItem_SV).Value;
                }
            }
            else if (secsItem_SV is SecsItemU2)
            {
                if (svAttr.Size == 1)
                {
                    val = ((SecsItemU2)secsItem_SV).Value[0];
                }
                else
                {
                    val = ((SecsItemU2)secsItem_SV).Value;
                }
            }
            else if (secsItem_SV is SecsItemU4)
            {
                if (svAttr.Size == 1)
                {
                    val = ((SecsItemU4)secsItem_SV).Value[0];
                }
                else
                {
                    val = ((SecsItemU4)secsItem_SV).Value;
                }
            }
            else if (secsItem_SV is SecsItemU8)
            {
                if (svAttr.Size == 1)
                {
                    val = ((SecsItemU8)secsItem_SV).Value[0];
                }
                else
                {
                    val = ((SecsItemU8)secsItem_SV).Value;
                }
            }
            else if (secsItem_SV is SecsItemI1)
            {
                if (svAttr.Size == 1)
                {
                    val = ((SecsItemI1)secsItem_SV).Value[0];
                }
                else
                {
                    val = ((SecsItemI1)secsItem_SV).Value;
                }
            }
            else if (secsItem_SV is SecsItemI2)
            {
                if (svAttr.Size == 1)
                {
                    val = ((SecsItemI2)secsItem_SV).Value[0];
                }
                else
                {
                    val = ((SecsItemI2)secsItem_SV).Value;
                }
            }
            else if (secsItem_SV is SecsItemI4)
            {
                if (svAttr.Size == 1)
                {
                    val = ((SecsItemI4)secsItem_SV).Value[0];
                }
                else
                {
                    val = ((SecsItemI4)secsItem_SV).Value;
                }
            }
            else if (secsItem_SV is SecsItemI8)
            {
                if (svAttr.Size == 1)
                {
                    val = ((SecsItemI8)secsItem_SV).Value[0];
                }
                else
                {
                    val = ((SecsItemI8)secsItem_SV).Value;
                }
            }
            else if (secsItem_SV is SecsItemBinary)
            {
                if (svAttr.Size == 1)
                {
                    val = ((SecsItemBinary)secsItem_SV).Value[0];
                }
                else
                {
                    val = ((SecsItemBinary)secsItem_SV).Value;
                }
            }
            else if (secsItem_SV is SecsItemAscii)
            {
                val = ((SecsItemAscii)secsItem_SV).Value;
            }
            else if (secsItem_SV is SecsItemBoolean)
            {
                if (svAttr.Size == 1)
                {
                    val = ((SecsItemBoolean)secsItem_SV).Value[0];
                }
                else
                {
                    val = ((SecsItemBoolean)secsItem_SV).Value;
                }
            }
            else
            {
                throw new Exception("Not support type " + secsItem_SV.GetType().Name);
            }

            PropertyInfo pi = mi.PropertyInfo;

            pi.SetValue(m_Model, val, null);
        }
Beispiel #2
0
 internal SVIDMapInfo(PropertyInfo pi, SVIDAttribute svAttr)
 {
     this.PropertyInfo = pi;
     this.SVIDInfo     = svAttr;
 }