예제 #1
0
        private void Download_attempt(System.Windows.Forms.ProgressBar progress)
        {
            float[] floatRange;

            //Connect
            TcpClient client = new TcpClient(_IP, 502);

            client.ReceiveTimeout = 1000;
            ModbusIpMaster master     = ModbusIpMaster.CreateIp(client);
            OmniIpMaster   omniMaster = new OmniIpMaster(master);

            _SN = omniMaster.ReadString(14099, 1);

            _general24.ID            = omniMaster.ReadString(4836, 1);
            _general24.location      = omniMaster.ReadString(4842, 5);
            _general24.company       = omniMaster.ReadString(4837, 5);
            _general24.dateFormat    = omniMaster.ReadInt16(3842, 1)[0];
            _general24.sysDate       = omniMaster.ReadString(4847, 1);
            _general24.sysTime       = omniMaster.ReadString(4848, 1);
            _general24.volUnit       = omniMaster.ReadInt16(3097, 1)[0];
            _general24.pressUnit     = omniMaster.ReadInt16(13071, 1)[0];
            _general24.atmPressure   = omniMaster.ReadFloat(7891, 1)[0];
            _general24.roll          = omniMaster.ReadInt16(3098, 1)[0];
            _general24.volDecPlaces  = omniMaster.ReadInt16(13386, 1)[0];
            _general24.massDecPlaces = omniMaster.ReadInt16(13388, 1)[0];
            //progressBar
            progress.Value = 8;

            for (ushort i = 0; i < 4; i++)
            {
                _flowmeterPulse[i].IOpoint       = omniMaster.ReadInt16((ushort)(13001 + 13 * i), 1)[0];
                _flowmeterPulse[i].ID            = omniMaster.ReadString((ushort)(4114 + 100 * i), 1);
                _flowmeterPulse[i].model         = omniMaster.ReadString((ushort)(4113 + 100 * i), 1);
                _flowmeterPulse[i].size          = omniMaster.ReadString((ushort)(4112 + 100 * i), 1);
                _flowmeterPulse[i].SN            = omniMaster.ReadString((ushort)(4111 + 100 * i), 1);
                _flowmeterPulse[i].grossFS       = omniMaster.ReadFloat((ushort)(17176 + 4 * i), 1)[0];
                _flowmeterPulse[i].massFS        = omniMaster.ReadFloat((ushort)(17177 + 4 * i), 1)[0];
                _flowmeterPulse[i].lowLimit      = omniMaster.ReadFloat((ushort)(7161 + 100 * i), 1)[0];
                _flowmeterPulse[i].highLimit     = omniMaster.ReadFloat((ushort)(7162 + 100 * i), 1)[0];
                _flowmeterPulse[i].activeFreq    = omniMaster.ReadInt16((ushort)(3106 + 100 * i), 1)[0];
                _flowmeterPulse[i].alarmInactive = omniMaster.ReadInt16((ushort)(13437 + i), 1)[0];
                _flowmeterPulse[i].pulseFidelity = omniMaster.ReadInt16((ushort)(13413 + 13 * i), 1)[0];
                _flowmeterPulse[i].kFactor       = omniMaster.ReadFloat((ushort)(17501 + 100 * i), 12);
                _flowmeterPulse[i].freq          = omniMaster.ReadInt16((ushort)(3122 + 100 * i), 12);

                floatRange = omniMaster.ReadFloat((ushort)(7163 + 100 * i), 15);

                _temperature[i].IOpoint       = omniMaster.ReadInt16((ushort)(13002 + 13 * i), 1)[0];
                _temperature[i].tag           = omniMaster.ReadString((ushort)(4117 + 100 * i), 1);
                _temperature[i].type          = omniMaster.ReadString((ushort)(13003 + 13 * i), 1);
                _temperature[i].lowAlarm      = floatRange[0];
                _temperature[i].highAlarm     = floatRange[1];
                _temperature[i].overrideCode  = omniMaster.ReadInt16((ushort)(3101 + 100 * i), 1)[0];
                _temperature[i].overrideValue = floatRange[2];
                _temperature[i].zeroScale     = floatRange[3];
                _temperature[i].fullScale     = floatRange[4];

                _pressure[i].IOpoint       = omniMaster.ReadInt16((ushort)(13004 + 13 * i), 1)[0];
                _pressure[i].tag           = omniMaster.ReadString((ushort)(4118 + 100 * i), 1);
                _pressure[i].lowAlarm      = floatRange[5];
                _pressure[i].highAlarm     = floatRange[6];
                _pressure[i].overrideCode  = omniMaster.ReadInt16((ushort)(3102 + 100 * i), 1)[0];
                _pressure[i].overrideValue = floatRange[7];
                _pressure[i].zeroScale     = floatRange[8];
                _pressure[i].fullScale     = floatRange[9];

                _density[i].IOpoint       = omniMaster.ReadInt16((ushort)(13005 + 13 * i), 1)[0];
                _density[i].tag           = omniMaster.ReadString((ushort)(4119 + 100 * i), 1);
                _density[i].lowAlarm      = floatRange[10];
                _density[i].highAlarm     = floatRange[11];
                _density[i].overrideCode  = omniMaster.ReadInt16((ushort)(3102 + 100 * i), 1)[0];
                _density[i].overrideValue = floatRange[12];
                _density[i].zeroScale     = floatRange[13];
                _density[i].fullScale     = floatRange[14];
                progress.Increment(4);
            }

            for (ushort j = 0; j < 12; j++)
            {
                _product24[j].name = omniMaster.ReadString((ushort)(4820 + j), 1);
                _product24[j].MF   = new Int32[4];
                for (ushort i = 0; i < 4; i++)
                {
                    _product24[j].MF[i] = omniMaster.ReadInt32((ushort)(5121 + 100 * i + j), 1)[0];
                }
                _product24[j].algorithm          = omniMaster.ReadInt16((ushort)(3813 + j), 1)[0];
                _product24[j].refDensityOverride = omniMaster.ReadFloat((ushort)(7822 + j), 1)[0];
                _product24[j].refTemperature     = omniMaster.ReadFloat((ushort)(17219 + j), 1)[0];
                progress.Increment(1);
            }
            //progressBar
            progress.Value = 32;

            _prover.type            = omniMaster.ReadInt16(3921, 1)[0];
            _prover.volume          = omniMaster.ReadFloat(7919, 1)[0];
            _prover.runsToAverage   = omniMaster.ReadInt16(3913, 1)[0];
            _prover.maxRuns         = omniMaster.ReadInt16(3914, 1)[0];
            _prover.basedOn         = omniMaster.ReadInt16(3928, 1)[0];
            _prover.repeatability   = omniMaster.ReadFloat(7927, 1)[0];
            _prover.autoImplementMF = omniMaster.ReadInt16(3922, 1)[0];
            _prover.maxDeviation    = omniMaster.ReadFloat(7928, 1)[0];
            //progressBar
            progress.Value = 40;

            //statements
            _statments.boolStatment = new string[64];
            _statments.boolRemark   = new string[64];
            _statments.varStatment  = new string[64];
            _statments.varRemark    = new string[64];
            for (ushort i = 0; i < 48; i++)
            {
                _statments.boolStatment[i] = omniMaster.ReadString((ushort)(14001 + i), 1);
                _statments.boolRemark[i]   = omniMaster.ReadString((ushort)(14101 + i), 1);
                _statments.varStatment[i]  = omniMaster.ReadString((ushort)(14051 + i), 1);
                _statments.varRemark[i]    = omniMaster.ReadString((ushort)(14151 + i), 1);
            }
            for (ushort i = 0; i < 16; i++)
            {
                _statments.boolStatment[i + 48] = omniMaster.ReadString((ushort)(14201 + i), 1);
                _statments.boolRemark[i + 48]   = omniMaster.ReadString((ushort)(14241 + i), 1);
                _statments.varStatment[i + 48]  = omniMaster.ReadString((ushort)(14221 + i), 1);
                _statments.varRemark[i + 48]    = omniMaster.ReadString((ushort)(14261 + i), 1);
            }
            //progressBar
            progress.Value = 63;//complete
        }
