Example #1
0
        /// <summary>
        /// Get the byte size of the structure.
        /// </summary>
        /// <param name="profileHeader">Structure whose byte size you want to get.</param>
        /// <returns>Byte size</returns>
        public static int GetByteSize(TypeOfStruct type)
        {
            switch (type)
            {
            case TypeOfStruct.PROFILE_HEADER:
                LJV7IF_PROFILE_HEADER profileHeader = new LJV7IF_PROFILE_HEADER();
                return(Marshal.SizeOf(profileHeader));

            case TypeOfStruct.PROFILE_FOOTER:
                LJV7IF_PROFILE_FOOTER profileFooter = new LJV7IF_PROFILE_FOOTER();
                return(Marshal.SizeOf(profileFooter));

            case TypeOfStruct.MEASURE_DATA:
                LJV7IF_MEASURE_DATA measureData = new LJV7IF_MEASURE_DATA();
                return(Marshal.SizeOf(measureData));
            }

            return(0);
        }
Example #2
0
        /// <summary>
        /// Get the string for log output.
        /// </summary>
        /// <param name="obj">Structure that you want to convert to a string</param>
        /// <returns>String for log output</returns>
        public static StringBuilder ConvertToLogString(LJV7IF_MEASURE_DATA measureData)
        {
            StringBuilder sb = new StringBuilder();

            string dataInfo = string.Empty;

            switch (measureData.byDataInfo)
            {
            case (int)LJV7IF_MEASURE_DATA_INFO.LJV7IF_MEASURE_DATA_INFO_VALID:
                dataInfo = @"Valid		";
                break;

            case (int)LJV7IF_MEASURE_DATA_INFO.LJV7IF_MEASURE_DATA_INFO_ALARM:
                dataInfo = @"Alarm value  ";
                break;

            case (int)LJV7IF_MEASURE_DATA_INFO.LJV7IF_MEASURE_DATA_INFO_WAIT:
                dataInfo = @"Judgment wait value  ";
                break;

            default:
                dataInfo = @"Unexpected value	";
                break;
            }
            sb.Append(dataInfo);
            string judge = string.Empty;

            switch (measureData.byJudge)
            {
            case 0:
                judge = @"______  ";
                break;

            case (int)LJV7IF_JUDGE_RESULT.LJV7IF_JUDGE_RESULT_HI:
                judge = @"HI____  ";
                break;

            case (int)LJV7IF_JUDGE_RESULT.LJV7IF_JUDGE_RESULT_GO:
                judge = @"__GO__  ";
                break;

            case (int)LJV7IF_JUDGE_RESULT.LJV7IF_JUDGE_RESULT_LO:
                judge = @"____LO  ";
                break;

            case (int)(LJV7IF_JUDGE_RESULT.LJV7IF_JUDGE_RESULT_HI | LJV7IF_JUDGE_RESULT.LJV7IF_JUDGE_RESULT_LO):
                judge = @"HI__LO  ";
                break;

            case (int)(LJV7IF_JUDGE_RESULT.LJV7IF_JUDGE_RESULT_HI
                       | LJV7IF_JUDGE_RESULT.LJV7IF_JUDGE_RESULT_GO
                       | LJV7IF_JUDGE_RESULT.LJV7IF_JUDGE_RESULT_LO):
                judge = @"ALL BIT  ";
                break;

            default:
                judge = @"UNEXPECTED ";
                break;
            }
            sb.Append(judge);
            sb.Append(measureData.fValue.ToString());

            return(sb);
        }