private bool Connect1751() { try { //присваивание объектам классов InstantDi(о)Ctrl параметров платы, имеющей ID = DeviceNumber PCI_1751.SelectedDevice = new DeviceInformation(Find1751()); PCI_1751.Write(5, 0xFF); //SW-POW (PC14) off //настройка портов на выход/вход PortDirection[] portDirs = PCI_1751.PortDirection; portDirs[5].Direction = DioPortDir.LinHout; //PC10 - input (ZPR), PC14 - output (SW-POW) portDirs[0].Direction = DioPortDir.Input; //Data_0-7 portDirs[1].Direction = DioPortDir.Input; //Data_8-15 portDirs[2].Direction = DioPortDir.LinHout; //PC00 - input (ZPR), PC04 - INIT, PC05 - WA, PC06 - RD, PC07 - WD } catch (Exception) { FormConsole.AppendText("Не удалось сконфигурировать PCI-1751! Проверьте подключение!\n"); FormConsole.ScrollToCaret(); return(false); } return(true); }
public Work_Form(SystemInfoClass sysInfo) { InitializeComponent(); SysInfo = sysInfo; PrepareForm(); if (!Connect1751()) { return; } if (ConnectMOXA()) { START_button.Enabled = true; STOP_button.Enabled = false; FormConsole.AppendText("МПИ подключен.\n"); FormConsole.ScrollToCaret(); } else { START_button.Enabled = false; STOP_button.Enabled = false; FormConsole.AppendText("Проверьте подключение МПИ!\n"); FormConsole.ScrollToCaret(); } }
private void ConsoleWriter(string text, Color color = default(Color)) { FormConsole.Invoke((MethodInvoker) delegate { FormConsole.AppendText(text + "\n"); FormConsole.ScrollToCaret(); if (color == default(Color)) { return; } FormConsole.Select(FormConsole.Text.Length - text.Length - 1, text.Length); FormConsole.SelectionColor = color; FormConsole.Select(FormConsole.Text.Length - 1, 1); FormConsole.ScrollToCaret(); }); }
//вывод в консоль выхода НН по входу public static void consoleRunNN(bool isPrintIn = true) { if (Information.inputSignals.Count == Information.inputSize + (Information.NN.IsBiasNeuron ? 1 : 0)) { List <float> outputSignals = Information.NN.Run(Information.inputSignals, Information.NN.IsBiasNeuron); FormConsole.AppendText("Run Result:\r\n"); int i = 1; if (isPrintIn) { FormConsole.AppendText("input: "); foreach (float signal in Information.inputSignals) { FormConsole.AppendText(i + ") " + signal.ToString() + " "); i++; } FormConsole.AppendText("\r\n"); } i = 1; FormConsole.AppendText("output: "); float max = float.MinValue; int maxInd = -1; foreach (float signal in outputSignals) { if (max < signal) { max = signal; maxInd = i - 1; } FormConsole.AppendText(i + ") " + Math.Round(signal, 4).ToString() + " "); i++; } FormConsole.AppendText("\r\n"); FormConsole.AppendText("Answer Pattern = " + maxInd); FormConsole.AppendText("\r\n"); FormConsole.Scroll(); } else { FormConsole.PrintlnAndScroll("Some Error In Run NN\r\n"); } }