EquipmentSettingViewModel.cs 16 KB

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