예제 #2
0
        private void Download_attempt(System.Windows.Forms.ProgressBar progress)
        {
            float[] floatRange;
            //progress bar
            //Form1 popForm = new Form1();
            //popForm.Show();
            //Connect

            TcpClient client = new TcpClient(_IP, 502);

            client.ReceiveTimeout = 1000;
            ModbusIpMaster master     = ModbusIpMaster.CreateIp(client);
            OmniIpMaster   omniMaster = new OmniIpMaster(master);

            _SN = omniMaster.ReadString(14099, 1);

            _general27.ID              = omniMaster.ReadString(4836, 1);
            _general27.location        = omniMaster.ReadString(4842, 5);
            _general27.company         = omniMaster.ReadString(4837, 5);
            _general27.dateFormat      = omniMaster.ReadInt16(3842, 1)[0];
            _general27.sysDate         = omniMaster.ReadString(4847, 1);
            _general27.sysTime         = omniMaster.ReadString(4848, 1);
            _general27.DPUnit          = omniMaster.ReadInt16(13072, 1)[0];
            _general27.pressUnit       = omniMaster.ReadInt16(13071, 1)[0];
            _general27.atmPressure     = omniMaster.ReadFloat(7891, 1)[0];
            _general27.roll            = omniMaster.ReadInt16(3098, 1)[0];
            _general27.grossDecPlaces  = omniMaster.ReadInt16(13386, 1)[0];
            _general27.netDecPlaces    = omniMaster.ReadInt16(13387, 1)[0];
            _general27.massDecPlaces   = omniMaster.ReadInt16(13388, 1)[0];
            _general27.energyDecPlaces = omniMaster.ReadInt16(13389, 1)[0];
            //progress bar
            progress.Value = 4;

            for (ushort i = 0; i < 4; i++)
            {
                _flowmenterType[i] = omniMaster.ReadInt16((ushort)(3108 + 100 * i), 1)[0];
                if (_flowmenterType[i] == 1) //if type = pulse
                {
                    _flowmeterPulse[i].IOpoint       = omniMaster.ReadInt16((ushort)(13001 + 13 * i), 1)[0];
                    _flowmeterPulse[i].ID            = omniMaster.ReadString((ushort)(4114 + 100 * i), 1);
                    _flowmeterPulse[i].model         = omniMaster.ReadString((ushort)(4113 + 100 * i), 1);
                    _flowmeterPulse[i].size          = omniMaster.ReadString((ushort)(4112 + 100 * i), 1);
                    _flowmeterPulse[i].SN            = omniMaster.ReadString((ushort)(4111 + 100 * i), 1);
                    _flowmeterPulse[i].grossFS       = omniMaster.ReadFloat((ushort)(17176 + 4 * i), 1)[0];
                    _flowmeterPulse[i].massFS        = omniMaster.ReadFloat((ushort)(17177 + 4 * i), 1)[0];
                    _flowmeterPulse[i].lowLimit      = omniMaster.ReadFloat((ushort)(7161 + 100 * i), 1)[0];
                    _flowmeterPulse[i].highLimit     = omniMaster.ReadFloat((ushort)(7162 + 100 * i), 1)[0];
                    _flowmeterPulse[i].activeFreq    = omniMaster.ReadInt16((ushort)(3106 + 100 * i), 1)[0];
                    _flowmeterPulse[i].alarmInactive = omniMaster.ReadInt16((ushort)(13437 + i), 1)[0];
                    _flowmeterPulse[i].pulseFidelity = omniMaster.ReadInt16((ushort)(13413 + 13 * i), 1)[0];
                    _flowmeterPulse[i].kFactor       = omniMaster.ReadFloat((ushort)(17501 + 100 * i), 12);
                    _flowmeterPulse[i].freq          = omniMaster.ReadInt16((ushort)(3122 + 100 * i), 12);
                }
                if (_flowmenterType[i] == 0 || _flowmenterType[i] == 2) //if type = DP
                {
                    _flowmeterDP[i].DPlowIOpoint  = omniMaster.ReadInt16((ushort)(13011 + 13 * i), 1)[0];
                    _flowmeterDP[i].DPmidIOpoint  = omniMaster.ReadInt16((ushort)(13059 + i), 1)[0];
                    _flowmeterDP[i].DPhighIOpoint = omniMaster.ReadInt16((ushort)(13012 + 13 * i), 1)[0];
                    _flowmeterDP[i].ID            = omniMaster.ReadString((ushort)(4114 + 100 * i), 1);
                    _flowmeterDP[i].model         = omniMaster.ReadString((ushort)(4113 + 100 * i), 1);
                    _flowmeterDP[i].size          = omniMaster.ReadString((ushort)(4112 + 100 * i), 1);
                    _flowmeterDP[i].SN            = omniMaster.ReadString((ushort)(4111 + 100 * i), 1);
                    _flowmeterDP[i].grossFS       = omniMaster.ReadFloat((ushort)(17176 + 4 * i), 1)[0];
                    _flowmeterDP[i].massFS        = omniMaster.ReadFloat((ushort)(17177 + 4 * i), 1)[0];
                    _flowmeterDP[i].lowLimit      = omniMaster.ReadFloat((ushort)(7161 + 100 * i), 1)[0];
                    _flowmeterDP[i].highLimit     = omniMaster.ReadFloat((ushort)(7162 + 100 * i), 1)[0];

                    _flowmeterDP[i].dpLowTag       = omniMaster.ReadString((ushort)(4115 + 100 * i), 1);
                    _flowmeterDP[i].dpLowZeroScale = omniMaster.ReadFloat((ushort)(7155 + 100 * i), 1)[0];
                    _flowmeterDP[i].dpLowFullScale = omniMaster.ReadFloat((ushort)(7156 + 100 * i), 1)[0];

                    _flowmeterDP[i].dpMidTag       = omniMaster.ReadString((ushort)(4128 + 100 * i), 1);
                    _flowmeterDP[i].dpMidZeroScale = omniMaster.ReadFloat((ushort)(17400 + 2 * i), 1)[0];
                    _flowmeterDP[i].dpMidFullScale = omniMaster.ReadFloat((ushort)(17401 + 2 * i), 1)[0];

                    _flowmeterDP[i].dpHighTag       = omniMaster.ReadString((ushort)(4116 + 100 * i), 1);
                    _flowmeterDP[i].dpHighZeroScale = omniMaster.ReadFloat((ushort)(7157 + 100 * i), 1)[0];
                    _flowmeterDP[i].dpHighFullScale = omniMaster.ReadFloat((ushort)(7158 + 100 * i), 1)[0];

                    _flowmeterDP[i].overrideCode  = omniMaster.ReadInt16((ushort)(3109 + 100 * i), 1)[0];
                    _flowmeterDP[i].overrideValue = omniMaster.ReadFloat((ushort)(7154 + 100 * i), 1)[0];
                    _flowmeterDP[i].lowAlarm      = omniMaster.ReadFloat((ushort)(7152 + 100 * i), 1)[0];
                    _flowmeterDP[i].highAlarm     = omniMaster.ReadFloat((ushort)(7153 + 100 * i), 1)[0];
                    _flowmeterDP[i].switchHigh    = omniMaster.ReadFloat((ushort)(7159 + 100 * i), 1)[0];
                    _flowmeterDP[i].switchLow     = omniMaster.ReadFloat((ushort)(7160 + 100 * i), 1)[0];

                    _flowmeterDP[i].orificeDiam    = omniMaster.ReadFloat((ushort)(7145 + 100 * i), 1)[0];
                    _flowmeterDP[i].orificeExpCoef = omniMaster.ReadFloat((ushort)(7146 + 100 * i), 1)[0];
                    _flowmeterDP[i].orificeRefTemp = omniMaster.ReadFloat((ushort)(7147 + 100 * i), 1)[0];

                    _flowmeterDP[i].pipeDiam    = omniMaster.ReadFloat((ushort)(7148 + 100 * i), 1)[0];
                    _flowmeterDP[i].pipeExpCoef = omniMaster.ReadFloat((ushort)(7149 + 100 * i), 1)[0];
                    _flowmeterDP[i].pipeRefTemp = omniMaster.ReadFloat((ushort)(7150 + 100 * i), 1)[0];

                    _flowmeterDP[i].deviceType = omniMaster.ReadInt16((ushort)(3112 + 100 * i), 1)[0];
                }

                floatRange = omniMaster.ReadFloat((ushort)(7163 + 100 * i), 15);

                _temperature[i].IOpoint       = omniMaster.ReadInt16((ushort)(13002 + 13 * i), 1)[0];
                _temperature[i].tag           = omniMaster.ReadString((ushort)(4117 + 100 * i), 1);
                _temperature[i].type          = omniMaster.ReadString((ushort)(13003 + 13 * i), 1);
                _temperature[i].lowAlarm      = floatRange[0];
                _temperature[i].highAlarm     = floatRange[1];
                _temperature[i].overrideCode  = omniMaster.ReadInt16((ushort)(3101 + 100 * i), 1)[0];
                _temperature[i].overrideValue = floatRange[2];
                _temperature[i].zeroScale     = floatRange[3];
                _temperature[i].fullScale     = floatRange[4];

                _pressure[i].IOpoint       = omniMaster.ReadInt16((ushort)(13004 + 13 * i), 1)[0];
                _pressure[i].tag           = omniMaster.ReadString((ushort)(4118 + 100 * i), 1);
                _pressure[i].lowAlarm      = floatRange[5];
                _pressure[i].highAlarm     = floatRange[6];
                _pressure[i].overrideCode  = omniMaster.ReadInt16((ushort)(3102 + 100 * i), 1)[0];
                _pressure[i].overrideValue = floatRange[7];
                _pressure[i].zeroScale     = floatRange[8];
                _pressure[i].fullScale     = floatRange[9];
            }
            //progress bar
            progress.Value = 24;

            for (ushort j = 0; j < 4; j++)
            {
                _product27[j].type           = omniMaster.ReadInt16((ushort)(3813 + j), 1)[0];
                _product27[j].name           = omniMaster.ReadString((ushort)(4820 + j), 1);
                _product27[j].viscosity      = omniMaster.ReadFloat((ushort)(17251 + 30 * j), 1)[0];
                _product27[j].isoentropicExp = omniMaster.ReadFloat((ushort)(17252 + 30 * j), 1)[0];
                _product27[j].heatingValue   = omniMaster.ReadFloat((ushort)(17253 + 30 * j), 1)[0];
                _product27[j].relativeDens   = omniMaster.ReadFloat((ushort)(17254 + 30 * j), 1)[0];
                _product27[j].densMethod     = omniMaster.ReadInt16((ushort)(3817 + j), 1)[0];

                _product27[j].cromathography = new float[22];
                for (ushort element = 0; element < 21; element++)
                {
                    _product27[j].cromathography[element] = omniMaster.ReadFloat((ushort)(17230 + element + 30 * j), 1)[0];
                }
                _product27[j].cromathography[21] = omniMaster.ReadFloat((ushort)(17258 + 30 * j), 1)[0]; //neo-pentane
                progress.Increment(4);
            }

            //statements

            _statments.boolStatment = new string[64];
            _statments.boolRemark   = new string[64];
            _statments.varStatment  = new string[64];
            _statments.varRemark    = new string[64];
            for (ushort i = 0; i < 48; i++)
            {
                _statments.boolStatment[i] = omniMaster.ReadString((ushort)(14001 + i), 1);
                _statments.boolRemark[i]   = omniMaster.ReadString((ushort)(14101 + i), 1);
                _statments.varStatment[i]  = omniMaster.ReadString((ushort)(14051 + i), 1);
                _statments.varRemark[i]    = omniMaster.ReadString((ushort)(14151 + i), 1);
            }
            for (ushort i = 0; i < 16; i++)
            {
                _statments.boolStatment[i + 48] = omniMaster.ReadString((ushort)(14201 + i), 1);
                _statments.boolRemark[i + 48]   = omniMaster.ReadString((ushort)(14241 + i), 1);
                _statments.varStatment[i + 48]  = omniMaster.ReadString((ushort)(14221 + i), 1);
                _statments.varRemark[i + 48]    = omniMaster.ReadString((ushort)(14261 + i), 1);
            }
            //progress bar
            progress.Value = 63; //complete
            //popForm.Close();
        }