示例#1
0
        public string ReadProbeValue()
        {
            float readvalue;
            short decimalPlaces;

            ReadFloatFromDevice(29061, out readvalue, out decimalPlaces);
            return(DataConverters.ConvertFloatToString(readvalue, decimalPlaces));
        }
示例#2
0
        public string ReadOutputControlValue()
        {
            float readvalue;
            short decimalPlaces;

            ReadFloatFromDevice(29066, out readvalue, 2);
            return(DataConverters.ConvertFloatToString(readvalue, 2));
        }
示例#3
0
        private void ReadFloatFromDevice(short registerAddress, out float value, short decimalPlaces)
        {
            short[] bytes = new short[4];
            var     resp  = modbus.ReadRawData(registerAddress, bytes);

            if (resp == 0)
            {
                value = DataConverters.ConvertInt32ToFloat(DataConverters.ConvertRawDataToInt32(bytes), decimalPlaces);
                return;
            }

            throw new Exception(Common.Errors[resp]);
        }
示例#4
0
        public string SetSetPointValue(string text)
        {
            var floatValue = DataConverters.ConvertInputTextToFloat(text);

            var intValue = DataConverters.ConvertFloatToIntRemovingDecimalPlaces(floatValue, 1);

            byte[] bytesToBeWrite = DataConverters.ExtractBytesFromInt(intValue);
            Array.Resize(ref bytesToBeWrite, 5);
            bytesToBeWrite[4] = 1;

            var shortToBeWrite = DataConverters.ConvertByteArrayToShortArray(bytesToBeWrite);

            var resp = modbus.WriteRawDataToDevice(29044, shortToBeWrite);

            if (resp == 0)
            {
                return(DataConverters.ConvertFloatToString(floatValue, 1));
            }

            throw new Exception(Common.Errors[resp]);
        }