コード例 #1
0
        /// <summary>
        /// Performs data checks on reservoir station data. </summary>
        /// <param name="props"> A property list for specific properties
        /// on checking this data. </param>
        /// <param name="data_vector"> Vector of data to check. </param>
        private void checkReservoirStationData(PropList props, System.Collections.IList data_vector)
        {
            //	 Create elements for the checks and check file
            string[] header = StateMod_Reservoir.getDataHeader();
            System.Collections.IList data = new List <object>();
            string title = "Reservoir Station";

            // Perform the general validation using the Data Table Model
            StateMod_Data_TableModel tm = new StateMod_Reservoir_Data_TableModel(data_vector, false);

            System.Collections.IList @checked = performDataValidation(tm, title);
            //String [] columnHeader = getDataTableModelColumnHeader( tm );
            string[] columnHeader = getColumnHeader(tm);

            // Do specific checks
            int size = 0;

            if (data_vector != null)
            {
                size = data_vector.Count;
            }
            data = doSpecificDataChecks(data_vector, props);
            // Add the data and checks to the check file.
            // Provides basic header information for this data check table
            string info = "The following " + title + " (" + data.Count +
                          " out of " + size + ") have no .....";

            // Create data models for Check file
            CheckFile_DataModel dm     = new CheckFile_DataModel(data, header, title, info, data.Count, size);
            CheckFile_DataModel gen_dm = new CheckFile_DataModel(@checked, columnHeader, title + " Missing or Invalid Data", "", __gen_problems, size);

            __check_file.addData(dm, gen_dm);
        }
コード例 #2
0
        /// <summary>
        /// Called when the Apply button is pressed. This commits any changes to the data objects.
        /// </summary>
        protected internal override void apply()
        {
            StateMod_Reservoir res = null;
            int size = _data.Count;

            for (int i = 0; i < size; i++)
            {
                res = (StateMod_Reservoir)_data[i];
                res.createBackup();
            }
        }
コード例 #3
0
        /// <summary>
        /// Called when the cancel button is pressed.  This discards any changes made to the data objects.
        /// </summary>
        protected internal override void cancel()
        {
            StateMod_Reservoir res = null;
            int size = _data.Count;

            for (int i = 0; i < size; i++)
            {
                res = (StateMod_Reservoir)_data[i];
                res.restoreOriginal();
            }
        }
コード例 #4
0
        /// <summary>
        /// Constructor. </summary>
        /// <param name="dataset"> the dataset in which the data is contained. </param>
        /// <param name="res"> the reservoir for which to display data </param>
        /// <param name="editable"> whether the gui data is editable or not. </param>
        public StateMod_Reservoir_Owner_JFrame(StateMod_DataSet dataset, StateMod_Reservoir res, bool editable)
        {
            StateMod_GUIUtil.setTitle(this, dataset, res.getName() + " - Reservoir Owner Accounts", null);
            JGUIUtil.setIcon(this, JGUIUtil.getIconImage());
            __currentRes = res;

            __dataset = dataset;

            __editable = editable;

            setupGUI();
        }
コード例 #5
0
        /// <summary>
        /// Constructor. </summary>
        /// <param name="dataset"> the dataset in which the data is contained. </param>
        /// <param name="res"> the reservoir object to display in the frame. </param>
        /// <param name="editable"> whether the gui data is editable or not </param>
        public StateMod_Reservoir_AreaCap_JFrame(StateMod_DataSet dataset, StateMod_Reservoir res, bool editable)
        {
            StateMod_GUIUtil.setTitle(this, dataset, res.getName() + " - Reservoir Content/Area/Seepage", null);
            JGUIUtil.setIcon(this, JGUIUtil.getIconImage());
            __currentRes = res;

            __dataset = dataset;

            __editable = editable;

            setupGUI();
        }
        /// <summary>
        /// Constructor. </summary>
        /// <param name="data"> the data to display in the worksheet.  Can be null or empty, in
        /// which case an empty worksheet is shown. </param>
        /// <param name="titleString"> the String to display in the title of the GUI. </param>
        /// <param name="editable"> whether the data in the JFrame can be edited or not.  If true
        /// the data can be edited, if false they can not. </param>
        /// <param name="precip"> if true, then the climate stations to view are precip stations.
        /// If false, they are evap stations. </param>
        /// <exception cref="Exception"> if there is an error building the worksheet. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public StateMod_ReservoirClimate_Data_JFrame(java.util.List data, String titleString, boolean editable, boolean precip) throws Exception
        public StateMod_ReservoirClimate_Data_JFrame(System.Collections.IList data, string titleString, bool editable, bool precip) : base()
        {
            int j     = 0;
            int size  = 0;
            int size2 = 0;
            StateMod_Reservoir        r = null;
            StateMod_ReservoirClimate c = null;

            System.Collections.IList climates = null;
            System.Collections.IList v        = new List <object>();

            if (data != null)
            {
                size = data.Count;
            }

            for (int i = 0; i < size; i++)
            {
                r        = (StateMod_Reservoir)data[i];
                climates = r.getClimates();
                if (climates == null)
                {
                    continue;
                }

                size2 = climates.Count;

                for (j = 0; j < size2; j++)
                {
                    c = (StateMod_ReservoirClimate)climates[j];
                    if (c == null)
                    {
                        // skip
                    }
                    else if (!precip && c.getType() == StateMod_ReservoirClimate.CLIMATE_EVAP)
                    {
                        c.setCgoto(r.getID());
                        v.Add(c);
                    }
                    else if (precip && c.getType() == StateMod_ReservoirClimate.CLIMATE_PTPX)
                    {
                        c.setCgoto(r.getID());
                        v.Add(c);
                    }
                }
            }

            initialize(v, titleString, editable);
            setSize(377, getHeight());
        }
