public static void BuildBlind() // Построение состояний лампочек { // вычислим примерные размеры массива SortedList <string, int> sl = null; sl = new SortedList <string, int>(Server.Count); Context con = null; con = Server.getContext(Server.PointVariables); for (int i = 0; i < con.Count; i++) { int index = con.getChaild(i); Context var = Server.getContext(index); sl.Add(var.Name, index); } con = Server.getContext(Server.PointModels); for (int i = 0; i < con.Count; i++) { int index = con.getChaild(i); Context var = Server.getContext(index); sl.Add(var.Name, index); } con = Server.getContext(Server.PointConstants); for (int i = 0; i < con.Count; i++) { int index = con.getChaild(i); Context var = Server.getContext(index); sl.Add(var.Name, index); } DateTime tm = DateTime.Now; long bazatime = tm.Ticks; for (int i = 0; i < defBlind.Count; i++) { int numFunction; SmallBlind sBl = defBlind[i]; string name = "Blind" + string.Format("{0:0000}", i); string description = sBl.nameFunction + "( "; for (int j = 0; j < sBl.nameParamIn.Count; j++) { description += j == 0 ? "" : ","; description += sBl.nameParamIn[j] + " in"; if (sBl.ups[j]) { description += " up"; } } for (int j = 0; j < sBl.nameParamOut.Count; j++) { description += "," + sBl.nameParamOut[j] + " out"; } description += " )"; numFunction = Function.NameToInt(sBl.nameFunction); if (numFunction < 0) { Util.errorMessage("Отсутствует функция ", description); Util.work = false; } Blind BL = new Blind(numFunction, sBl.onstart); if (sBl.steptimer > 0) { BL.setOnTimer(bazatime, sBl.steptimer); } for (int j = 0; j < sBl.nameParamIn.Count; j++) { int ip = sl.IndexOfKey(sBl.nameParamIn[j]); if (ip < 0) { Util.errorMessage("Нет " + sBl.nameParamIn[j], description); Util.work = false; ip = 1; } else { ip = sl[sBl.nameParamIn[j]]; if (sBl.ups[j]) { Context cont = Server.getContext(ip); Variable var = (Variable)cont.defContext; if (var != null) { var.appendReference(Server.Count); var.blinds.Add(Server.Count); Server.setContext(ip, cont); } } else { Context cont = Server.getContext(ip); Variable var = (Variable)cont.defContext; var.blinds.Add(Server.Count); Server.setContext(ip, cont); } BL.listParamIn.Add(ip); } } for (int j = 0; j < sBl.nameParamOut.Count; j++) { int ip = sl.IndexOfKey(sBl.nameParamOut[j]); if (ip < 0) { Util.errorMessage("Нет " + sBl.nameParamIn[j], description); Util.work = false; ip = 1; } else { ip = sl[sBl.nameParamOut[j]]; Context cont = Server.getContext(ip); Variable var = (Variable)cont.defContext; var.blinds.Add(Server.Count); Server.setContext(ip, cont); BL.listParamOut.Add(ip); } } if (!Function.isCorrect(numFunction, BL.listParamIn, BL.listParamOut)) { Util.errorMessage("Ошибки в параметрах вызова ", description); Util.work = false; } ; Blind.appendBlind(name, description, BL); Util.message(name + " " + description + " добавлено "); } sl = null; }