static Task GenerateVirtual(DefinitionCollection definitions, C32n pointStructures, Dictionary <string, DeviceCollection> deviceLists) { return(Task.Run(() => { var virt = definitions.Where(z => z.Value.Virtual); if (virt.Count() == 0) { return; } log4net.ThreadContext.Properties["datablock"] = "Virtual"; List <CimplicityPointStructure> points = new List <CimplicityPointStructure>(); foreach (var d in virt) { var device = deviceLists.SelectMany(x => x.Value.Where(z => z.VirtualType?.Equals(d.Value.Name) ?? false)); if (device.Count() == 0) { logger.Warn($"Nenalezeno zadne zarizeni k definici {d.Value.Name}"); continue; } foreach (var singledevice in device) { foreach (var pd in d.Value.Points) { var ps = pointStructures.Get(pd.PointType); if (ps == null) { logger.Error($"Nenalezena zadna struktura pointu typu {pd.PointType}. Definice={d.Value.Name}"); continue; } points.Add(createPoint(pd, d.Value, ps, singledevice)); } } } ToCsv(points, Location + $@"\virtual.txt"); })); }
static Task Generate(DbClass db, DefinitionCollection definitions, C32n pointStructures, Dictionary <string, DeviceCollection> deviceLists) { return(Task.Run(() => { log4net.ThreadContext.Properties["datablock"] = db.Name; List <CimplicityPointStructure> points = new List <CimplicityPointStructure>(); foreach (DbStructure i in db.Structure.Children) { var dl = definitions.Get(i); if (dl == null || dl.Count == 0) { logger.Error($"Nenalezena zadna definice pointu pro DB{db.Number}.{i.Address}. Symbol={i.Name}, Comment={i.Comment}"); continue; } foreach (var d in dl) { foreach (var pd in d.Points) { var ps = pointStructures.Get(pd.PointType); if (ps == null) { logger.Error($"Nenalezena zadna struktura pointu typu {pd.PointType} pro DB{db.Number}.{i.Address}. Symbol={i.Name}, Comment={i.Comment}. Definice={d.Name}"); continue; } var point = createPoint(db, i, pd, d, ps, deviceLists); if (point != null) { points.Add(point); } } } } ToCsv(points, Location + $@"\{db.Name}.txt"); })); }