コード例 #7
0
        /// <summary>
        /// Constructor. </summary>
        /// <param name="dataset"> the dataset in which the data is contained. </param>
        /// <param name="res"> the Reservoir for which to display return information. </param>
        /// <param name="editable"> whether the gui data is editable or not. </param>
        public StateMod_Reservoir_Return_JFrame(StateMod_DataSet dataset, StateMod_Reservoir res, bool editable)
        {
            StateMod_GUIUtil.setTitle(this, dataset, res.getName() + " - Reservoir Return Flow Table Assignment", null);
            JGUIUtil.setIcon(this, JGUIUtil.getIconImage());
            __currentRes = res;
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_ReturnFlow> allReturns = (java.util.List<StateMod_ReturnFlow>)dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESERVOIR_RETURN).getData();
            IList <StateMod_ReturnFlow> allReturns = (IList <StateMod_ReturnFlow>)dataset.getComponentForComponentType(StateMod_DataSet.COMP_RESERVOIR_RETURN).getData();

            __currentResReturnList = (IList <StateMod_ReturnFlow>)StateMod_Util.getDataList(allReturns, res.getID());
            Message.printStatus(2, "", "Have " + __currentResReturnList.Count + " return records for reservoir \"" + __currentRes.getID() + "\" uniquetempvar.");
            //__dataset = dataset;
            // TODO SAM 2011-01-02 For now editing is disabled...
            editable   = false;
            __editable = editable;
            setupGUI();
        }
コード例 #8
0
        /// <summary>
        /// Display a graph of reservoir content versus area or content versus seepage. </summary>
        /// <param name="dataset"> The dataset including the reservoir. </param>
        /// <param name="res"> StateMod_Reservoir with data to graph. </param>
        /// <param name="type"> "Area" or "Seepage", indicating the data to graph. </param>
        /// <param name="editable"> Indicate whether the data are editable or not (currently
        /// ignored and treated as not editable through the graph). </param>
        public StateMod_Reservoir_AreaCap_Graph_JFrame(StateMod_DataSet dataset, StateMod_Reservoir res, string type, bool editable)
        {
            StateMod_GUIUtil.setTitle(this, dataset, res.getName() + " - Reservoir Content/" + type + " Curve", null);
            JGUIUtil.setIcon(this, JGUIUtil.getIconImage());

            __res  = res;
            __type = type;

            DefaultTableXYDataset graph_dataset = createDataset();
            JFreeChart            chart         = createChart(graph_dataset);
            ChartPanel            chartPanel    = new ChartPanel(chart);

            chartPanel.setPreferredSize(new Dimension(500, 500));
            getContentPane().add("Center", chartPanel);
            pack();
            JGUIUtil.center(this);
            setVisible(true);
        }
コード例 #9
0
        /// <summary>
        /// This set of routines don't actually add an element to an array.  They already
        /// exist as part of a list of StateMod_ReservoirRight.  We are just connecting pointers.
        /// </summary>
        public static void connectAllRights(IList <StateMod_Reservoir> reservoirs, IList <StateMod_ReservoirRight> rights)
        {
            if (reservoirs == null)
            {
                return;
            }
            int i, num_res = reservoirs.Count;

            StateMod_Reservoir res = null;

            for (i = 0; i < num_res; i++)
            {
                res = reservoirs[i];
                if (res == null)
                {
                    continue;
                }
                res.connectRights(rights);
            }
            res = null;
        }
