Ejemplo n.º 1
0
        /// <summary>
        /// Get a value from the history tables.
        /// </summary>
        /// <param name="historyType">Type of history information. see HistoryType</param>
        /// <param name="historyScale">Scale of history data. see HistoryScale</param>
        /// <param name="historyIndex">Index in the data to obtain</param>
        /// <returns>Historic data value of the requested graph</returns>
        public short getHistory(HistoryType historyType, HistoryScale historyScale, int historyIndex)
        {
            if (historyType < 0 || historyType >= HistoryType.HISTORY_TYPE_COUNT ||
                historyScale < 0 || historyScale >= HistoryScale.HISTORY_SCALE_COUNT ||
                historyIndex < 0 || historyIndex >= HISTORY_COUNT)
            {
                return(0);
            }

            short[] history = null;
            switch (historyType)
            {
            case HistoryType.HISTORY_TYPE_RES:
                history = resHist;
                break;

            case HistoryType.HISTORY_TYPE_COM:
                history = comHist;
                break;

            case HistoryType.HISTORY_TYPE_IND:
                history = indHist;
                break;

            case HistoryType.HISTORY_TYPE_MONEY:
                history = moneyHist;
                break;

            case HistoryType.HISTORY_TYPE_CRIME:
                history = crimeHist;
                break;

            case HistoryType.HISTORY_TYPE_POLLUTION:
                history = pollutionHist;
                break;

            default:
                break;
            }

            int offset = 0;

            switch (historyScale)
            {
            case HistoryScale.HISTORY_SCALE_SHORT:
                offset = 0;
                break;

            case HistoryScale.HISTORY_SCALE_LONG:
                offset = 120;
                break;

            default:
                break;
            }

            short result = history[historyIndex + offset];

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Store a value into the history tables.
        /// </summary>
        /// <param name="historyType">Type of history information. @see HistoryType</param>
        /// <param name="historyScale">Scale of history data. @see HistoryScale</param>
        /// <param name="historyIndex">Index in the data to obtain</param>
        /// <param name="historyValue">Index in the value to store</param>
        public void SetHistory(HistoryType historyType, HistoryScale historyScale, int historyIndex, short historyValue)
        {
            if (historyType < 0 || historyType >= HistoryType.Count ||
                historyScale < 0 || historyScale >= HistoryScale.Count ||
                historyIndex < 0 || historyIndex >= Constants.HistoryCount)
            {
                return;
            }

            short[] history = null;
            switch (historyType)
            {
            case HistoryType.Res:
                history = ResHist;
                break;

            case HistoryType.Com:
                history = ComHist;
                break;

            case HistoryType.Ind:
                history = IndHist;
                break;

            case HistoryType.Money:
                history = MoneyHist;
                break;

            case HistoryType.Crime:
                history = CrimeHist;
                break;

            case HistoryType.Pollution:
                history = PollutionHist;
                break;

            default:
                //NOT_REACHED();
                break;
            }

            int offset = 0;

            switch (historyScale)
            {
            case HistoryScale.Short:
                offset = 0;
                break;

            case HistoryScale.Long:
                offset = 120;
                break;

            default:
                //NOT_REACHED();
                break;
            }

            history[historyIndex + offset] = historyValue;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the minimal and maximal values of a historic graph.
        /// </summary>
        /// <param name="historyType">Type of history information. see HistoryType</param>
        /// <param name="historyScale">Scale of history data. see HistoryScale</param>
        /// <param name="minValResult">Pointer to variable to write minimal value to.</param>
        /// <param name="maxValResult">Pointer to variable to write maximal value to.</param>
        public void getHistoryRange(HistoryType historyType, HistoryScale historyScale, out short minValResult, out short maxValResult)
        {
            if (historyType < 0 || historyType >= HistoryType.HISTORY_TYPE_COUNT ||
                historyScale < 0 || historyScale >= HistoryScale.HISTORY_SCALE_COUNT)
            {
                minValResult = 0;
                maxValResult = 0;
                return;
            }

            short[] history = null;
            switch (historyType)
            {
            case HistoryType.HISTORY_TYPE_RES:
                history = resHist;
                break;

            case HistoryType.HISTORY_TYPE_COM:
                history = comHist;
                break;

            case HistoryType.HISTORY_TYPE_IND:
                history = indHist;
                break;

            case HistoryType.HISTORY_TYPE_MONEY:
                history = moneyHist;
                break;

            case HistoryType.HISTORY_TYPE_CRIME:
                history = crimeHist;
                break;

            case HistoryType.HISTORY_TYPE_POLLUTION:
                history = pollutionHist;
                break;

            default:
                break;
            }

            int offset = 0;

            switch (historyScale)
            {
            case HistoryScale.HISTORY_SCALE_SHORT:
                offset = 0;
                break;

            case HistoryScale.HISTORY_SCALE_LONG:
                offset = 120;
                break;

            default:
                break;
            }

            short minVal = 32000;
            short maxVal = -32000;

            for (int i = 0; i < HISTORY_COUNT; i++)
            {
                short val = history[i + offset];

                minVal = Math.Min(val, minVal);
                maxVal = Math.Max(val, maxVal);
            }

            minValResult = minVal;
            maxValResult = maxVal;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get the minimal and maximal values of a historic graph.
        /// </summary>
        /// <param name="historyType">Type of history information. @see HistoryType</param>
        /// <param name="historyScale">Scale of history data. @see HistoryScale</param>
        /// <param name="minValResult">Pointer to variable to write minimal value to.</param>
        /// <param name="maxValResult">Pointer to variable to write maximal value to.</param>
        public void GetHistoryRange(HistoryType historyType, HistoryScale historyScale, ref short minValResult, ref short maxValResult)
        {
            if (historyType < 0 || historyType >= HistoryType.Count || historyScale < 0 || historyScale >= HistoryScale.Count)
            {
                minValResult = 0;
                maxValResult = 0;
                return;
            }

            short[] history = null;
            switch (historyType)
            {
            case HistoryType.Res:
                history = ResHist;
                break;

            case HistoryType.Com:
                history = ComHist;
                break;

            case HistoryType.Ind:
                history = IndHist;
                break;

            case HistoryType.Money:
                history = MoneyHist;
                break;

            case HistoryType.Crime:
                history = CrimeHist;
                break;

            case HistoryType.Pollution:
                history = PollutionHist;
                break;

            default:
                //NOT_REACHED();
                break;
            }

            int offset = 0;

            switch (historyScale)
            {
            case HistoryScale.Short:
                offset = 0;
                break;

            case HistoryScale.Long:
                offset = 120;
                break;

            default:
                //NOT_REACHED();
                break;
            }

            short minVal = 32000;
            short maxVal = -32000;

            for (int i = 0; i < Constants.HistoryCount; i++)
            {
                short val = history[i + offset];

                minVal = Math.Min(val, minVal);
                maxVal = Math.Max(val, maxVal);
            }

            minValResult = minVal;
            maxValResult = maxVal;
        }