示例#1
0
        private async Task LoadLinesAsync()
        {
            Lines = new List <ScanLine>();
            var plcs = await _store.GetPlcListAsync();

            var targets = await _store.GetTargetListAsync();

            int iPageSize = 10;

            foreach (var plc in plcs)
            {
                var line = new ScanLine(DataTypeHelper.GetPlcType(plc.CpuType), plc.Ip, plc.Port, plc.Slot, plc.Rack);
                line.PlcId                = plc.Id;
                line.RunHandler          += Line_RunHandler;
                line.StatusChangeHandler += Line_StatusChangeHandler;

                var nomaltgs  = (from u in targets where u.PlcId == plc.Id && u.VarType != 7 select u).ToList();
                var stringtgs = (from u in targets where u.PlcId == plc.Id && u.VarType == 7 select u).ToList();

                RegistReader(line, nomaltgs, iPageSize);
                RegistStringReader(line, stringtgs);
                Lines.Add(line);
                line.Start(1000);
            }
        }