コード例 #10
0
        /// <summary>
        /// Constructor. </summary>
        /// <param name="data"> the data to display in the worksheet.  Can be null or empty, in
        /// which case an empty worksheet is shown. </param>
        /// <param name="titleString"> the String to display as the GUI title. </param>
        /// <param name="editable"> whether the data in the JFrame can be edited or not.  If true
        /// the data can be edited, if false they can not. </param>
        /// <exception cref="Exception"> if there is an error building the worksheet. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public StateMod_ReservoirAreaCap_Data_JFrame(java.util.List data, String titleString, boolean editable) throws Exception
        public StateMod_ReservoirAreaCap_Data_JFrame(System.Collections.IList data, string titleString, bool editable) : base()
        {
            int j     = 0;
            int size  = 0;
            int size2 = 0;
            StateMod_Reservoir        r = null;
            StateMod_ReservoirAreaCap a = null;

            System.Collections.IList areacaps = null;
            System.Collections.IList v        = new List <object>();

            if (data != null)
            {
                size = data.Count;
            }

            for (int i = 0; i < size; i++)
            {
                r        = (StateMod_Reservoir)data[i];
                areacaps = r.getAreaCaps();
                if (areacaps == null)
                {
                    continue;
                }

                size2 = areacaps.Count;

                for (j = 0; j < size2; j++)
                {
                    a = (StateMod_ReservoirAreaCap)areacaps[j];
                    a.setCgoto(r.getID());
                    v.Add(a);
                }
            }

            initialize(v, titleString, editable);
            setSize(400, getHeight());
        }
コード例 #11
0
        /// <summary>
        /// Creates a list of the available IDs for a Vector of StateMod_Data-extending
        /// objects.  Reservoirs will include an identifier for each reservoir total and each account for the reservoir. </summary>
        /// <param name="nodes"> the nodes for which to create a list of IDs. </param>
        /// <param name="include_accounts"> If true, the </param>
        /// <returns> a Vector of Strings, each of which contains an ID followed by the name of Structure in parentheses </returns>
        private System.Collections.IList createAvailableIDsList(System.Collections.IList nodes)
        {
            System.Collections.IList v = new List <object>();

            int  num          = 0;
            bool is_reservoir = false;     // To allow check below

            if (nodes != null)
            {
                num = nodes.Count;
                if ((num > 0) && ((StateMod_Data)nodes[0]) is StateMod_Reservoir)
                {
                    is_reservoir = true;
                }
            }

            StateMod_Reservoir res = null;     // These are used if reservoirs.
            int nowner             = 0;
            int ia = 0;

            for (int i = 0; i < num; i++)
            {
                // Add the normal item...
                v.Add(StateMod_Util.formatDataLabel(((StateMod_Data)nodes[i]).getID(), ((StateMod_Data)nodes[i]).getName()));
                if (is_reservoir)
                {
                    // Also add reservoir owner/accounts...
                    res    = (StateMod_Reservoir)nodes[i];
                    nowner = res.getAccounts().Count;
                    for (ia = 0; ia < nowner; ia++)
                    {
                        v.Add(StateMod_Util.formatDataLabel(res.getID() + "-" + (ia + 1), res.getName() + " - " + res.getAccount(ia).getName()));
                    }
                }
            }
            return(v);
        }
コード例 #12
0
        /// <summary>
        /// Sets the value at the specified position to the specified value. </summary>
        /// <param name="value"> the value to set the cell to. </param>
        /// <param name="row"> the row of the cell for which to set the value. </param>
        /// <param name="col"> the col of the cell for which to set the value. </param>
        public virtual void setValueAt(object value, int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }
            int ival;
            StateMod_Reservoir smr = (StateMod_Reservoir)_data.get(row);

            switch (col)
            {
            case COL_ID:
                smr.setID((string)value);
                break;

            case COL_NAME:
                smr.setName((string)value);
                break;

            case COL_NODE_ID:
                smr.setCgoto((string)value);
                break;

            case COL_SWITCH:
                if (value is int?)
                {
                    ival = ((int?)value).Value;
                    smr.setSwitch(ival);
                }
                else if (value is string)
                {
                    string onOff = (string)value;
                    int    index = onOff.IndexOf(" -", StringComparison.Ordinal);
                    ival = (Convert.ToInt32(onOff.Substring(0, index)));
                    smr.setSwitch(ival);
                }
                break;

            case COL_ONE_FILL_DATE:
                smr.setRdate(((int?)value).Value);
                break;

            case COL_MIN_CONTENT:
                smr.setVolmin(((double?)value).Value);
                break;

            case COL_MAX_CONTENT:
                smr.setVolmax(((double?)value).Value);
                break;

            case COL_MAX_RELEASE:
                smr.setFlomax(((double?)value).Value);
                break;

            case COL_DEAD_STORAGE:
                smr.setDeadst(((double?)value).Value);
                break;

            case COL_DAILY_ID:
                smr.setCresdy((string)value);
                break;
            }
        }
