EquipmentSettingViewModel.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  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. /// <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 List<KeyAndValueDto> RopeCoreTypes => TypeExtension.ToKeyAndDescriptionList(typeof(RopeCoreType));
  193. public List<KeyAndValueDto> WireMaterialTypes => TypeExtension.ToKeyAndDescriptionList(typeof(WireMaterialType));
  194. public List<KeyAndValueDto> LayTypes => TypeExtension.ToKeyAndDescriptionList(typeof(LayType));
  195. public List<KeyAndValueDto> WireSurfaceTypes => TypeExtension.ToKeyAndDescriptionList(typeof(WireSurfaceType));
  196. public List<KeyAndValueDto> RiskLevels => TypeExtension.ToKeyAndDescriptionList(typeof(RiskLevel));
  197. public event PropertyChangedEventHandler PropertyChanged;
  198. protected internal virtual void OnPropertyChanged(string propertyName)
  199. {
  200. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  201. }
  202. }
  203. public class ParameterData : INotifyPropertyChanged
  204. {
  205. private string mainBoardSoftwareVersion;
  206. private short sensorCount;
  207. private float samplingStep;
  208. private short frequencyDivisionFactor;
  209. private short timeDomainFrequency;
  210. private short damageThreshold;
  211. private short scrapUpperLimit;
  212. private short frontMagnetLength;
  213. private short backMagnetLength;
  214. private float valueCoefficient;
  215. private float effectiveStrokeLength;
  216. private short zeroPositionCorrectionDuration;
  217. private short zeroPositionCorrectionOffset;
  218. private float warningValue;
  219. private float alarmValue;
  220. private short soundLightAlarmAutoResetMode;
  221. private short wireRopeType;
  222. private short wireRopeCount;
  223. private float wireRopeLength;
  224. private float wireRopeDiameter;
  225. private short wireRopeStrandCount;
  226. private short wireRopeStrandWireCount;
  227. private EncoderDirection encoderDirection;
  228. private DateTime? systemTime;
  229. private float twistFactor;
  230. /// <summary>
  231. /// 主板软件版本号
  232. /// </summary>
  233. public string MainBoardSoftwareVersion
  234. {
  235. get => mainBoardSoftwareVersion;
  236. set
  237. {
  238. mainBoardSoftwareVersion = value;
  239. OnPropertyChanged(nameof(MainBoardSoftwareVersion));
  240. }
  241. }
  242. /// <summary>
  243. /// 传感器数量
  244. /// </summary>
  245. public short SensorCount
  246. {
  247. get => sensorCount;
  248. set
  249. {
  250. sensorCount = value;
  251. OnPropertyChanged(nameof(SensorCount));
  252. }
  253. }
  254. /// <summary>
  255. /// 采样步长 单位:mm/点 4字节浮点数
  256. /// </summary>
  257. public float SamplingStep
  258. {
  259. get => samplingStep;
  260. set
  261. {
  262. samplingStep = value;
  263. OnPropertyChanged(nameof(SamplingStep));
  264. }
  265. }
  266. /// <summary>
  267. /// 分频系数
  268. /// </summary>
  269. public short FrequencyDivisionFactor
  270. {
  271. get => frequencyDivisionFactor;
  272. set
  273. {
  274. frequencyDivisionFactor = value;
  275. OnPropertyChanged(nameof(FrequencyDivisionFactor));
  276. }
  277. }
  278. /// <summary>
  279. /// 时域频率 2字节整型
  280. /// </summary>
  281. public short TimeDomainFrequency
  282. {
  283. get => timeDomainFrequency;
  284. set
  285. {
  286. timeDomainFrequency = value;
  287. OnPropertyChanged(nameof(TimeDomainFrequency));
  288. }
  289. }
  290. /// <summary>
  291. /// 损伤门限 2字节整型
  292. /// </summary>
  293. public short DamageThreshold
  294. {
  295. get => damageThreshold;
  296. set
  297. {
  298. damageThreshold = value;
  299. OnPropertyChanged(nameof(DamageThreshold));
  300. }
  301. }
  302. /// <summary>
  303. /// 报废上限
  304. /// </summary>
  305. public short ScrapUpperLimit
  306. {
  307. get => scrapUpperLimit;
  308. set
  309. {
  310. scrapUpperLimit = value;
  311. OnPropertyChanged(nameof(ScrapUpperLimit));
  312. }
  313. }
  314. /// <summary>
  315. /// 前磁极长度 单位:mm 2字节整型
  316. /// </summary>
  317. public short FrontMagnetLength
  318. {
  319. get => frontMagnetLength;
  320. set
  321. {
  322. frontMagnetLength = value;
  323. OnPropertyChanged(nameof(FrontMagnetLength));
  324. }
  325. }
  326. /// <summary>
  327. /// 后磁极长度 单位:mm 2字节整型
  328. /// </summary>
  329. public short BackMagnetLength
  330. {
  331. get => backMagnetLength;
  332. set
  333. {
  334. backMagnetLength = value;
  335. OnPropertyChanged(nameof(BackMagnetLength));
  336. }
  337. }
  338. /// <summary>
  339. /// 量值系数 4字节浮点数
  340. /// </summary>
  341. public float ValueCoefficient
  342. {
  343. get => valueCoefficient;
  344. set
  345. {
  346. valueCoefficient = value;
  347. OnPropertyChanged(nameof(ValueCoefficient));
  348. }
  349. }
  350. /// <summary>
  351. /// 零位有效行程长度,单位:m 4字节浮点数
  352. /// </summary>
  353. public float EffectiveStrokeLength
  354. {
  355. get => effectiveStrokeLength;
  356. set
  357. {
  358. effectiveStrokeLength = value;
  359. OnPropertyChanged(nameof(EffectiveStrokeLength));
  360. }
  361. }
  362. /// <summary>
  363. /// 零位矫正静止时长,单位:秒 2字节整型
  364. /// </summary>
  365. public short ZeroPositionCorrectionDuration
  366. {
  367. get => zeroPositionCorrectionDuration;
  368. set
  369. {
  370. zeroPositionCorrectionDuration = value;
  371. OnPropertyChanged(nameof(ZeroPositionCorrectionDuration));
  372. }
  373. }
  374. /// <summary>
  375. /// 零位矫正允许偏移量,单位:mm 2字节整型
  376. /// </summary>
  377. public short ZeroPositionCorrectionOffset
  378. {
  379. get => zeroPositionCorrectionOffset;
  380. set
  381. {
  382. zeroPositionCorrectionOffset = value;
  383. OnPropertyChanged(nameof(ZeroPositionCorrectionOffset));
  384. }
  385. }
  386. /// <summary>
  387. /// 预警(黄色报警)量值 4字节浮点数
  388. /// </summary>
  389. public float WarningValue
  390. {
  391. get => warningValue;
  392. set
  393. {
  394. warningValue = value;
  395. OnPropertyChanged(nameof(WarningValue));
  396. }
  397. }
  398. /// <summary>
  399. /// 报警(红色报警)量值 4字节浮点数
  400. /// </summary>
  401. public float AlarmValue
  402. {
  403. get => alarmValue;
  404. set
  405. {
  406. alarmValue = value;
  407. OnPropertyChanged(nameof(AlarmValue));
  408. }
  409. }
  410. /// <summary>
  411. /// 声光报警自动重置方式,0=不自动重置,>0=延时自动重置,-1=开始新一次检测时重置
  412. /// </summary>
  413. public short SoundLightAlarmAutoResetMode
  414. {
  415. get => soundLightAlarmAutoResetMode;
  416. set
  417. {
  418. soundLightAlarmAutoResetMode = value;
  419. OnPropertyChanged(nameof(SoundLightAlarmAutoResetMode));
  420. }
  421. }
  422. /// <summary>
  423. /// 钢丝绳类型 0=塔吊单绳,1=电梯排绳
  424. /// </summary>
  425. public short WireRopeType
  426. {
  427. get => wireRopeType;
  428. set
  429. {
  430. wireRopeType = value;
  431. OnPropertyChanged(nameof(WireRopeType));
  432. }
  433. }
  434. /// <summary>
  435. ///钢丝绳数量 1字节
  436. /// </summary>
  437. public short WireRopeCount
  438. {
  439. get => wireRopeCount;
  440. set
  441. {
  442. wireRopeCount = value;
  443. OnPropertyChanged(nameof(WireRopeCount));
  444. }
  445. }
  446. /// <summary>
  447. /// 钢丝绳长度,单位:m 4字节浮点数
  448. /// </summary>
  449. public float WireRopeLength
  450. {
  451. get => wireRopeLength;
  452. set
  453. {
  454. wireRopeLength = value;
  455. OnPropertyChanged(nameof(WireRopeLength));
  456. }
  457. }
  458. /// <summary>
  459. /// 钢丝绳直径,单位:mm 4字节浮点数
  460. /// </summary>
  461. public float WireRopeDiameter
  462. {
  463. get => wireRopeDiameter;
  464. set
  465. {
  466. wireRopeDiameter = value;
  467. OnPropertyChanged(nameof(WireRopeDiameter));
  468. }
  469. }
  470. /// <summary>
  471. /// 钢丝绳股数 1字节
  472. /// </summary>
  473. public short WireRopeStrandCount
  474. {
  475. get => wireRopeStrandCount;
  476. set
  477. {
  478. wireRopeStrandCount = value;
  479. OnPropertyChanged(nameof(WireRopeStrandCount));
  480. }
  481. }
  482. /// <summary>
  483. /// 钢丝绳每股丝数,2字节整型
  484. /// </summary>
  485. public short WireRopeStrandWireCount
  486. {
  487. get => wireRopeStrandWireCount;
  488. set
  489. {
  490. wireRopeStrandWireCount = value;
  491. OnPropertyChanged(nameof(WireRopeStrandWireCount));
  492. }
  493. }
  494. /// <summary>
  495. /// 编码器方向,1=正向,2=反向
  496. /// </summary>
  497. public EncoderDirection EncoderDirection
  498. {
  499. get => encoderDirection;
  500. set
  501. {
  502. encoderDirection = value;
  503. OnPropertyChanged(nameof(EncoderDirection));
  504. }
  505. }
  506. /// <summary>
  507. /// 系统时间
  508. /// </summary>
  509. public DateTime? SystemTime
  510. {
  511. get => systemTime;
  512. set
  513. {
  514. systemTime = value;
  515. OnPropertyChanged(nameof(SystemTime));
  516. }
  517. }
  518. /// <summary>
  519. /// 判伤捻距系数,浮点数,判伤捻距默认为7d,可通过此参数设置系数来调整(与损伤判定相关)。
  520. /// 默认值为1.0,设置2.0表示判伤捻距为2 x 7 = 14d
  521. /// </summary>
  522. public float TwistFactor
  523. {
  524. get => twistFactor;
  525. set
  526. {
  527. twistFactor = value;
  528. OnPropertyChanged(nameof(TwistFactor));
  529. }
  530. }
  531. public event PropertyChangedEventHandler PropertyChanged;
  532. protected internal virtual void OnPropertyChanged(string propertyName)
  533. {
  534. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  535. }
  536. }
  537. }