// Remove a device from YAPI after an unplug detected by device refresh internal virtual void imm_forgetDevice(string serial) { YDevice dev = _devs[serial]; if (dev == null) { return; } string lname = dev.imm_getLogicalName(); _devs.Remove(serial); if (_snByName.ContainsKey(lname) && _snByName[lname].Equals(serial)) { _snByName.Remove(lname); } YFunctionType module = _fnByType["Module"]; module.imm_forgetFunction(serial + ".module"); int count = dev.imm_functionCount(); for (int i = 0; i < count; i++) { YPEntry yp = dev.imm_getYPEntryFromOfs(i); if (_fnByType.ContainsKey(yp.Classname)) { YFunctionType functionType = _fnByType[yp.Classname]; functionType.imm_forgetFunction(yp.HardwareId); } } }
// Reindex a device in YAPI after a name change detected by device refresh internal virtual void imm_reindexDevice(YDevice dev) { string serial = dev.imm_getSerialNumber(); string lname = dev.imm_getLogicalName(); _devs[serial] = dev; if (!lname.Equals("")) { _snByName[lname] = serial; } YFunctionType module = _fnByType["Module"]; YPEntry moduleYPEntry = dev.ModuleYPEntry; module.imm_reindexFunction(moduleYPEntry); int count = dev.imm_functionCount(); for (int i = 0; i < count; i++) { YPEntry yp = dev.imm_getYPEntryFromOfs(i); string classname = yp.Classname; YFunctionType functionType; if (_fnByType.ContainsKey(classname)) { functionType = _fnByType[classname]; } else { functionType = new YFunctionType(classname, _yctx); _fnByType[classname] = functionType; } functionType.imm_reindexFunction(yp); } }
// 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); } }
// Set a function advertised value by hardware id internal virtual void imm_setFunctionValue(string hwid, string pubval) { string classname = YAPIContext.imm_functionClass(hwid); YFunctionType fnByType = imm_getFnByType(classname); fnByType.imm_setFunctionValue(hwid, pubval); }
private YFunctionType imm_getFnByType(string className) { if (!_fnByType.ContainsKey(className)) { _fnByType[className] = new YFunctionType(className, _yctx); } return(_fnByType[className]); }
internal virtual void imm_reindexYellowPages(Dictionary <string, List <YPEntry> > yellowPages) { // reindex all Yellow pages foreach (string classname in yellowPages.Keys) { YFunctionType ftype = imm_getFnByType(classname); List <YPEntry> ypEntries = yellowPages[classname]; foreach (YPEntry yprec in ypEntries) { ftype.imm_reindexFunction(yprec); } } }
// 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); } }
internal virtual void imm_reset() { _fnByType["Module"] = new YFunctionType("Module", _yctx); }