Exemple #1
0
        public List <int[]> getLogs(int startIndexRead)
        {
            modbusClient = ConnectUserControl.getModbusClient();
            List <int[]> RecordNumbers = new List <int[]>();

            if (modbusClient != null && modbusClient.Connected == true)
            {
                try
                {
                    //long OldbestRecordNumber = getOldbestRecordNumber();
                    long NewbestRecordNumber = getNewbestRecordNumber();
                    if (startIndexRead != -1 && NewbestRecordNumber != -1)
                    {
                        modbusClient.WriteMultipleRegisters(1059, ModbusClient.ConvertIntToRegisters(768));
                        for (long i = startIndexRead; i <= NewbestRecordNumber; i++)
                        {
                            int[] numberCurrentWrite = new int[4];
                            numberCurrentWrite = ModbusClient.ConvertLongToRegisters(i);
                            modbusClient.WriteMultipleRegisters(1060, numberCurrentWrite);
                            int[] ArrayLogs = new int[64];
                            ArrayLogs = modbusClient.ReadHoldingRegisters(17344, 64);
                            RecordNumbers.Add(ArrayLogs);
                        }
                    }
                    return(RecordNumbers);
                }
                catch (Exception)
                {
                    Console.WriteLine("Error: Неожиданный обрыв подключения");
                    return(RecordNumbers);//
                }
            }
            else
            {
                return(RecordNumbers);
            }
        }