DataCenterModel.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using SWRIS.Dtos;
  2. using SWRIS.Enums;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.ComponentModel;
  6. using System.Linq;
  7. namespace SWRIS.Models
  8. {
  9. public class DataCenterModel : INotifyPropertyChanged
  10. {
  11. public DataCenterModel(List<EquipmentModel> equipments, List<LimitData> limits)
  12. {
  13. if (equipments != null)
  14. {
  15. equipments = equipments.OrderBy(c => c.RopeNumber).ToList();
  16. foreach (var equipment in equipments)
  17. {
  18. var equipmentData = new EquipmentDataModel()
  19. {
  20. RopeNumber = equipment.RopeNumber,
  21. RopeName = equipment.RopeName,
  22. TrolleyId = equipment.TrolleyId,
  23. IpAddress = equipment.IpAddress,
  24. SerialNo = equipment.SerialNo,
  25. SensorCount = equipment.Parameter.SensorCount,
  26. SamplingStep = equipment.Parameter.SamplingStep,
  27. RopeLength = equipment.Parameter.WireRopeLength,
  28. LiftHightRatio = equipment.LiftHightRatio,
  29. LiftHeight = equipment.RatedHeight,
  30. DisableAlarm = equipment.DisableAlarm,
  31. InUseSensor = equipment.InUseSensor,
  32. VariationThreshold = App.Config.SpeedVariationThreshold
  33. };
  34. limits?.ForEach(limit =>
  35. {
  36. if (limit.RelatedRopes.Contains(equipment.RopeNumber))
  37. {
  38. equipmentData.Limits.Add(new LimitModel
  39. {
  40. Name = limit.Name,
  41. State = LimitState.Offline,
  42. SwitchIndex = limit.SwitchIndex,
  43. IsEnable = limit.IsEnable
  44. });
  45. }
  46. });
  47. Equipments.Add(equipmentData);
  48. }
  49. }
  50. }
  51. public ObservableCollection<EquipmentDataModel> Equipments { get; set; } = new ObservableCollection<EquipmentDataModel>();
  52. public ObservableCollection<FaultsMessageDto> Messages { get; set; } = new ObservableCollection<FaultsMessageDto>();
  53. public event PropertyChangedEventHandler PropertyChanged;
  54. protected internal virtual void OnPropertyChanged(string propertyName)
  55. {
  56. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  57. }
  58. }
  59. }