123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- using MeterVision.db;
- using MeterVision.Util;
- using System;
- using System.ComponentModel;
- using System.Linq;
- using System.Windows;
- namespace MeterVision.model
- {
- public class SingleDetailItem : INotifyPropertyChanged
- {
- public event PropertyChangedEventHandler PropertyChanged;
- // 触发属性变更通知
- protected virtual void OnPropertyChanged(string propertyName)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- private int _index;
- public int Index
- {
- get => _index;
- set
- {
- if (_index != value)
- {
- _index = value;
- OnPropertyChanged(nameof(Index));
- }
- }
- }
- private string _singleDetailId;
- public string SingleDetailId
- {
- get => _singleDetailId;
- set
- {
- if (_singleDetailId != value)
- {
- _singleDetailId = value;
- OnPropertyChanged(nameof(SingleDetailId));
- }
- }
- }
- private string _createTime;
- public string CreateTime
- {
- get => _createTime;
- set
- {
- if (_createTime != value)
- {
- _createTime = value;
- OnPropertyChanged(nameof(CreateTime));
- }
- }
- }
- private string _srcImage;
- public string SrcImage
- {
- get => _srcImage;
- set
- {
- if (_srcImage != value)
- {
- _srcImage = value;
- OnPropertyChanged(nameof(SrcImage));
- }
- }
- }
- private int _runFlag;
- public int RunFlag
- {
- get => _runFlag;
- set
- {
- if (_runFlag != value)
- {
- _runFlag = value;
- OnPropertyChanged(nameof(RunFlag));
- OnPropertyChanged(nameof(ResultVisiable)); // 依赖 RunFlag 更新 ResultVisiable
- }
- }
- }
- private string _runTime;
- public string RunTime
- {
- get => _runTime;
- set
- {
- if (_runTime != value)
- {
- _runTime = value;
- OnPropertyChanged(nameof(RunTime));
- OnPropertyChanged(nameof(RunTime_date)); // 依赖 RunTime 更新 RunTIme_date
- OnPropertyChanged(nameof(RunTime_time)); // 依赖 RunTime 更新 RunTIme_time
- }
- }
- }
- public string RunTime_date => ThisApp.ConvertDateFormat_Date(RunTime);
- public string RunTime_time => ThisApp.ConvertDateFormat_Time(RunTime);
- private string _dstIamge;
- public string DstImage
- {
- get => _dstIamge;
- set
- {
- if (_dstIamge != value)
- {
- _dstIamge = value;
- OnPropertyChanged(nameof(DstImage));
- }
- }
- }
- private int _meterType;
- public int MeterType
- {
- get => _meterType;
- set
- {
- if (_meterType != value)
- {
- _meterType = value;
- OnPropertyChanged(nameof(MeterType));
- OnPropertyChanged(nameof(MeterTypeName)); // 依赖 MeterType 更新 MeterTypeName
- }
- }
- }
- public string MeterTypeName => Get_MeterTypeName();
- private int _digitCount;
- public int DigitCount
- {
- get => _digitCount;
- set
- {
- if (_digitCount != value)
- {
- _digitCount = value;
- OnPropertyChanged(nameof(DigitCount));
- OnPropertyChanged(nameof(NumCountName)); // 依赖 DigitCount 更新 NumCountName
- }
- }
- }
- private int _pointerCount;
- public int PointerCount
- {
- get => _pointerCount;
- set
- {
- if (_pointerCount != value)
- {
- _pointerCount = value;
- OnPropertyChanged(nameof(PointerCount));
- OnPropertyChanged(nameof(NumCountName)); // 依赖 PointerCount 更新 NumCountName
- }
- }
- }
- public string NumCountName => Get_NumCountName();
- private string _lastUnit;
- public string LastUnit
- {
- get => _lastUnit;
- set
- {
- if (_lastUnit != value)
- {
- _lastUnit = value;
- OnPropertyChanged(nameof(LastUnit));
- OnPropertyChanged(nameof(LastUnitName)); // 依赖 LastUnit 更新 LastUnitName
- }
- }
- }
- public string LastUnitName
- {
- get
- {
- if(MeterType > 0)
- {
- return $"尾数: {LastUnit}m³";
- }
- else
- {
- return "";
- }
- }
- }
- private int _resultType;
- public int ResultType
- {
- get => _resultType;
- set
- {
- if (_resultType != value)
- {
- _resultType = value;
- OnPropertyChanged(nameof(ResultType));
- OnPropertyChanged(nameof(ResultTypeColor)); // 依赖 ResultType 更新 ResultTypeColor
- }
- }
- }
- public string ResultTypeColor => Get_ResultTypeColor();
- private string _rawValue;
- public string RawValue
- {
- get => _rawValue;
- set
- {
- if (_rawValue != value)
- {
- _rawValue = value;
- if (MeterType == 0)
- {
- _rawValue = "";
- }
- OnPropertyChanged(nameof(RawValue));
- }
- }
- }
- private string _finalValue;
- public string FinalValue
- {
- get => _finalValue;
- set
- {
- if (_finalValue != value)
- {
- _finalValue = value;
- if(MeterType == 0)
- {
- _finalValue = "";
- }
- OnPropertyChanged(nameof(FinalValue));
- }
- }
- }
- private string _aiVer;
- public string AiVer
- {
- get => _aiVer;
- set
- {
- if (_aiVer != value)
- {
- _aiVer = value;
- OnPropertyChanged(nameof(AiVer));
- }
- }
- }
- private string _debugInfo;
- public string DebugInfo
- {
- get => _debugInfo;
- set
- {
- if (_debugInfo != value)
- {
- _debugInfo = value;
- OnPropertyChanged(nameof(DebugInfo));
- OnPropertyChanged(nameof(AI_result_array)); // 依赖 DebugInfo 更新 AI_result_array
- }
- }
- }
- public string[] AI_result_array => Get_DebugInfoArray();
- private string _logPath;
- public string LogPath
- {
- get => _logPath;
- set
- {
- if (_logPath != value)
- {
- _logPath = value;
- OnPropertyChanged(nameof(LogPath));
- }
- }
- }
- private string _memo;
- public string Memo
- {
- get => _memo;
- set
- {
- if (_memo != value)
- {
- _memo = value;
- OnPropertyChanged(nameof(Memo));
- }
- }
- }
- public Visibility ResultVisiable => (RunFlag == 1) ? Visibility.Visible : Visibility.Hidden;
- public SingleDetailItem() { }
- public SingleDetailItem(TSingleDetail singleDetail)
- {
- ObjectHelper.CopyMatchingFields(singleDetail, this);
- }
- private string Get_MeterTypeName()
- {
- switch (MeterType)
- {
- case 1:
- return "数字+指针";
- case 2:
- return "全指针";
- case 3:
- return "全数字";
- case 4:
- return "LED表";
- case 5:
- return "压力表";
- default:
- return "非水表";
- }
- }
- private string Get_NumCountName()
- {
- switch (MeterType)
- {
- case 1:
- return $"数字: {DigitCount} 指针{PointerCount}";
- case 2:
- return $"指针: {PointerCount}";
- default:
- return string.Empty;
- }
- }
- private string Get_ResultTypeColor()
- {
- switch (ResultType)
- {
- case 1:
- case 2:
- case 7:
- case 8:
- return "#67c23a"; // 绿色
- default:
- return "#e6a23c"; // 橙色
- }
- }
- private string[] Get_DebugInfoArray()
- {
- string[] sInfos = DebugInfo.Split(',');
- if (sInfos.Length != 24)
- {
- sInfos = Enumerable.Range(0, 24).Select(_ => "").ToArray();
- }
- return sInfos.Select(s => s == "88" ? "" : s).ToArray();
- }
- //-------------------------------------------------
- }
- }
|