예제 #1
0
        private void Map(EquipmentModel model)
        {
            m_SVAttributeDic.Clear();

            Type          eqType          = model.GetType();
            Type          svAttributeType = typeof(SVIDAttribute);
            SVIDAttribute svAttribute;

            PropertyInfo[] props = eqType.GetProperties();
            SVIDMapInfo    mi    = null;

            foreach (PropertyInfo pi in props)
            {
                if (pi.CanWrite && pi.IsDefined(svAttributeType, true))
                {
                    object[] attrs = pi.GetCustomAttributes(svAttributeType, true);
                    svAttribute = (SVIDAttribute)attrs[0];
                    if (m_SVAttributeDic.ContainsKey(svAttribute.ID))
                    {
                        //throw error
                        throw new Exception(string.Format("Duplicated SVID {0} PropertyName := {1}", svAttribute.ID, pi.Name));
                    }

                    mi = new SVIDMapInfo(pi, svAttribute);

                    m_SVAttributeDic.Add(svAttribute.ID, mi);
                }
            }
        }
예제 #2
0
 public SVAttributeMapper(EquipmentModel model)
 {
     m_SVAttributeDic = new Dictionary <object, SVIDMapInfo>();
     m_Model          = model;
     m_Model.SetSVIDMapper(this);
     Map(m_Model);
 }
예제 #3
0
        public SecsHost Create(EquipmentModel eqModel)
        {
            GemOption opt = eqModel.Connection;

            SecsHost host = null;

            if (opt.Protocol == GemProtocol.HSMS)
            {
                host = new HsmsHost(opt.HsmsParameters);
            }
            else if (opt.Protocol == GemProtocol.SECS_I)
            {
                host = new SecsIHost(opt.SecsIParameters);
            }

            host.DeviceId = opt.DeviceId;

            return(host);
        }