コード例 #13
0
        /// <summary>
        /// Returns the data that should be placed in the JTable at the given row and column. </summary>
        /// <param name="row"> the row for which to return data. </param>
        /// <param name="col"> the column for which to return data. </param>
        /// <returns> the data that should be placed in the JTable at the given row and col. </returns>
        public virtual object getValueAt(int row, int col)
        {
            if (_sortOrder != null)
            {
                row = _sortOrder[row];
            }

            StateMod_Reservoir r = (StateMod_Reservoir)_data.get(row);

            switch (col)
            {
            case COL_ID:
                return(r.getID());

            case COL_NAME:
                return(r.getName());

            case COL_NODE_ID:
                return(r.getCgoto());

            case COL_SWITCH:
                return(new int?(r.getSwitch()));

            case COL_ONE_FILL_DATE:
                return(new int?((int)r.getRdate()));

            case COL_MIN_CONTENT:
                return(new double?(r.getVolmin()));

            case COL_MAX_CONTENT:
                return(new double?(r.getVolmax()));

            case COL_MAX_RELEASE:
                return(new double?(r.getFlomax()));

            case COL_DEAD_STORAGE:
                return(new double?(r.getDeadst()));

            case COL_DAILY_ID:
                return(r.getCresdy());

            case COL_NUM_OWNERS:
                return(new int?(r.getNowner()));

            case COL_NUM_PRECIP_STA:
                int nptpx = StateMod_ReservoirClimate.getNumPrecip(r.getClimates());
                return(new int?(nptpx));

            case COL_NUM_EVAP_STA:
                int nevap = StateMod_ReservoirClimate.getNumEvap(r.getClimates());
                return(new int?(nevap));

            case COL_NUM_CURVE_ROWS:
                System.Collections.IList v = r.getAreaCaps();
                if (v == null)
                {
                    return(new int?(0));
                }
                else
                {
                    return(new int?(v.Count));
                }

            default:
                return("");
            }
        }
        /// <summary>
        /// Sets up the data Vectors to display the reservoir collection data in the
        /// GUI.
        /// </summary>
        private void setupData()
        {
            int[] years                 = null;
            int   len                   = 0;
            int   size                  = _data.size();
            int   size2                 = 0;
            StateMod_Reservoir l        = null;
            string             colType  = null;
            string             id       = null;
            string             partType = null;

            System.Collections.IList ids = null;
            __data = new System.Collections.IList[__COLUMNS];
            for (int i = 0; i < __COLUMNS; i++)
            {
                __data[i] = new List <object>();
            }

            int rows = 0;

            for (int i = 0; i < size; i++)
            {
                l  = (StateMod_Reservoir)_data.get(i);
                id = l.getID();
                //		div = new Integer(l.getCollectionDiv());

                years    = l.getCollectionYears();
                colType  = l.getCollectionType();
                partType = l.getCollectionPartType();

                if (years == null)
                {
                    len = 0;
                }
                else
                {
                    len = years.Length;
                }

                for (int j = 0; j < len; j++)
                {
                    ids = l.getCollectionPartIDs(years[j]);
                    if (ids == null)
                    {
                        size2 = 0;
                    }
                    else
                    {
                        size2 = ids.Count;
                    }

                    for (int k = 0; k < size2; k++)
                    {
                        __data[__COL_ID].Add(id);
                        //				__data[__COL_DIV].add(div);
                        __data[__COL_YEAR].Add(new int?(years[j]));
                        __data[__COL_COL_TYPE].Add(colType);
                        __data[__COL_PART_TYPE].Add(partType);
                        __data[__COL_PART_ID].Add(ids[k]);
                        rows++;
                    }
                }
            }
            _rows = rows;
        }
