Example #1
0
 // Find the hardwareId for the first instance of a given function class
 internal virtual string imm_getFirstHardwareId(string className)
 {
     if (!_yctx._BaseType.ContainsKey(className))
     {
         YFunctionType ft = imm_getFnByType(className);
         YPEntry       yp = ft.imm_getFirstYPEntry();
         if (yp == null)
         {
             return(null);
         }
         return(yp.HardwareId);
     }
     else
     {
         // using an abstract baseType
         YPEntry.BaseClass baseType = _yctx._BaseType[className];
         foreach (YFunctionType subClassType in _fnByType.Values)
         {
             YPEntry yp = subClassType.imm_getFirstYPEntry();
             if (yp != null && yp.getBaseClass().Equals(baseType))
             {
                 return(yp.HardwareId);
             }
         }
         return(null);
     }
 }
Example #2
0
 // Find the hardwareId for the next instance of a given function class
 internal virtual string imm_getNextHardwareId(string className, string hwid)
 {
     if (!_yctx._BaseType.ContainsKey(className))
     {
         YFunctionType ft = imm_getFnByType(className);
         YPEntry       yp = ft.imm_getNextYPEntry(hwid);
         if (yp == null)
         {
             return(null);
         }
         return(yp.HardwareId);
     }
     else
     {
         // enumeration of an abstract class
         YPEntry.BaseClass baseType  = _yctx._BaseType[className];
         string            prevclass = YAPIContext.imm_functionClass(hwid);
         YPEntry           res       = imm_getFnByType(prevclass).imm_getNextYPEntry(hwid);
         if (res != null)
         {
             return(res.HardwareId);
         }
         foreach (string altClassName in _fnByType.Keys)
         {
             if (!prevclass.Equals(""))
             {
                 if (!altClassName.Equals(prevclass))
                 {
                     continue;
                 }
                 prevclass = "";
                 continue;
             }
             YFunctionType functionType = _fnByType[altClassName];
             res = functionType.imm_getFirstYPEntry();
             if (res != null && res.getBaseClass().Equals(baseType))
             {
                 return(res.HardwareId);
             }
         }
         return(null);
     }
 }
Example #3
0
 // Find the best known identifier (hardware Id) for a given function
 internal virtual YPEntry imm_resolveFunction(string className, string func)
 {
     if (!_yctx._BaseType.ContainsKey(className))
     {
         return(imm_getFnByType(className).imm_getYPEntry(func));
     }
     else
     {
         // using an abstract baseType
         YPEntry.BaseClass baseType = _yctx._BaseType[className];
         foreach (YFunctionType subClassType in _fnByType.Values)
         {
             try {
                 YPEntry yp = subClassType.imm_getYPEntry(func);
                 if (yp.getBaseClass().Equals(baseType))
                 {
                     return(yp);
                 }
             } catch (YAPI_Exception) {
             }
         }
     }
     throw new YAPI_Exception(YAPI.DEVICE_NOT_FOUND, "No function of type " + className + " found");
 }