예제 #1
0
            public override void RunSuite()
            {
                // Make some test objects.
                DateTime dt1 = new DateTime(2005, 5, 9, 15, 47, 39, 123);
                DateTime dt2 = new DateTime(2022, 11, 24, 7, 29, 6, 801);

                TimeTag ttImmediate = new TimeTag();                 // default constructor
                TimeTag tt1         = new TimeTag(dt1);              // specific constructor
                TimeTag tt2         = new TimeTag(dt2);
                TimeTag tt1raw      = new TimeTag(tt1.Raw);          // constructor from raw
                TimeTag tt2copy     = new TimeTag(new TimeTag(dt2)); // copy constructor

                // Check them all.
                UT_EQUAL(ttImmediate.ToString(), "When:Immediate");
                UT_EQUAL(tt1.ToString(), "When:2005-05-09 15:47:39.000 Seconds:3324642459 Fraction:528280977");
                UT_EQUAL(tt2.ToString(), "When:2022-11-24 07:29:06.000 Seconds:3878263746 Fraction:3440268803");

                UT_TRUE(tt1.Equals(tt1));
                UT_FALSE(ttImmediate.Equals(tt2));
                UT_FALSE(tt1raw.Equals(tt1));

                UT_TRUE(tt1 == tt1raw);
                UT_TRUE(tt2 == tt2copy);
                UT_TRUE(tt1 != tt2);
                UT_FALSE(tt1 != tt1raw);
                UT_FALSE(tt2 != tt2copy);
                UT_FALSE(tt1 == tt2);

                UT_TRUE(tt2 >= tt1);
                UT_TRUE(tt2 > tt1);
                UT_FALSE(tt1 >= tt2);
                UT_FALSE(tt1 > tt2);

                UT_TRUE(tt1 <= tt2);
                UT_TRUE(tt1 < tt2);
                UT_FALSE(tt2 <= tt1);
                UT_FALSE(tt2 < tt1);
            }
예제 #2
0
 public override string ToString()
 {
     return(TimeTag.ToString("MM/dd/yyyy,HH:mm:ss,") + Sensor.Name + "," + SensorState + "," + Resident.Name + "," + Activity.Name + "," + Comments);
 }
예제 #3
0
 public override string ToString()
 {
     return(TimeTag.ToString("MM/dd/yyyy,HH:mm:ss,") + SensorName + "," + SensorState + "," + OccupantId + "," + ActivityLabel + "," + Comments);
 }
예제 #4
0
        /// <summary>
        /// Returns the text representation of <see cref="ArchiveDataPoint"/> object in the specified <paramref name="format"/>
        /// using the specified <paramref name="provider"/>.
        /// </summary>
        /// <param name="format">Format of text output (I for ID, T for Time, V for Value, Q for Quality).</param>
        /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information.</param>
        /// <returns>A <see cref="string"/> value.</returns>
        public virtual string ToString(string format, IFormatProvider provider)
        {
            if (provider == null)
            {
                provider = CultureInfo.InvariantCulture;
            }

            switch (format.ToUpperInvariant())
            {
            case "I":
            case "ID":
                return(m_historianID.ToString(provider));

            case "T":
            case "TIME":
                return(m_time.ToString());

            case "U":
            case "UNIXTIME":
                return((new UnixTimeTag(m_time.ToDateTime())).Value.ToString("0.000", provider));

            case "V":
            case "VALUE":
                return(m_value.ToString(provider));

            case "Q":
            case "QUALITY":
                return(Quality.ToString());

            case "N":
            case "NAME":
                if (Metadata != null)
                {
                    return(Metadata.Name);
                }
                return("");

            case "D":
            case "DESCRIPTION":
                if (Metadata != null)
                {
                    return(Metadata.Description);
                }
                return("");

            case "S":
            case "SOURCE":
                if (Metadata != null)
                {
                    return(Metadata.PlantCode);
                }
                return("");

            case "S1":
            case "SYNONYM1":
                if (Metadata != null)
                {
                    return(Metadata.Synonym1);
                }
                return("");

            case "S2":
            case "SYNONYM2":
                if (Metadata != null)
                {
                    return(Metadata.Synonym2);
                }
                return("");

            case "S3":
            case "SYNONYM3":
                if (Metadata != null)
                {
                    return(Metadata.Synonym3);
                }
                return("");

            default:
                throw new FormatException("Invalid format identifier specified for ArchiveDataPoint: " + format);
            }
        }