Exemplo n.º 1
0
        private int SetupNetworkList(string name)
        {
            var rows = decodes.networklist.Select("name = '" + name + "'");

            if (rows.Length == 1)
            {
                return(Convert.ToInt32(rows[0]["id"]));
            }

            int id = NextID(svr, "networklist");

            decodes.networklist.AddnetworklistRow(id, name, "goes", "cbtt",
                                                  LinuxUtility.ToUnixTime(DateTime.Now) * 1000);
            svr.SaveTable(decodes.networklist);
            return(id);
        }
Exemplo n.º 2
0
        private void InsertGoesPlatform(int networklistid)
        {
            platformID       = NextID(svr, "platform");
            platformConfigID = NextID(svr, "platformconfig");
            decodesScriptID  = NextID(svr, "decodesscript");

            for (int i = 0; i < mcf.sitemcf.Rows.Count; i++)
            {
                McfDataSet.sitemcfRow s = mcf.sitemcf[i];

                //var usgs_id = "";
                //if (!UsgsSite(s.SITE, out usgs_id))
                //  continue;
                if (!InSiteList(s.SITE))
                {
                    continue;
                }

                string nessid = s.NESSID.Trim();

                if (s.TTYPE != "SAT" || s.MASTERSW == 0 || nessid == "" || nessid == "0" ||
                    decodes.transportmedium.Select("mediumid='" + nessid + "'").Length > 0 || s.PCHAN == 199)
                {
                    Console.WriteLine("Skipping adding existing/parked platform " + s.SITE + " " + s.NESSID);
                    continue;
                }

                string cfgName             = "";//
                string platformDesignator  = "";
                string platformDescription = "";
                string parameterFilter     = "";

                List <McfDataSet.sitemcfRow> sitesAtTransmitter =
                    new List <McfDataSet.sitemcfRow>(from row in mcf.sitemcf.AsEnumerable()
                                                     where row.NESSID == nessid
                                                     //&& row.NESSID != ""
                                                     //&& row.NESSID != "0"
                                                     orderby row.SITE
                                                     select row);



                for (int j = 0; j < sitesAtTransmitter.Count; j++)
                {
                    if (cfgName.Length > 0)
                    {
                        cfgName += "-";
                    }
                    cfgName += "" + sitesAtTransmitter[j].SITE.Trim();

                    if (platformDesignator.Length > 0)
                    {
                        platformDesignator += "-";
                    }
                    platformDesignator += sitesAtTransmitter[j].SITE.Trim();

                    if (platformDescription.Length > 0)
                    {
                        platformDescription += "\n   ";
                    }
                    platformDescription += sitesAtTransmitter[j].DESCR;

                    if (parameterFilter.Length > 0)
                    {
                        parameterFilter += " or ";
                    }
                    parameterFilter += " GOESDEC like '" + sitesAtTransmitter[j].SITE.PadRight(8) + "%' ";
                }

                var pc = decodes.platformconfig;
                var p  = decodes.platform;
                // build Platform and Platform Config together.

                int siteID = LookupSiteIDFromCBTT(s.SITE.Trim());

                var duplicates = pc.Select("name = '" + cfgName + "'");
                if (duplicates.Length > 0)
                {
                    Console.WriteLine(cfgName + " allready exists.. skipping");
                    continue;
                }

                pc.AddplatformconfigRow(platformConfigID, cfgName, s.DESCR, GetManufactureCode(s.DCPMFG));
                p.AddplatformRow(platformID, GetAgencyName(s.GRP), "TRUE", siteID, platformConfigID, platformDescription,
                                 LinuxUtility.ToUnixTime(DateTime.Now.Date) * 1000,
                                 LinuxUtility.ToUnixTime(DateTime.Now.AddYears(100)) * 1000, platformDesignator);

                decodes.transportmedium.AddtransportmediumRow(platformID, "goes-self-timed", nessid, "ST",
                                                              s.PCHAN, s.REPTIM, s.TSSIZ, s.REPINT * 60, GetManufactureCode(s.DCPMFG),
                                                              0, "S", "UTC", "", 0, 0, "U", 0, "FALSE", "", "");

                decodes.networklistentry.AddnetworklistentryRow(networklistid, nessid, s.SITE.Trim(), s.DESCR);

                decodes.platformproperty.AddplatformpropertyRow(platformID, "HydrometGroup", getHydrometCatagoryName(s));

                decodes.platformproperty.AddplatformpropertyRow(platformID, "USGS", "True");
                decodes.platformproperty.AddplatformpropertyRow(platformID, "expectLength", s.SMSGLEN.ToString());

//            need parameter filter....
                var parameters = (McfDataSet.goesmcfRow[])mcf.goesmcf.Select(parameterFilter + " and ACTIVE = 1");

                string dataOrder = "D";
                if (s.DCPMFG == "A")
                {
                    dataOrder = "A";
                }

                decodes.decodesscript.AdddecodesscriptRow(decodesScriptID, platformConfigID, "ST", "Decodes", dataOrder);

                BuildDecodesScripts(sitesAtTransmitter.ToArray(), siteID, parameters, platformConfigID, decodesScriptID);
                InsertBatteryVoltScript(platformConfigID, decodesScriptID, parameters.Length + 1, s);
                m_converter.AddBatteryVoltConverter(decodesScriptID, parameters.Length + 1, s);
                platformID++;
                platformConfigID++;
                decodesScriptID++;
            }
        }