EquipmentSettingViewModel.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. using SWRIS.Dtos;
  2. using SWRIS.Enums;
  3. using SWRIS.Extensions;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. namespace SWRIS.Models.ViewModel
  8. {
  9. public class EquipmentSettingViewModel : INotifyPropertyChanged
  10. {
  11. private int ropeNumber;
  12. private string ropeName;
  13. private string ipAddress;
  14. private string serialNo;
  15. private string supplier;
  16. private int ropeCoreType;
  17. private int wireMaterialType;
  18. private int wireSurfaceType;
  19. private int layType;
  20. private bool disableAlarm;
  21. private int[] inUseSensor = new int[] { 1, 2, 3, 4 };
  22. private double liftHightRatio = 1;
  23. private RiskLevel soundRiskLevel = RiskLevel.Moderate;
  24. private ParameterData parameter;
  25. private bool isConnected;
  26. private RunningStatus runningStatus = RunningStatus.SpatialNormal;
  27. /// <summary>
  28. /// 绳号
  29. /// </summary>
  30. public int RopeNumber
  31. {
  32. get { return ropeNumber; }
  33. set
  34. {
  35. ropeNumber = value;
  36. OnPropertyChanged(nameof(RopeNumber));
  37. }
  38. }
  39. /// <summary>
  40. /// 钢丝绳名称
  41. /// </summary>
  42. public string RopeName
  43. {
  44. get { return ropeName; }
  45. set
  46. {
  47. ropeName = value;
  48. OnPropertyChanged(nameof(RopeName));
  49. }
  50. }
  51. /// <summary>
  52. /// Ip地址
  53. /// </summary>
  54. public string IpAddress
  55. {
  56. get { return ipAddress; }
  57. set
  58. {
  59. ipAddress = value;
  60. OnPropertyChanged(nameof(IpAddress));
  61. }
  62. }
  63. /// <summary>
  64. /// 序列号
  65. /// </summary>
  66. public string SerialNo
  67. {
  68. get { return serialNo; }
  69. set
  70. {
  71. serialNo = value;
  72. OnPropertyChanged(nameof(SerialNo));
  73. }
  74. }
  75. /// <summary>
  76. /// 供应商
  77. /// </summary>
  78. public string Supplier
  79. {
  80. get { return supplier; }
  81. set
  82. {
  83. supplier = value;
  84. OnPropertyChanged(nameof(Supplier));
  85. }
  86. }
  87. /// <summary>
  88. /// 绳芯类型 1 钢芯 2 纤维芯
  89. /// </summary>
  90. public int RopeCoreType
  91. {
  92. get { return ropeCoreType; }
  93. set
  94. {
  95. ropeCoreType = value;
  96. OnPropertyChanged(nameof(RopeCoreType));
  97. }
  98. }
  99. /// <summary>
  100. /// 钢丝材质 1 碳钢 2 不锈钢
  101. /// </summary>
  102. public int WireMaterialType
  103. {
  104. get { return wireMaterialType; }
  105. set
  106. {
  107. wireMaterialType = value;
  108. OnPropertyChanged(nameof(WireMaterialType));
  109. }
  110. }
  111. /// <summary>
  112. /// 表面状态 1 光面 2 A级镀锌 3 B级镀锌
  113. /// </summary>
  114. public int WireSurfaceType
  115. {
  116. get { return wireSurfaceType; }
  117. set
  118. {
  119. wireSurfaceType = value;
  120. OnPropertyChanged(nameof(WireSurfaceType));
  121. }
  122. }
  123. /// <summary>
  124. /// 捻向 1 右交互捻 2 左交互捻 3 右同向捻 4 左同向捻
  125. /// </summary>
  126. public int LayType
  127. {
  128. get { return layType; }
  129. set
  130. {
  131. layType = value;
  132. OnPropertyChanged(nameof(LayType));
  133. }
  134. }
  135. /// <summary>
  136. /// 绳长/高度倍率
  137. /// </summary>
  138. public double LiftHightRatio
  139. {
  140. get { return liftHightRatio; }
  141. set
  142. {
  143. liftHightRatio = value;
  144. OnPropertyChanged(nameof(LiftHightRatio));
  145. }
  146. }
  147. public RiskLevel SoundRiskLevel
  148. {
  149. get { return soundRiskLevel; }
  150. set
  151. {
  152. soundRiskLevel = value;
  153. OnPropertyChanged(nameof(SoundRiskLevel));
  154. }
  155. }
  156. public ParameterData Parameter
  157. {
  158. get { return parameter; }
  159. set
  160. {
  161. parameter = value;
  162. OnPropertyChanged(nameof(Parameter));
  163. }
  164. }
  165. public bool IsConnected
  166. {
  167. get { return isConnected; }
  168. set
  169. {
  170. isConnected = value;
  171. OnPropertyChanged(nameof(IsConnected));
  172. }
  173. }
  174. public bool DisableAlarm
  175. {
  176. get { return disableAlarm; }
  177. set
  178. {
  179. disableAlarm = value;
  180. OnPropertyChanged(nameof(DisableAlarm));
  181. }
  182. }
  183. public int[] InUseSensor
  184. {
  185. get { return inUseSensor; }
  186. set
  187. {
  188. inUseSensor = value;
  189. OnPropertyChanged(nameof(InUseSensor));
  190. }
  191. }
  192. public RunningStatus RunningStatus
  193. {
  194. get { return runningStatus; }
  195. set
  196. {
  197. runningStatus = value;
  198. OnPropertyChanged(nameof(RunningStatus));
  199. }
  200. }
  201. public List<KeyAndValueDto> RopeCoreTypes => TypeExtension.ToKeyAndDescriptionList(typeof(RopeCoreType));
  202. public List<KeyAndValueDto> WireMaterialTypes => TypeExtension.ToKeyAndDescriptionList(typeof(WireMaterialType));
  203. public List<KeyAndValueDto> LayTypes => TypeExtension.ToKeyAndDescriptionList(typeof(LayType));
  204. public List<KeyAndValueDto> WireSurfaceTypes => TypeExtension.ToKeyAndDescriptionList(typeof(WireSurfaceType));
  205. public List<KeyAndValueDto> RiskLevels => TypeExtension.ToKeyAndDescriptionList(typeof(RiskLevel));
  206. public event PropertyChangedEventHandler PropertyChanged;
  207. protected internal virtual void OnPropertyChanged(string propertyName)
  208. {
  209. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  210. }
  211. }
  212. public class ParameterData : INotifyPropertyChanged
  213. {
  214. private string mainBoardSoftwareVersion;
  215. private short sensorCount;
  216. private float samplingStep;
  217. private short frequencyDivisionFactor;
  218. private short timeDomainFrequency;
  219. private short damageThreshold;
  220. private short scrapUpperLimit;
  221. private short frontMagnetLength;
  222. private short backMagnetLength;
  223. private float valueCoefficient;
  224. private float effectiveStrokeLength;
  225. private short zeroPositionCorrectionDuration;
  226. private short zeroPositionCorrectionOffset;
  227. private float warningValue;
  228. private float alarmValue;
  229. private short soundLightAlarmAutoResetMode;
  230. private short wireRopeType;
  231. private short wireRopeCount;
  232. private float wireRopeLength;
  233. private float wireRopeDiameter;
  234. private short wireRopeStrandCount;
  235. private short wireRopeStrandWireCount;
  236. private EncoderDirection encoderDirection;
  237. private DateTime? systemTime;
  238. private float twistFactor;
  239. private float firstCalibrationPositiont;
  240. private float secondCalibrationPositiont;
  241. /// <summary>
  242. /// 主板软件版本号
  243. /// </summary>
  244. public string MainBoardSoftwareVersion
  245. {
  246. get => mainBoardSoftwareVersion;
  247. set
  248. {
  249. mainBoardSoftwareVersion = value;
  250. OnPropertyChanged(nameof(MainBoardSoftwareVersion));
  251. }
  252. }
  253. /// <summary>
  254. /// 传感器数量
  255. /// </summary>
  256. public short SensorCount
  257. {
  258. get => sensorCount;
  259. set
  260. {
  261. sensorCount = value;
  262. OnPropertyChanged(nameof(SensorCount));
  263. }
  264. }
  265. /// <summary>
  266. /// 采样步长 单位:mm/点 4字节浮点数
  267. /// </summary>
  268. public float SamplingStep
  269. {
  270. get => samplingStep;
  271. set
  272. {
  273. samplingStep = value;
  274. OnPropertyChanged(nameof(SamplingStep));
  275. }
  276. }
  277. /// <summary>
  278. /// 分频系数
  279. /// </summary>
  280. public short FrequencyDivisionFactor
  281. {
  282. get => frequencyDivisionFactor;
  283. set
  284. {
  285. frequencyDivisionFactor = value;
  286. OnPropertyChanged(nameof(FrequencyDivisionFactor));
  287. }
  288. }
  289. /// <summary>
  290. /// 时域频率 2字节整型
  291. /// </summary>
  292. public short TimeDomainFrequency
  293. {
  294. get => timeDomainFrequency;
  295. set
  296. {
  297. timeDomainFrequency = value;
  298. OnPropertyChanged(nameof(TimeDomainFrequency));
  299. }
  300. }
  301. /// <summary>
  302. /// 损伤门限 2字节整型
  303. /// </summary>
  304. public short DamageThreshold
  305. {
  306. get => damageThreshold;
  307. set
  308. {
  309. damageThreshold = value;
  310. OnPropertyChanged(nameof(DamageThreshold));
  311. }
  312. }
  313. /// <summary>
  314. /// 报废上限
  315. /// </summary>
  316. public short ScrapUpperLimit
  317. {
  318. get => scrapUpperLimit;
  319. set
  320. {
  321. scrapUpperLimit = value;
  322. OnPropertyChanged(nameof(ScrapUpperLimit));
  323. }
  324. }
  325. /// <summary>
  326. /// 前磁极长度 单位:mm 2字节整型
  327. /// </summary>
  328. public short FrontMagnetLength
  329. {
  330. get => frontMagnetLength;
  331. set
  332. {
  333. frontMagnetLength = value;
  334. OnPropertyChanged(nameof(FrontMagnetLength));
  335. }
  336. }
  337. /// <summary>
  338. /// 后磁极长度 单位:mm 2字节整型
  339. /// </summary>
  340. public short BackMagnetLength
  341. {
  342. get => backMagnetLength;
  343. set
  344. {
  345. backMagnetLength = value;
  346. OnPropertyChanged(nameof(BackMagnetLength));
  347. }
  348. }
  349. /// <summary>
  350. /// 量值系数 4字节浮点数
  351. /// </summary>
  352. public float ValueCoefficient
  353. {
  354. get => valueCoefficient;
  355. set
  356. {
  357. valueCoefficient = value;
  358. OnPropertyChanged(nameof(ValueCoefficient));
  359. }
  360. }
  361. /// <summary>
  362. /// 零位有效行程长度,单位:m 4字节浮点数
  363. /// </summary>
  364. public float EffectiveStrokeLength
  365. {
  366. get => effectiveStrokeLength;
  367. set
  368. {
  369. effectiveStrokeLength = value;
  370. OnPropertyChanged(nameof(EffectiveStrokeLength));
  371. }
  372. }
  373. /// <summary>
  374. /// 零位矫正静止时长,单位:秒 2字节整型
  375. /// </summary>
  376. public short ZeroPositionCorrectionDuration
  377. {
  378. get => zeroPositionCorrectionDuration;
  379. set
  380. {
  381. zeroPositionCorrectionDuration = value;
  382. OnPropertyChanged(nameof(ZeroPositionCorrectionDuration));
  383. }
  384. }
  385. /// <summary>
  386. /// 零位矫正允许偏移量,单位:mm 2字节整型
  387. /// </summary>
  388. public short ZeroPositionCorrectionOffset
  389. {
  390. get => zeroPositionCorrectionOffset;
  391. set
  392. {
  393. zeroPositionCorrectionOffset = value;
  394. OnPropertyChanged(nameof(ZeroPositionCorrectionOffset));
  395. }
  396. }
  397. /// <summary>
  398. /// 预警(黄色报警)量值 4字节浮点数
  399. /// </summary>
  400. public float WarningValue
  401. {
  402. get => warningValue;
  403. set
  404. {
  405. warningValue = value;
  406. OnPropertyChanged(nameof(WarningValue));
  407. }
  408. }
  409. /// <summary>
  410. /// 报警(红色报警)量值 4字节浮点数
  411. /// </summary>
  412. public float AlarmValue
  413. {
  414. get => alarmValue;
  415. set
  416. {
  417. alarmValue = value;
  418. OnPropertyChanged(nameof(AlarmValue));
  419. }
  420. }
  421. /// <summary>
  422. /// 声光报警自动重置方式,0=不自动重置,>0=延时自动重置,-1=开始新一次检测时重置
  423. /// </summary>
  424. public short SoundLightAlarmAutoResetMode
  425. {
  426. get => soundLightAlarmAutoResetMode;
  427. set
  428. {
  429. soundLightAlarmAutoResetMode = value;
  430. OnPropertyChanged(nameof(SoundLightAlarmAutoResetMode));
  431. }
  432. }
  433. /// <summary>
  434. /// 钢丝绳类型 0=塔吊单绳,1=电梯排绳
  435. /// </summary>
  436. public short WireRopeType
  437. {
  438. get => wireRopeType;
  439. set
  440. {
  441. wireRopeType = value;
  442. OnPropertyChanged(nameof(WireRopeType));
  443. }
  444. }
  445. /// <summary>
  446. ///钢丝绳数量 1字节
  447. /// </summary>
  448. public short WireRopeCount
  449. {
  450. get => wireRopeCount;
  451. set
  452. {
  453. wireRopeCount = value;
  454. OnPropertyChanged(nameof(WireRopeCount));
  455. }
  456. }
  457. /// <summary>
  458. /// 钢丝绳长度,单位:m 4字节浮点数
  459. /// </summary>
  460. public float WireRopeLength
  461. {
  462. get => wireRopeLength;
  463. set
  464. {
  465. wireRopeLength = value;
  466. OnPropertyChanged(nameof(WireRopeLength));
  467. }
  468. }
  469. /// <summary>
  470. /// 钢丝绳直径,单位:mm 4字节浮点数
  471. /// </summary>
  472. public float WireRopeDiameter
  473. {
  474. get => wireRopeDiameter;
  475. set
  476. {
  477. wireRopeDiameter = value;
  478. OnPropertyChanged(nameof(WireRopeDiameter));
  479. }
  480. }
  481. /// <summary>
  482. /// 钢丝绳股数 1字节
  483. /// </summary>
  484. public short WireRopeStrandCount
  485. {
  486. get => wireRopeStrandCount;
  487. set
  488. {
  489. wireRopeStrandCount = value;
  490. OnPropertyChanged(nameof(WireRopeStrandCount));
  491. }
  492. }
  493. /// <summary>
  494. /// 钢丝绳每股丝数,2字节整型
  495. /// </summary>
  496. public short WireRopeStrandWireCount
  497. {
  498. get => wireRopeStrandWireCount;
  499. set
  500. {
  501. wireRopeStrandWireCount = value;
  502. OnPropertyChanged(nameof(WireRopeStrandWireCount));
  503. }
  504. }
  505. /// <summary>
  506. /// 编码器方向,1=正向,2=反向
  507. /// </summary>
  508. public EncoderDirection EncoderDirection
  509. {
  510. get => encoderDirection;
  511. set
  512. {
  513. encoderDirection = value;
  514. OnPropertyChanged(nameof(EncoderDirection));
  515. }
  516. }
  517. /// <summary>
  518. /// 系统时间
  519. /// </summary>
  520. public DateTime? SystemTime
  521. {
  522. get => systemTime;
  523. set
  524. {
  525. systemTime = value;
  526. OnPropertyChanged(nameof(SystemTime));
  527. }
  528. }
  529. /// <summary>
  530. /// 判伤捻距系数,浮点数,判伤捻距默认为7d,可通过此参数设置系数来调整(与损伤判定相关)。
  531. /// 默认值为1.0,设置2.0表示判伤捻距为2 x 7 = 14d
  532. /// </summary>
  533. public float TwistFactor
  534. {
  535. get => twistFactor;
  536. set
  537. {
  538. twistFactor = value;
  539. OnPropertyChanged(nameof(TwistFactor));
  540. }
  541. }
  542. /// <summary>
  543. /// 限位1校准位置
  544. /// </summary>
  545. public float FirstCalibrationPositiont
  546. {
  547. get => firstCalibrationPositiont;
  548. set
  549. {
  550. firstCalibrationPositiont = value;
  551. OnPropertyChanged(nameof(FirstCalibrationPositiont));
  552. }
  553. }
  554. /// <summary>
  555. /// 限位2校准位置
  556. /// </summary>
  557. public float SecondCalibrationPositiont
  558. {
  559. get => secondCalibrationPositiont;
  560. set
  561. {
  562. secondCalibrationPositiont = value;
  563. OnPropertyChanged(nameof(SecondCalibrationPositiont));
  564. }
  565. }
  566. public event PropertyChangedEventHandler PropertyChanged;
  567. protected internal virtual void OnPropertyChanged(string propertyName)
  568. {
  569. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  570. }
  571. }
  572. }