DataCenterModel.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. DisableAlarm = equipment.DisableAlarm,
  30. InUseSensor = equipment.InUseSensor,
  31. VariationThreshold = App.Config.SpeedVariationThreshold
  32. };
  33. limits?.ForEach(limit =>
  34. {
  35. if (limit.RelatedRopes.Contains(equipment.RopeNumber))
  36. {
  37. equipmentData.Limits.Add(new LimitModel
  38. {
  39. Name = limit.Name,
  40. State = LimitState.Offline,
  41. SwitchIndex = limit.SwitchIndex,
  42. IsEnable = limit.IsEnable
  43. });
  44. }
  45. });
  46. Equipments.Add(equipmentData);
  47. }
  48. }
  49. }
  50. public ObservableCollection<EquipmentDataModel> Equipments { get; set; } = new ObservableCollection<EquipmentDataModel>();
  51. public ObservableCollection<FaultsMessageDto> Messages { get; set; } = new ObservableCollection<FaultsMessageDto>();
  52. public event PropertyChangedEventHandler PropertyChanged;
  53. protected internal virtual void OnPropertyChanged(string propertyName)
  54. {
  55. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  56. }
  57. }
  58. }