private TelegramContainer createSeries(Task task, int numOfCommands, LastReplyPrecondition[] teleStopPrec, byte[][] teleData, Telegram.Callback callback, bool isGeneralCmd) { TelegramContainer container = new TelegramContainer(); container.clear(); for (int i = 0; i < numOfCommands; i++) { Telegram tele = new Telegram(5) { uniqId = GlobalServices.uniqTelegramId(), parentUniqId = -1, type = TelegramType.Command }; if (_ioph is IOPH_DATA) { tele.protocol = Protocol.DCP2; if (isGeneralCmd) { tele.DCPCmdSet = 0x18; } else { tele.DCPCmdSet = 0x1c; } } else { tele.protocol = Protocol.DCP; tele.DCPCmdSet = 4; } tele.lastReplyPrecondition = teleStopPrec[i]; tele.UserDataExt.addUserData("Task", task); tele.portHandler = _ioph; tele.mainWin = this; tele.clearEventHandler(); tele.CallbackEvent += callback; tele.data.copy(teleData[i]); container.addTelegramContainerItem(new TelegramContainerItem(tele)); } return container; }
private TelegramContainer createSeries(Task task, int numOfCommands, LastReplyPrecondition[] teleStopPrec, byte[][] teleData, Telegram.Callback callback) { TelegramContainer container = new TelegramContainer(); container.clear(); for (int i = 0; i < numOfCommands; i++) { Telegram tele = new Telegram(5) { uniqId = GlobalServices.uniqTelegramId(), parentUniqId = -1, type = TelegramType.Command, protocol = Protocol.DCP, DCPCmdSet = 4, lastReplyPrecondition = teleStopPrec[i], userData = (int) task, portHandler = this._ioph, mainWin = this }; tele.clearEventHandler(); tele.CallbackEvent += callback; tele.data.copy(teleData[i]); if (i == (numOfCommands - 1)) { tele.UserDataExt.addUserData("RetVal", 0); } container.addTelegramContainerItem(new TelegramContainerItem(tele)); } return container; }
private TelegramContainer createSpiCommanSeries(int numOfCommands, byte[][] teleData, Telegram.Callback callback, bool resetChip, bool shutdownChip) { TelegramContainer container = new TelegramContainer(); container.clear(); if (shutdownChip) { foreach (TelegramContainerItem item in createShutdownCommandSeries()) { container.addTelegramContainerItem(item); } return container; } if (resetChip) { foreach (TelegramContainerItem item2 in createResetCommandSeries()) { container.addTelegramContainerItem(item2); } } for (int i = 0; i < numOfCommands; i++) { Telegram tele = new Telegram(5) { uniqId = GlobalServices.uniqTelegramId(), parentUniqId = -1, type = TelegramType.Command, protocol = Protocol.DCP2, DCPCmdSet = 0x1c, portHandler = _ioph, mainWin = this }; tele.clearEventHandler(); tele.CallbackEvent += callback; byte[] buf = new byte[3]; buf[0] = 0x10; tele.data.copy(buf); tele.data.append(teleData[i], teleData[i].Length); tele.UserDataExt.addUserData("SentData", "> " + WDSConverters.ToHexString(teleData[i], teleData[i].Length)); container.addTelegramContainerItem(new TelegramContainerItem(tele)); } return container; }
private TelegramContainer createSeries(Task task, int numOfCommands, byte[][] dcpPrefixCommandSet, byte[][] rfCommandSet, Telegram.Callback callback, bool[] isGeneralCmdIndicatorSet) { try { TelegramContainer container = new TelegramContainer(); container.clear(); for (int i = 0; i < numOfCommands; i++) { Telegram tele = new Telegram(5) { uniqId = GlobalServices.uniqTelegramId(), parentUniqId = -1, type = TelegramType.Command, protocol = Protocol.DCP2 }; if (isGeneralCmdIndicatorSet[i]) { tele.DCPCmdSet = 0x18; } else { tele.DCPCmdSet = 0x1c; } tele.lastReplyPrecondition = LastReplyPrecondition.Indication; tele.UserDataExt.addUserData("Task", task); tele.portHandler = this._ioph; tele.mainWin = this; tele.clearEventHandler(); tele.CallbackEvent += callback; if ((dcpPrefixCommandSet != null) && (dcpPrefixCommandSet.Length >= i)) { tele.data.copy(dcpPrefixCommandSet[i]); } if ((rfCommandSet != null) && (rfCommandSet.Length >= i)) { tele.data.append(rfCommandSet[i], rfCommandSet[i].Length); } container.addTelegramContainerItem(new TelegramContainerItem(tele)); } return container; } catch (Exception exception) { _log.Error("Could not create command series! " + exception.Message); return null; } }
private TelegramContainer createShutdownCommandSeries() { TelegramContainer container = new TelegramContainer(); container.clear(); for (int i = 0; (i < RESET_COMMAND_SET.Length) || (i < 2); i++) { Telegram tele = new Telegram(5) { uniqId = GlobalServices.uniqTelegramId(), parentUniqId = -1, type = TelegramType.Command, protocol = Protocol.DCP2, DCPCmdSet = 0x1c, portHandler = _ioph, mainWin = this }; tele.clearEventHandler(); tele.data.copy(RESET_COMMAND_SET[i]); container.addTelegramContainerItem(new TelegramContainerItem(tele)); } return container; }