addInterfacesFromJson method
Creates interfaces based on a JSON input.
The parameters
argument is not currently used, but may be useful in the
future.
Implementation
void addInterfacesFromJson(String instanceName,
Map<String, dynamic> busInterfaces, Map<String, String> parameters) {
for (final MapEntry(key: intfInstName, value: intfInfo)
in busInterfaces.entries) {
intfInfo as Map<String, dynamic>;
final role = _getPairRole(intfInfo['mode'] as String);
final portMapList = intfInfo['portMaps'] != null
? List<Map<String, dynamic>>.from(
intfInfo['portMaps']! as List<dynamic>)
: <Map<String, dynamic>>[];
final allUsedPorts = _getUsedPorts(portMapList);
final thisIntf = getBridgeIntfFromJson(intfMap: intfInfo);
_checkReqPortUsage(thisIntf, allUsedPorts);
final thisIntfRef = addInterface(
thisIntf,
name: intfInstName,
role: role,
connect: false,
);
for (final portMap in portMapList) {
final rtlPortName = portMap['physicalPortName'].toString();
final intfPortName = portMap['logicalPortName'].toString();
final phyPs = portMap['physicalPartSelect'].toString();
final logicalPs = portMap['logicalPartSelect'].toString();
final logPortRef = logicalPs == ''
? intfPortName
: '$intfPortName$logicalPs'.replaceAll(' ', '');
final phyPortRef = phyPs == ''
? rtlPortName
: '$rtlPortName$phyPs'.replaceAll(' ', '');
if (thisIntfRef.interface.tryPort(intfPortName) == null) {
RohdBridgeLogger.logger.error('Port $intfPortName not in interface'
' ${thisIntfRef.interface}');
} else {
addPortMap(port(phyPortRef), thisIntfRef.port(logPortRef));
}
}
}
}