Exemple #1
0
        /// <summary>
        /// Get a list of the field information to be used when generating the CSV fields associated with each event variable.
        /// </summary>
        /// <returns>A <c>List</c> of <c>FieldInformation_t</c> structures that are to be used to generate the CSV fields for the EventVariable class.</returns>
        private List <FieldInformation_t> GetFieldInformationEventVariable()
        {
            // A list of the CSV fields that are to be output for each event variable.
            List <FieldInformation_t> cSVFieldInformationList = new List <FieldInformation_t>();

            Type type = typeof(EventVariable);

            FieldInformation_t fieldInformation;

            // fieldInformation = new FieldInformation_t(FieldNameCSVRecordType, typeof(string), null);
            // cSVFieldInformationList.Add(fieldInformation);

            // fieldInformation = new FieldInformation_t(FieldNameVariableType, typeof(VariableType), type.GetProperty(KeyPropertyNameEventVariableVariableType));
            // cSVFieldInformationList.Add(fieldInformation);

            // fieldInformation = new FieldInformation_t(FieldNameEventVariableIdentifier, typeof(short), type.GetProperty(KeyPropertyNameEventVariableIdentifier));
            // cSVFieldInformationList.Add(fieldInformation);

            fieldInformation = new FieldInformation_t(FieldNameName, typeof(string), type.GetProperty(KeyPropertyNameEventVariableName));
            cSVFieldInformationList.Add(fieldInformation);

            fieldInformation = new FieldInformation_t(FieldNameValueFromTarget, typeof(double), null);
            cSVFieldInformationList.Add(fieldInformation);

            fieldInformation = new FieldInformation_t(FieldNameUnits, typeof(string), type.GetProperty(KeyPropertyNameEventVariableUnits));
            cSVFieldInformationList.Add(fieldInformation);

            return(cSVFieldInformationList);
        }
Exemple #2
0
        /// <summary>
        /// Get a list of the field information to be used when generating the CSV fields associated with each event record.
        /// </summary>
        /// <returns>A <c>List</c> of <c>FieldInformation_t</c> structures that are to be used to generate the CSV fields for the EventRecord class.</returns>
        private List <FieldInformation_t> GetFieldInformationEventRecord()
        {
            // A list of the CSV fields that are to be output for each event record.
            List <FieldInformation_t> cSVFieldInformationList = new List <FieldInformation_t>();

            Type type = typeof(EventRecord);

            FieldInformation_t fieldInformation;

            // fieldInformation = new FieldInformation_t(FieldNameCSVRecordType, typeof(string), null);
            // cSVFieldInformationList.Add(fieldInformation);

            fieldInformation = new FieldInformation_t(FieldNameLogIdentifier, typeof(int), null);
            cSVFieldInformationList.Add(fieldInformation);

            fieldInformation = new FieldInformation_t(FieldNameCarIdentifier, typeof(String), type.GetProperty(KeyPropertyNameEventRecordCarIdentifier));
            cSVFieldInformationList.Add(fieldInformation);

            fieldInformation = new FieldInformation_t(FieldNameDescription, typeof(string), type.GetProperty(KeyPropertyNameEventRecordDescription));
            cSVFieldInformationList.Add(fieldInformation);

            fieldInformation = new FieldInformation_t(FieldNameDate, typeof(DateTime), null);
            cSVFieldInformationList.Add(fieldInformation);

            fieldInformation = new FieldInformation_t(FieldNameTime, typeof(DateTime), null);
            cSVFieldInformationList.Add(fieldInformation);

            fieldInformation = new FieldInformation_t(FieldNameDay, typeof(string), null);
            cSVFieldInformationList.Add(fieldInformation);

            // fieldInformation = new FieldInformation_t(FieldNameIdentifier, typeof(short), type.GetProperty(KeyPropertyNameEventRecordIdentifier));
            // cSVFieldInformationList.Add(fieldInformation);

            // fieldInformation = new FieldInformation_t(FieldNameHelpIndex, typeof(int), type.GetProperty(KeyPropertyNameEventRecordHelpIndex));
            // cSVFieldInformationList.Add(fieldInformation);

            fieldInformation = new FieldInformation_t(FieldNameStreamSaved, typeof(string), null);
            cSVFieldInformationList.Add(fieldInformation);

            // fieldInformation = new FieldInformation_t(FieldNameStreamNumber, typeof(short), type.GetProperty(KeyPropertyNameEventRecordStreamNumber));
            // cSVFieldInformationList.Add(fieldInformation);

            fieldInformation = new FieldInformation_t(FieldNameEventVariableCount, typeof(int), null);
            cSVFieldInformationList.Add(fieldInformation);

            return(cSVFieldInformationList);
        }
Exemple #3
0
        /// <summary>
        /// Convert the raw property value object to a string depending upon the specified CSV field type.
        /// </summary>
        /// <param name="raw">The raw value of the property that is currently being processed.</param>
        /// <param name="fieldInformation">The <c>FieldInformation_t</c> structure that is currently being processed.</param>
        /// <returns>A string representation of the Property value.</returns>
        private static string ConvertRawPropertyValueToString(object raw, ref FieldInformation_t fieldInformation)
        {
            string valueAsString;

            if (raw == null)
            {
                valueAsString = string.Empty;
            }
            else
            {
                try
                {
                    // Convert the raw value to a string in accordance with the property type.
                    if (fieldInformation.CSVFieldType == typeof(UInt32))
                    {
                        UInt32 rawAsUInt32 = Convert.ToUInt32(raw);
                        valueAsString = CommonConstants.HexValueIdentifier + rawAsUInt32.ToString(CommonConstants.FormatStringHex + "8");
                    }
                    else if (fieldInformation.CSVFieldType == typeof(UInt16))
                    {
                        UInt16 rawAsUInt16 = Convert.ToUInt16(raw);
                        valueAsString = CommonConstants.HexValueIdentifier + rawAsUInt16.ToString(CommonConstants.FormatStringHex + (sizeof(UInt16) * 2).ToString());
                    }
                    else if (fieldInformation.CSVFieldType == typeof(byte))
                    {
                        byte rawAsByte = Convert.ToByte(raw);
                        valueAsString = CommonConstants.HexValueIdentifier + rawAsByte.ToString(CommonConstants.FormatStringHex + (sizeof(UInt16) * 2).ToString());
                    }
                    else if (fieldInformation.CSVFieldType == typeof(string))
                    {
                        valueAsString = raw.ToString();
                    }
                    else
                    {
                        valueAsString = raw.ToString();
                    }
                }
                catch (Exception)
                {
                    valueAsString = string.Empty;
                }
            }

            return(valueAsString);
        }