Example #1
0
        /// <summary>
        /// Decode data from database and fill AllData[currentRow] with results
        /// </summary>
        /// <param name="dataString"></param>
        /// <param name="dateStart"></param>
        /// <param name="dateEnd"></param>
        /// <param name="id"></param>
        /// <param name="delim"></param>
        public void FillDataRow(string dataString, int id, char delim)
        {
            string   validFlag;
            string   timestamp;
            DateTime currentDate, readDate;
            TimeSpan ts;
            int      current15MinValue = 0;

            string[] rows = dataString.Split(delim); // split monolithic data to single rows
            currentDate = startDate;

            // Fill everything with data missing
            ts = endDate.Subtract(currentDate);
            while (ts.TotalMinutes != 0)
            {
                data[current15MinValue] = new Data15MinClass(currentDate); // Fill with "missing" data
                currentDate             = currentDate.AddMinutes(15);      // Update current date
                current15MinValue++;
                ts = endDate.Subtract(currentDate);
            }


            // Sometimes there wont be any data
            if (rows.Length == 1 && dataString.Equals(""))
            {// This is when no results came from db
                deviceID = id;
                return;
            }
            else
            { // Everything is ok (we have some data), loop thru every row and parse it
                for (int i = 0; i < rows.Length; i++)
                {
                    #warning I experimented with null values

                    // Read values
                    string[] temp = rows[i].Split(';'); // Split row from db to separated searched values
                    // t[0]=valid, t[1]=ia, t[2]=ib, t[3]=ic, t[4]=vab, t[5]=vbc, t[6]=vca, t[7]=read_time
                    validFlag = temp[0];
                    timestamp = temp[7];
                    readDate  = HelperClass.ConvertOracleTimeToDateTime(timestamp);
                    FloatValues fv = new FloatValues(temp[1], temp[2], temp[3], temp[4], temp[5], temp[6], temp[8]);
                    if (!fv.successfullyParsed)
                    {
                        // This is null value, replace with default values for null
                        fv.ReplaceWithNullValue();
                    }

                    // Get number of minutes since start
                    ts = readDate.Subtract(startDate);

                    // Calculate 15min sector and update it
                    current15MinValue = (int)ts.TotalMinutes / 15;
                    data[current15MinValue].UpdateData15min(Convert.ToInt32(validFlag), fv);
                }
            }
            deviceID = id;
        }
        private Color GetColorFromValue(Data15MinClass s)
        {
            // Data repeat flag is orange
            if (s.flags.dataRepeatFlag)
            {
                return(ConfigClass.colors.colorRepeat);
            }

            // Data duplicate flag is Olive, but CornflowerBlue if zero and Orchid if null
            if (s.flags.duplicateFlag)
            {
                if (s.Values.successfullyParsed)
                {
                    // This means its valid or zero

                    if (FloatHelper.CheckIfZero(s.Values)) // If zero color it with zero color
                    {
                        return(ConfigClass.colors.colorZero);
                    }
                    return(ConfigClass.colors.colorDuplicate);; // Otherwise color it with olive
                }
                else
                {
                    // This means its null
                    return(ConfigClass.colors.colorNull);
                }
            }

            // Missing flag is OrangeRed
            if (s.flags.missingFlag)
            {
                return(ConfigClass.colors.colorMissing);
            }

            // Null flag is Orchid
            if (s.flags.nullFlag)
            {
                return(ConfigClass.colors.colorNull);
            }

            // Zero flag is CornflowerBlue
            if (s.flags.zeroFlag)
            {
                return(ConfigClass.colors.colorZero);
            }

            // invalid flag is Red
            if (s.flags.invalidFlag)
            {
                return(ConfigClass.colors.colorInvalid);
            }

            // If no flags are active that means data is just valid
            return(ConfigClass.colors.colorValid);
        }
Example #3
0
 public void ReplaceData(Data15MinClass d)
 {
 }