コード例 #15
0
        /// <summary>
        /// Read reservoir information in and store in a Vector. </summary>
        /// <param name="filename"> Name of file to read. </param>
        /// <exception cref="Exception"> if there is an error reading the file. </exception>
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public static java.util.List<StateMod_Reservoir> readStateModFile(String filename) throws Exception
        public static IList <StateMod_Reservoir> readStateModFile(string filename)
        {
            string routine = "StateMod_Reservoir.readStateModFile";
            IList <StateMod_Reservoir> theReservoirs = new List <StateMod_Reservoir>();
            string         iline = null;
            IList <object> v     = new List <object>(9);

            int[]                     format_0   = new int[] { StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_STRING, StringUtil.TYPE_INTEGER, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_SPACE, StringUtil.TYPE_STRING };
            int[]                     format_0w  = new int[] { 12, 24, 12, 8, 8, 1, 12 };
            int[]                     format_1   = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER, StringUtil.TYPE_INTEGER };
            int[]                     format_1w  = new int[] { 24, 8, 8, 8, 8, 8, 8, 8, 8 };
            int[]                     format_2   = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_INTEGER };
            int[]                     format_2w  = new int[] { 12, 12, 8, 8, 8, 8 };
            int[]                     format_3   = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_STRING, StringUtil.TYPE_DOUBLE };
            int[]                     format_3w  = new int[] { 24, 12, 8 };
            int[]                     format_4   = new int[] { StringUtil.TYPE_SPACE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE, StringUtil.TYPE_DOUBLE };
            int[]                     format_4w  = new int[] { 24, 8, 8, 8 };
            StreamReader              @in        = null;
            StateMod_Reservoir        aReservoir = null;
            StateMod_ReservoirAccount anAccount  = null;
            StateMod_ReservoirClimate anEvap     = null;
            StateMod_ReservoirClimate aPtpx      = null;
            int i = 0;

            if (Message.isDebugOn)
            {
                Message.printDebug(10, routine, "in SMParseResFile reading file: " + filename);
            }
            int line_count = 0;

            try
            {
                @in = new StreamReader(IOUtil.getPathUsingWorkingDir(filename));
                while (!string.ReferenceEquals((iline = @in.ReadLine()), null))
                {
                    ++line_count;
                    // check for comments
                    if (iline.StartsWith("#", StringComparison.Ordinal) || iline.Trim().Length == 0)
                    {
                        continue;
                    }

                    // allocate new reservoir node
                    aReservoir = new StateMod_Reservoir();

                    // line 1
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "line 1: " + iline);
                    }
                    StringUtil.fixedRead(iline, format_0, format_0w, v);
                    aReservoir.setID(((string)v[0]).Trim());
                    aReservoir.setName(((string)v[1]).Trim());
                    aReservoir.setCgoto(((string)v[2]).Trim());
                    aReservoir.setSwitch((int?)v[3]);
                    aReservoir.setRdate((double?)v[4]);
                    aReservoir.setCresdy(((string)v[5]).Trim());

                    // line 2
                    iline = @in.ReadLine();
                    ++line_count;
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "line 2: " + iline);
                    }
                    StringUtil.fixedRead(iline, format_1, format_1w, v);
                    aReservoir.setVolmin(((double?)v[0]));
                    aReservoir.setVolmax(((double?)v[1]));
                    aReservoir.setFlomax(((double?)v[2]));
                    aReservoir.setDeadst(((double?)v[3]));
                    int nowner = ((int?)v[4]).Value;
                    int nevap  = ((int?)v[5]).Value;
                    int nptpx  = ((int?)v[6]).Value;
                    int nrange = ((int?)v[7]).Value;

                    // get the owner's information
                    if (Message.isDebugOn)
                    {
                        Message.printDebug(50, routine, "Number of owners: " + nowner);
                    }
                    for (i = 0; i < nowner; i++)
                    {
                        iline = @in.ReadLine();
                        ++line_count;
                        StringUtil.fixedRead(iline, format_2, format_2w, v);
                        anAccount = new StateMod_ReservoirAccount();
                        // Account ID is set to the numerical count (StateMod uses the number)
                        anAccount.setID("" + (i + 1));
                        anAccount.setName(((string)v[0]).Trim());
                        anAccount.setOwnmax(((double?)v[1]));
                        anAccount.setCurown(((double?)v[2]));
                        anAccount.setPcteva(((double?)v[3]));
                        anAccount.setN2own(((int?)v[4]));
                        aReservoir.addAccount(anAccount);
                    }

                    // get the evaporation information
                    for (i = 0; i < nevap; i++)
                    {
                        iline = @in.ReadLine();
                        ++line_count;
                        StringUtil.fixedRead(iline, format_3, format_3w, v);
                        anEvap = new StateMod_ReservoirClimate();
                        anEvap.setID(((string)v[0]).Trim());
                        anEvap.setType(StateMod_ReservoirClimate.CLIMATE_EVAP);
                        anEvap.setWeight(((double?)v[1]));
                        aReservoir.addClimate(anEvap);
                    }

                    // get the precipitation information
                    for (i = 0; i < nptpx; i++)
                    {
                        iline = @in.ReadLine();
                        ++line_count;
                        StringUtil.fixedRead(iline, format_3, format_3w, v);
                        aPtpx = new StateMod_ReservoirClimate();
                        aPtpx.setID(((string)v[0]).Trim());
                        aPtpx.setType(StateMod_ReservoirClimate.CLIMATE_PTPX);
                        aPtpx.setWeight(((double?)v[1]));
                        aReservoir.addClimate(aPtpx);
                    }

                    // get the area capacity information
                    for (i = 0; i < nrange; i++)
                    {
                        iline = @in.ReadLine();
                        ++line_count;
                        StringUtil.fixedRead(iline, format_4, format_4w, v);
                        StateMod_ReservoirAreaCap anAreaCap = new StateMod_ReservoirAreaCap();
                        anAreaCap.setConten(((double?)v[0]));
                        anAreaCap.setSurarea(((double?)v[1]));
                        anAreaCap.setSeepage(((double?)v[2]));
                        aReservoir.addAreaCap(anAreaCap);
                    }

                    // add the reservoir to the vector of reservoirs
                    theReservoirs.Add(aReservoir);
                }
            }
            catch (Exception e)
            {
                Message.printWarning(3, routine, "Error reading reservoir stations in line " + line_count);
                throw e;
            }
            finally
            {
                if (@in != null)
                {
                    @in.Close();
                }
            }
            return(theReservoirs);
        }
