Example #1
0
 public static float ValidData(LJV7IF_MEASURE_DATA data)
 {
     if (data.byDataInfo == (int)LJV7IF_MEASURE_DATA_INFO.LJV7IF_MEASURE_DATA_INFO_VALID &&
         data.byJudge == (int)LJV7IF_JUDGE_RESULT.LJV7IF_JUDGE_RESULT_GO)
     {
         return(data.fValue);
     }
     return(-1);
 }
Example #2
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 #3
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);
        }