/// <summary> /// returns connection Variable which corresponds to given module /// </summary> /// <param name="targetModule"></param> /// <returns></returns> public NoNextVar getConnectionToModule(Module targetModule) { NoNextVar result = null; foreach (var connection in connections) { if (connection.Name.Equals(SMVPreFix.getConnectionVar(targetModule))) { result = connection; break; } } return(result); }
private static List <NoNextVar> generateConnectionVariable(KPsystem kpSystem, MType kpType, Module module) { List <NoNextVar> connections = new List <NoNextVar>(); foreach (MType mType in kpSystem.Types) { NoNextVar connection = new NoNextVar(SMVPreFix.getConnectionVar(mType)); connection.Behaviour = VariableBehaviour.CUSTOM; SEnum connEnums = new SEnum(); HashSet <Instance> connectedTo = new HashSet <Instance>(); foreach (var connectedInstance in module.Instance.ConnectedTo) { // if it has connection if (connectedInstance.Module.Type == mType.Name) { bool communicationRuleToTargetExist = communicationRuleIncludesTargetType(kpType, mType); if (communicationRuleToTargetExist) { connectedTo.Add(connectedInstance); } } } //if there is more than one connection of same type compartments exists, then add it to connections if (connectedTo.Count > 1) { //sort them IEnumerable <Instance> orderedConns = connectedTo.OrderBy(instance => instance.Name); foreach (var connectedInstance in orderedConns) { connEnums.Values.Add(SMVPreFix.getConnectedTo(connectedInstance)); } connection.Type = connEnums; // connection.Init = setOrUpdateInit(module, connection); Commented out, since no need to get from parameter. connections.Add(connection); } } return(connections); }