private string GenerateDplCDisplayParameters(ControllerModel controller) { var sb = new StringBuilder(); sb.AppendLine("void display_parameters(void)"); sb.AppendLine("{"); sb.AppendLine($"{ts}/* fasecycli */"); sb.AppendLine($"{ts}/* --------- */"); foreach (var fcm in controller.Fasen) { sb.Append(GetCoordinatesString(fcm, fcm.GetDefine(), "us")); } sb.AppendLine(); sb.AppendLine($"{ts}/* detectie */"); sb.AppendLine($"{ts}/* -------- */"); var ovdummydets = controller.PrioData.GetAllDummyDetectors(); var alldets = controller.GetAllDetectors().Concat(ovdummydets); foreach (var dm in alldets.Where(x => !x.Dummy)) { sb.Append(GetCoordinatesString(dm, dm.GetDefine(), "is")); } if (alldets.Any(x => x.Dummy)) { sb.AppendLine("#if (!defined AUTOMAAT_TEST)"); foreach (var dm in alldets.Where(x => x.Dummy)) { sb.Append(GetCoordinatesString(dm, dm.GetDefine(), "is")); } sb.AppendLine("#endif"); } sb.AppendLine(); sb.AppendLine($"{ts}/* overige uitgangen */"); sb.AppendLine($"{ts}/* ----------------- */"); foreach (var item in AllCCOLOutputElements.Where(x => !x.Dummy)) { if (item.Element != null) { sb.Append(GetCoordinatesString(item.Element, item.Naam, "us")); } } foreach (var item in AllOutputModelElements.Where(x => !x.Dummy)) { sb.Append(GetCoordinatesString(item, _uspf + item.Naam, "us")); } if (AllCCOLOutputElements.Any(x => x.Dummy) || AllOutputModelElements.Any(x => x.Dummy)) { sb.AppendLine("#if (!defined AUTOMAAT_TEST)"); } if (AllCCOLOutputElements.Any(x => x.Dummy)) { foreach (var item in AllCCOLOutputElements.Where(x => x.Dummy)) { if (item.Element != null) { sb.Append(GetCoordinatesString(item.Element, item.Naam, "us")); } } } if (AllOutputModelElements.Any(x => x.Dummy)) { foreach (var item in AllOutputModelElements.Where(x => x.Dummy)) { sb.Append(GetCoordinatesString(item, _uspf + item.Naam, "us")); } } if (AllCCOLOutputElements.Any(x => x.Dummy) || AllOutputModelElements.Any(x => x.Dummy)) { sb.AppendLine("#endif"); } sb.AppendLine(); sb.AppendLine($"{ts}/* overige ingangen */"); sb.AppendLine($"{ts}/* ---------------- */"); foreach (var item in AllCCOLInputElements.Where(x => !x.Dummy)) { if (item.Element != null) { sb.Append(GetCoordinatesString(item.Element, item.Naam, "is")); } } foreach (var item in AllInputModelElements.Where(x => !x.Dummy)) { sb.Append(GetCoordinatesString(item, _ispf + item.Naam, "is")); } if (AllCCOLInputElements.Any(x => x.Dummy) || AllInputModelElements.Any(x => x.Dummy)) { sb.AppendLine("#if (!defined AUTOMAAT_TEST)"); } if (AllCCOLInputElements.Any(x => x.Dummy)) { foreach (var item in AllCCOLInputElements.Where(x => x.Dummy)) { if (item.Element != null) { sb.Append(GetCoordinatesString(item.Element, item.Naam, "is")); } } } if (AllInputModelElements.Any(x => x.Dummy)) { foreach (var item in AllInputModelElements.Where(x => x.Dummy)) { sb.Append(GetCoordinatesString(item, _ispf + item.Naam, "is")); } } if (AllCCOLInputElements.Any(x => x.Dummy) || AllInputModelElements.Any(x => x.Dummy)) { sb.AppendLine("#endif"); } sb.AppendLine(); sb.AppendLine($"{ts}/* Gebruikers toevoegingen file includen */"); sb.AppendLine($"{ts}/* ------------------------------------- */"); sb.AppendLine($"{ts}#include \"{controller.Data.Naam}dpl.add\""); sb.AppendLine(); sb.AppendLine("}"); return(sb.ToString()); }
private string GenerateTabCControlParametersIOTypes(ControllerModel c) { var sb = new StringBuilder(); sb.AppendLine("/* Typen ingangen */"); sb.AppendLine("/* -------------- */"); var ds = new List <string>(); DetectorTypeEnum prev = DetectorTypeEnum.Kop; foreach (DetectorModel dm in c.GetAllDetectors()) { if (c.Data.CCOLVersie >= CCOLVersieEnum.CCOL9) { if (prev != DetectorTypeEnum.VecomDetector && (dm.Type == DetectorTypeEnum.VecomDetector || dm.Type == DetectorTypeEnum.OpticomIngang)) { sb.AppendLine("#ifndef NO_CVN_50"); } if ((prev == DetectorTypeEnum.VecomDetector || prev == DetectorTypeEnum.OpticomIngang) && dm.Type != DetectorTypeEnum.VecomDetector) { sb.AppendLine("#else"); foreach (var d in ds) { sb.AppendLine($"{ts}IS_type[{_dpf}{d}] = DS_type;"); } ds.Clear(); sb.AppendLine("#endif"); } } sb.Append($"{ts}IS_type[{_dpf}{dm.Naam}] = "); switch (dm.Type) { case DetectorTypeEnum.Knop: case DetectorTypeEnum.KnopBinnen: case DetectorTypeEnum.KnopBuiten: sb.AppendLine("DK_type;"); break; case DetectorTypeEnum.File: case DetectorTypeEnum.Verweg: sb.AppendLine("DL_type | DVER_type;"); break; case DetectorTypeEnum.Kop: sb.AppendLine("DL_type | DKOP_type;"); break; case DetectorTypeEnum.Lang: sb.AppendLine("DL_type | DLNG_type;"); break; case DetectorTypeEnum.OpticomIngang: case DetectorTypeEnum.VecomDetector: // TODO: it is possible to use DKOP and DVER to mark in- and uitmelding: use? how? if (c.Data.CCOLVersie >= CCOLVersieEnum.CCOL9) { sb.AppendLine("DSI_type;"); ds.Add(dm.Naam); } else { sb.AppendLine("DS_type;"); } break; case DetectorTypeEnum.Overig: sb.AppendLine("DL_type;"); break; case DetectorTypeEnum.WisselStandDetector: case DetectorTypeEnum.WisselDetector: case DetectorTypeEnum.WisselStroomKringDetector: case DetectorTypeEnum.Radar: sb.AppendLine("DL_type | DKOP_type;"); break; default: throw new ArgumentOutOfRangeException("Unknown detector type while generating tab.c: " + dm.Type.ToString()); } prev = dm.Type; } sb.AppendLine(); sb.AppendLine("/* Typen uitgangen */"); sb.AppendLine("/* --------------- */"); foreach (FaseCyclusModel fc in c.Fasen) { sb.Append($"{ts}US_type[{_fcpf}{fc.Naam}] = "); switch (fc.Type) { case Models.Enumerations.FaseTypeEnum.Auto: sb.AppendLine("MVT_type;"); break; case Models.Enumerations.FaseTypeEnum.OV: sb.AppendLine("OV_type;"); break; case Models.Enumerations.FaseTypeEnum.Fiets: sb.AppendLine("FTS_type;"); break; case Models.Enumerations.FaseTypeEnum.Voetganger: sb.AppendLine("VTG_type;"); break; default: throw new ArgumentOutOfRangeException("Unknown vehicle type while generating tab.c: " + fc.Type.ToString()); } } if (c.Data.CCOLVersie > CCOLVersieEnum.CCOL8 && AllCCOLInputElements.Any(x => x.Multivalent)) { sb.AppendLine(); sb.AppendLine($"{ts}/* Multivalente ingangen */"); sb.AppendLine($"#if !defined NO_VLOG_300"); foreach (var i in AllCCOLInputElements.Where(x => x.Multivalent)) { sb.AppendLine($"{ts}IS_type[{i.Naam}] = ISM_type;"); } sb.AppendLine("#endif /* NO_VLOG_300 */"); } if (c.Data.CCOLVersie > CCOLVersieEnum.CCOL8 && AllCCOLOutputElements.Any(x => x.Multivalent)) { sb.AppendLine(); sb.AppendLine($"{ts}/* Multivalente ingangen */"); sb.AppendLine($"#if !defined NO_VLOG_300"); foreach (var i in AllCCOLOutputElements.Where(x => x.Multivalent)) { sb.AppendLine($"{ts}US_type[{i.Naam}] = USM_type;"); } sb.AppendLine("#endif /* NO_VLOG_300 */"); } return(sb.ToString()); }