Пример #1
0
        /// <summary>
        /// Create Decoding Script
        /// </summary>
        /// <param name="goes"></param>
        /// <param name="sensorNumber"></param>
        /// <param name="dataType"></param>
        /// <param name="script"></param>
        /// <returns></returns>
        private static string CreateScript(McfDataSet.goesmcfRow goes, int sensorNumber, string dataType)
        {
            string script = "1p," + goes.S_OFV + "x,";

            int spaceBetween = goes.S_ONV - goes.S_DTSIZE;

            if (spaceBetween == 0)
            {
                script += goes.S_NV.ToString() + "(f(s," + dataType + "," + goes.S_DTSIZE + "," + sensorNumber + "))";
            }
            else
            {
                if (goes.S_NV > 1)
                {
                    script += (goes.S_NV - 1).ToString() + "(f(s," + dataType + "," + goes.S_DTSIZE + "," + sensorNumber + ")," + spaceBetween + "x),";
                }

                script += "f(s," + dataType + "," + goes.S_DTSIZE + "," + sensorNumber + ")";

                if (goes.S_NV == 1)
                {
                    script = "1p," + goes.S_OFV + "x,f(s," + dataType + "," + goes.S_DTSIZE + "," + sensorNumber + ")";
                }
            }
            return(script);
        }
Пример #2
0
        /// <summary>
        /// Scaling, offset, shift, etc.
        /// Done by adding appropirate row to scriptsensor
        /// </summary>
        /// <param name="decodesScriptID"></param>
        /// <param name="sensorNumber"></param>
        /// <param name="goes"></param>
        /// <param name="s"></param>
        internal void AddUnitConverter(int decodesScriptID, int sensorNumber, McfDataSet.goesmcfRow goes, McfDataSet.sitemcfRow s)
        {
            int unitconverterid = GetUnitConverterID(goes, s);

            if (unitconverterid >= 0)
            {
                decodes.scriptsensor.AddscriptsensorRow(decodesScriptID, sensorNumber, unitconverterid);
            }
            else
            {
                Console.WriteLine("did not find unit converter " + goes.GOESDEC);
            }
        }
Пример #3
0
        internal void GetMaxMin(McfDataSet.goesmcfRow goes, out double min, out double max)
        {
            max = 9999999;
            min = 0.0001;
            var rows = (McfDataSet.pcodemcfRow[])mcf.pcodemcf.Select("PCODE ='" + goes.GOESDEC + "'");

            if (rows.Length == 0)
            {
                Logger.WriteLine("Error: could not find '" + goes.GOESDEC + "' in pcode table");
                return;
            }

            if (rows[0].QCSW == 1)
            {
                if (System.Math.Abs(rows[0].QHILIM - 998877) > 0.01)
                {
                    max = rows[0].QHILIM;
                }
                if (System.Math.Abs(rows[0].QHILIM - 998877) > 0.01)
                {
                    min = rows[0].QLOLIM;
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Find appropriate method for to scale, offset, etc
        /// If necessary create entry in unitconverter. Otherwise use
        /// existing unitconverter.
        /// </summary>
        /// <param name="goes"></param>
        /// <returns></returns>
        internal int GetUnitConverterID(McfDataSet.goesmcfRow goes, McfDataSet.sitemcfRow s)
        {
            var rows = (McfDataSet.pcodemcfRow[])mcf.pcodemcf.Select("PCODE ='" + goes.GOESDEC + "'");

            //if( s.SITE.IndexOf("ARNO") >=0 )
            //     Console.WriteLine("");

            if (rows.Length == 0)
            {
                Logger.WriteLine("Error: could not find '" + goes.GOESDEC + "' in pcode table");
                return(-1);
            }


            if (s.CTYPE == "S")
            {
                Logger.WriteLine("Warning <skipping unit conversion>:  Site based processing '" + s.SITE + "'");
                return(-1);
            }

            var pcode = rows[0];



            if (pcode.ACTIVE == 0 || goes.ACTIVE == 0)
            {
                Logger.WriteLine("parameter not active :" + goes.GOESDEC);
                return(-1);
            }

            // DONT' look at goes.RTCNAME ( pcode.RTCPROC is used instead)
            if (!pcode.IsRTCPROCNull() && pcode.RTCPROC.Trim().Replace("\0", "") != "")
            {
                // TO DO  GH_WEIR, GH_WEIRX,
                if (pcode.RTCPROC.ToLower().Trim() == "ch_weir")
                {
                    //Y  =  A*( B*x +C + D )^E
                    //return Weir(pcode.SCALE, 0.01, pcode.OFFSET, pcode.SHIFT,pcode.BASE);
                    return(LinearEquation(0.01, 0, "ft"));
                }
                if (pcode.RTCPROC.ToLower().Trim() == "gh_vshift" || pcode.RTCPROC.ToLower().Trim() == "gh_lim")
                {
                    return(LinearEquation(pcode.SCALE, pcode.OFFSET, "ft"));
                }

                Logger.WriteLine("not implemented Rtcm routine :" + pcode.RTCPROC);
                return(-1);
            }
            string parameterName = goes.GOESDEC.Substring(7).Trim();

            // string siteName = goes.GOESDEC.Substring(0, 8).Trim();

            if (parameterName == "FB" || parameterName == "FB2")
            {
                return(LinearEquation(pcode.SCALE, pcode.OFFSET, "ft"));
            }
            else if (parameterName == "PC")
            {
                return(LinearEquation(pcode.SCALE, pcode.OFFSET, "in"));
            }
            else if (parameterName.IndexOf("GH") == 0 ||
                     parameterName.IndexOf("CH") == 0)    // || parameterName == "GH2", GH-L2, GH-L3 )
            {
                return(LinearEquation(pcode.SCALE, pcode.OFFSET, "ft"));
                //return UsgsEquation(pcode.SCALE, pcode.OFFSET, 1.0, 0.0);
            }
            else if (parameterName.Trim() == "OB" || parameterName.Trim() == "TV" || parameterName == "WF")
            {
                if (System.Math.Abs(pcode.SCALE) < 0.000001)    // basically zero
                {
                    return(LinearEquation(0.07862, -99.02, "degF"));
                }
                else
                {
                    return(LinearEquation(pcode.SCALE, pcode.OFFSET, "degF"));
                }
            }
            else if (parameterName.Trim() == "WC")
            {
                if (System.Math.Abs(pcode.SCALE) < 0.000001)    // basically zero
                {
                    return(LinearEquation(0.1221, pcode.OFFSET, "degC"));
                }
                else
                {
                    return(LinearEquation(pcode.SCALE, pcode.OFFSET, "degC"));
                }
            }

            string units = GetUnits(parameterName);

            return(LinearEquation(pcode.SCALE, pcode.OFFSET, units));


            //return -1;
        }
Пример #5
0
        /// <summary>
        /// Gets id from datatype table for this pcode.
        /// if necesssary create entry in datatype table
        /// </summary>
        /// <param name="goes"></param>
        /// <returns></returns>
        private int GetDataTypeID(McfDataSet.goesmcfRow goes)
        {
            string pcode = goes.GOESDEC.Substring(7).Trim();

            return(GetDataTypeID(pcode));
        }