コード例 #16
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void saveComponent(RTi.Util.IO.DataSetComponent comp, String oldFilename,String newFilename, java.util.List<String> comments) throws Exception
        private void saveComponent(DataSetComponent comp, string oldFilename, string newFilename, IList <string> comments)
        {
            bool   daily = false;
            int    type  = comp.getComponentType();
            object data  = comp.getData();
            string name  = null;

            switch (type)
            {
            ////////////////////////////////////////////////////////
            // StateMod_* classes
            case StateMod_DataSet.COMP_CONTROL:
                StateMod_DataSet.writeStateModControlFile(__dataset, oldFilename, newFilename, comments);
                name = "Control";
                break;

            case StateMod_DataSet.COMP_DELAY_TABLES_DAILY:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delayTablesDaily = (java.util.List<StateMod_DelayTable>)data;
                IList <StateMod_DelayTable> delayTablesDaily = (IList <StateMod_DelayTable>)data;
                StateMod_DelayTable.writeStateModFile(oldFilename, newFilename, delayTablesDaily, comments, __dataset.getInterv(), -1);
                name = "Delay Tables Daily";
                break;

            case StateMod_DataSet.COMP_DELAY_TABLES_MONTHLY:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DelayTable> delayTablesMonthly = (java.util.List<StateMod_DelayTable>)data;
                IList <StateMod_DelayTable> delayTablesMonthly = (IList <StateMod_DelayTable>)data;
                StateMod_DelayTable.writeStateModFile(oldFilename, newFilename, delayTablesMonthly, comments, __dataset.getInterv(), -1);
                name = "Delay Tables Monthly";
                break;

            case StateMod_DataSet.COMP_DIVERSION_STATIONS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Diversion> diversionStations = (java.util.List<StateMod_Diversion>)data;
                IList <StateMod_Diversion> diversionStations = (IList <StateMod_Diversion>)data;
                StateMod_Diversion.writeStateModFile(oldFilename, newFilename, diversionStations, comments, daily);
                name = "Diversion";
                break;

            case StateMod_DataSet.COMP_DIVERSION_RIGHTS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_DiversionRight> diversionRights = (java.util.List<StateMod_DiversionRight>)data;
                IList <StateMod_DiversionRight> diversionRights = (IList <StateMod_DiversionRight>)data;
                StateMod_DiversionRight.writeStateModFile(oldFilename, newFilename, diversionRights, comments, daily);
                name = "Diversion Rights";
                break;

            case StateMod_DataSet.COMP_INSTREAM_STATIONS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_InstreamFlow> instreamFlow = (java.util.List<StateMod_InstreamFlow>)data;
                IList <StateMod_InstreamFlow> instreamFlow = (IList <StateMod_InstreamFlow>)data;
                StateMod_InstreamFlow.writeStateModFile(oldFilename, newFilename, instreamFlow, comments, daily);
                name = "Instream";
                break;

            case StateMod_DataSet.COMP_INSTREAM_RIGHTS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_InstreamFlowRight> instreamFlowRights = (java.util.List<StateMod_InstreamFlowRight>)data;
                IList <StateMod_InstreamFlowRight> instreamFlowRights = (IList <StateMod_InstreamFlowRight>)data;
                StateMod_InstreamFlowRight.writeStateModFile(oldFilename, newFilename, instreamFlowRights, comments);
                name = "Instream Rights";
                break;

            case StateMod_DataSet.COMP_OPERATION_RIGHTS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_OperationalRight> operationalRights = (java.util.List<StateMod_OperationalRight>)data;
                IList <StateMod_OperationalRight> operationalRights = (IList <StateMod_OperationalRight>)data;
                // 2 is the file version (introduced for StateMod version 12 change)
                StateMod_OperationalRight.writeStateModFile(oldFilename, newFilename, 2, operationalRights, comments, __dataset);
                name = "Operational Rights";
                break;

            case StateMod_DataSet.COMP_PLANS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Plan> planStations = (java.util.List<StateMod_Plan>)data;
                IList <StateMod_Plan> planStations = (IList <StateMod_Plan>)data;
                StateMod_Plan.writeStateModFile(oldFilename, newFilename, planStations, comments);
                name = "Plan";
                break;

            case StateMod_DataSet.COMP_RESERVOIR_STATIONS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Reservoir> reservoirStations = (java.util.List<StateMod_Reservoir>)data;
                IList <StateMod_Reservoir> reservoirStations = (IList <StateMod_Reservoir>)data;
                StateMod_Reservoir.writeStateModFile(oldFilename, newFilename, reservoirStations, comments, daily);
                name = "Reservoir";
                break;

            case StateMod_DataSet.COMP_RESERVOIR_RIGHTS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_ReservoirRight> reservoirRights = (java.util.List<StateMod_ReservoirRight>)data;
                IList <StateMod_ReservoirRight> reservoirRights = (IList <StateMod_ReservoirRight>)data;
                StateMod_ReservoirRight.writeStateModFile(oldFilename, newFilename, reservoirRights, comments);
                name = "Reservoir Rights";
                break;

            case StateMod_DataSet.COMP_RESPONSE:
                StateMod_DataSet.writeStateModFile(__dataset, oldFilename, newFilename, comments);
                name = "Response";
                break;

            case StateMod_DataSet.COMP_RIVER_NETWORK:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_RiverNetworkNode> riverNodes = (java.util.List<StateMod_RiverNetworkNode>)data;
                IList <StateMod_RiverNetworkNode> riverNodes = (IList <StateMod_RiverNetworkNode>)data;
                StateMod_RiverNetworkNode.writeStateModFile(oldFilename, newFilename, riverNodes, comments, true);
                name = "River Network";
                break;

            case StateMod_DataSet.COMP_STREAMESTIMATE_STATIONS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamEstimate> streamEstimateStations = (java.util.List<StateMod_StreamEstimate>)data;
                IList <StateMod_StreamEstimate> streamEstimateStations = (IList <StateMod_StreamEstimate>)data;
                StateMod_StreamEstimate.writeStateModFile(oldFilename, newFilename, streamEstimateStations, comments, daily);
                name = "Stream Estimate";
                break;

            case StateMod_DataSet.COMP_STREAMESTIMATE_COEFFICIENTS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamEstimate_Coefficients> streamEstimateCoefficients = (java.util.List<StateMod_StreamEstimate_Coefficients>)data;
                IList <StateMod_StreamEstimate_Coefficients> streamEstimateCoefficients = (IList <StateMod_StreamEstimate_Coefficients>)data;
                StateMod_StreamEstimate_Coefficients.writeStateModFile(oldFilename, newFilename, streamEstimateCoefficients, comments);
                name = "Stream Estimate Coefficients";
                break;

            case StateMod_DataSet.COMP_STREAMGAGE_STATIONS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_StreamGage> streamGageStations = (java.util.List<StateMod_StreamGage>)data;
                IList <StateMod_StreamGage> streamGageStations = (IList <StateMod_StreamGage>)data;
                StateMod_StreamGage.writeStateModFile(oldFilename, newFilename, streamGageStations, comments, daily);
                name = "Streamgage Stations";
                break;

            case StateMod_DataSet.COMP_WELL_STATIONS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_Well> wellStations = (java.util.List<StateMod_Well>)data;
                IList <StateMod_Well> wellStations = (IList <StateMod_Well>)data;
                StateMod_Well.writeStateModFile(oldFilename, newFilename, wellStations, comments);
                name = "Well";
                break;

            case StateMod_DataSet.COMP_WELL_RIGHTS:
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_WellRight> wellRights = (java.util.List<StateMod_WellRight>)data;
                IList <StateMod_WellRight> wellRights = (IList <StateMod_WellRight>)data;
                StateMod_WellRight.writeStateModFile(oldFilename, newFilename, wellRights, comments, (PropList)null);
                name = "Well Rights";
                break;

            //////////////////////////////////////////////////////
            // StateMod Time Series
            case StateMod_DataSet.COMP_CONSUMPTIVE_WATER_REQUIREMENT_TS_DAILY:
            case StateMod_DataSet.COMP_CONSUMPTIVE_WATER_REQUIREMENT_TS_MONTHLY:
            case StateMod_DataSet.COMP_DEMAND_TS_DAILY:
            case StateMod_DataSet.COMP_DEMAND_TS_AVERAGE_MONTHLY:
            case StateMod_DataSet.COMP_DEMAND_TS_MONTHLY:
            case StateMod_DataSet.COMP_DEMAND_TS_OVERRIDE_MONTHLY:
            case StateMod_DataSet.COMP_DIVERSION_TS_DAILY:
            case StateMod_DataSet.COMP_DIVERSION_TS_MONTHLY:
            case StateMod_DataSet.COMP_EVAPORATION_TS_MONTHLY:
            case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_AVERAGE_MONTHLY:
            case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_DAILY:
            case StateMod_DataSet.COMP_INSTREAM_DEMAND_TS_MONTHLY:
            case StateMod_DataSet.COMP_PRECIPITATION_TS_MONTHLY:
            case StateMod_DataSet.COMP_RESERVOIR_CONTENT_TS_DAILY:
            case StateMod_DataSet.COMP_RESERVOIR_CONTENT_TS_MONTHLY:
            case StateMod_DataSet.COMP_RESERVOIR_TARGET_TS_DAILY:
            case StateMod_DataSet.COMP_RESERVOIR_TARGET_TS_MONTHLY:
            case StateMod_DataSet.COMP_STREAMESTIMATE_NATURAL_FLOW_TS_DAILY:
            case StateMod_DataSet.COMP_STREAMESTIMATE_NATURAL_FLOW_TS_MONTHLY:
            case StateMod_DataSet.COMP_STREAMGAGE_NATURAL_FLOW_TS_DAILY:
            case StateMod_DataSet.COMP_STREAMGAGE_NATURAL_FLOW_TS_MONTHLY:
            case StateMod_DataSet.COMP_STREAMGAGE_HISTORICAL_TS_DAILY:
            case StateMod_DataSet.COMP_STREAMGAGE_HISTORICAL_TS_MONTHLY:
            case StateMod_DataSet.COMP_WELL_DEMAND_TS_DAILY:
            case StateMod_DataSet.COMP_WELL_DEMAND_TS_MONTHLY:
            case StateMod_DataSet.COMP_WELL_PUMPING_TS_DAILY:
            case StateMod_DataSet.COMP_WELL_PUMPING_TS_MONTHLY:
                double   missing  = -999.0;
                YearType yearType = null;
                if (__dataset.getCyrl() == YearType.CALENDAR)
                {
                    yearType = YearType.CALENDAR;
                }
                else if (__dataset.getCyrl() == YearType.WATER)
                {
                    yearType = YearType.WATER;
                }
                else if (__dataset.getCyrl() == YearType.NOV_TO_OCT)
                {
                    yearType = YearType.NOV_TO_OCT;
                }
                int precision = 2;

                // Do the following to avoid warnings
                IList <TS> tslist = null;
                if (data != null)
                {
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<RTi.TS.TS> tslist0 = (java.util.List<RTi.TS.TS>)data;
                    IList <TS> tslist0 = (IList <TS>)data;
                    if (tslist0.Count > 0)
                    {
                        TS ts = tslist0[0];
                        missing = ts.getMissing();
                    }
                    tslist = tslist0;
                }

                StateMod_TS.writeTimeSeriesList(oldFilename, newFilename, comments, tslist, null, null, yearType, missing, precision);
                name = "TS (" + type + ")";
                break;

            default:
                name = "(something: " + type + ")";
                break;
            }
            comp.setDirty(false);
            Message.printStatus(1, "", "Component '" + name + "' written");
        }