private int[] SetValuesStartMeasurements(CounterSystem devices)
        {
            CounterSystem countersSystem = devices;

            int[] numberOfActiveDevices = new int[countersSystem.numberOfSlaveDevices];

            int index = 0;

            foreach (var device in countersSystem.device)
            {
                foreach (var counter in device.counter)
                {
                    if (counter.Active == true)
                    {
                        numberOfActiveDevices[index] = 1;
                        //++numberOfActiveCountersInDevice[index];
                        if (TransferData.IsAllSetCouterParametersOK(counter))
                        {
                            if (!TransferData.SetCounterValues(counter))
                            {
                                MessageBox.Show("Error writing data to device at address: " + device.DeviceAddress + " counter: " + counter.CounterNumber);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Counter parameters are not correct: " + counter.CounterNumber);
                        }
                    }
                }
                if (numberOfActiveDevices[index] == 1)
                {
                    TransferData.DeviceMakeSendReadCommand(device, (byte)ModbusCommand.StartCounters);
                }
                ++index;
            }

            //start devicec
            //Debug.WriteLine(numberOfActiveCountersInDevice);
            return(numberOfActiveDevices);
        }