public static void Connect(CancellationToken ct) { if (ControllerNames.LSdebug) { foreach (ControllerListSource cls in IODataCollection.controllerNameList.Where(c => c.name.StartsWith(_name + '-'))) { LSu.Connect(cls.name, int.Parse(cls.IP)); } } else { foreach (ControllerListSource cls in IODataCollection.controllerNameList.Where(c => c.name.StartsWith(_name + '-'))) { try { LSConnect(ct); } catch (Exception e) { throw new Exception(e.Message); } break; } } }
static void LSConnectDetail() { short i = LTDMC.dmc_board_init(); if (i <= 0 || i > 8) { throw new Exception($"雷赛卡初始化错误,返回值:{i}"); } else { ushort _num = 0; ushort[] cardIDs = new ushort[8]; uint[] cardTypes = new uint[8]; short res = LTDMC.dmc_get_CardInfList(ref _num, cardTypes, cardIDs); if (res != 0) { throw new Exception($"雷赛卡无法获取卡信息,错误代码:{res}"); } foreach (ControllerListSource cls in IODataCollection.controllerNameList.Where(c => c.name.StartsWith(_name + '-'))) { string s = string.Join(",", cardIDs).TrimEnd(','); if ((Array.IndexOf(cardIDs, ushort.Parse(cls.IP)) == -1) || ((int.Parse(cls.IP) == 0) && (cardIDs[0] != 0))) { throw new Exception($"雷赛卡卡号不存在:{cls.IP},卡号列表:{s}"); } LSu.Connect(cls.name, int.Parse(cls.IP)); } } }