EquipmentSettingViewModel.cs 17 KB

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