public DeviceDiagnoseComponent(IList <ItemInfo> items, Guid deviceguid, string devicename, DeviceDiagnoseClass component) : this(items, deviceguid, devicename)
 {
     if (component != null)
     {
         Component = component;
         Component.UnAllotItems = new ObservableCollection <ItemInfo>(items);
     }
 }
Example #2
0
        public static DeviceDiagnoseClass ConvertFromDB(T_DeviceDiagnose t_device)
        {
            DeviceDiagnoseClass device = new DeviceDiagnoseClass();

            device.id   = t_device.id;
            device.Name = t_device.Name;
            device.Guid = t_device.Guid ?? new Guid();
            if (!string.IsNullOrWhiteSpace(t_device.ShaftsJson))
            {
                device.Shafts = JsonConvert.DeserializeObject <ObservableCollection <ShaftComponent> >(t_device.ShaftsJson);//可能有问题
                //修复一些不进行json的字段
                foreach (var shaft in device.Shafts)
                {
                    if (shaft.Component != null)
                    {
                        shaft.Component.Parent = device;
                        shaft.Component.InitMachComponents();
                    }
                }
            }
            else
            {
                device.Shafts = new ObservableCollection <ShaftComponent>();
            }
            device.HeadDivFreThreshold       = t_device.HeadDivFreThreshold ?? 0;
            device.IsDeviceDiagnosis         = t_device.IsDeviceDiagnosis ?? false;
            device.MeanThreshold             = t_device.MeanThreshold ?? 0;
            device.KurtosisIndexThreshold    = t_device.KurtosisIndexThreshold ?? 0;
            device.PeakThreshold             = t_device.PeakThreshold ?? 0;
            device.PulseIndexThreshold       = t_device.PulseIndexThreshold ?? 0;
            device.PeakIndexThreshold        = t_device.PeakIndexThreshold ?? 0;
            device.RMSThreshold              = t_device.RMSThreshold ?? 0;
            device.FrePeakFilterInterval     = t_device.FrePeakFilterInterval ?? 0;
            device.FreDiagnosisSetupInterval = t_device.FreDiagnosisSetupInterval ?? 0;
            device.IsFaultprobability        = t_device.IsFaultprobability ?? false;
            device.DiagnosisMethod           = (DiagnosisMethod)(t_device.DiagnosisMethod ?? 0);
            if (!string.IsNullOrWhiteSpace(t_device.UnAllotItemsJson))
            {
                device.UnAllotItems = JsonConvert.DeserializeObject <ObservableCollection <ItemInfo> >(t_device.UnAllotItemsJson);
            }
            else
            {
                device.UnAllotItems = new ObservableCollection <ItemInfo>();
            }

            return(device);
        }
Example #3
0
        public static T_DeviceDiagnose ConvertToDB(DeviceDiagnoseClass device)
        {
            T_DeviceDiagnose t_device = new T_DeviceDiagnose();

            t_device.id   = device.id;
            t_device.Name = device.Name;
            t_device.Guid = device.Guid;
            if (device.Shafts != null)
            {
                t_device.ShaftsJson = JsonConvert.SerializeObject(device.Shafts);//可能有问题
            }
            else
            {
                t_device.ShaftsJson = null;
            }
            t_device.HeadDivFreThreshold       = device.HeadDivFreThreshold;
            t_device.IsDeviceDiagnosis         = device.IsDeviceDiagnosis;
            t_device.MeanThreshold             = device.MeanThreshold;
            t_device.KurtosisIndexThreshold    = device.KurtosisIndexThreshold;
            t_device.PeakThreshold             = device.PeakThreshold;
            t_device.PulseIndexThreshold       = device.PulseIndexThreshold;
            t_device.PeakIndexThreshold        = device.PeakIndexThreshold;
            t_device.RMSThreshold              = device.RMSThreshold;
            t_device.FrePeakFilterInterval     = device.FrePeakFilterInterval;
            t_device.FreDiagnosisSetupInterval = device.FreDiagnosisSetupInterval;
            t_device.IsFaultprobability        = device.IsFaultprobability;
            t_device.DiagnosisMethod           = (int)device.DiagnosisMethod;
            if (device.UnAllotItems != null)
            {
                t_device.UnAllotItemsJson = JsonConvert.SerializeObject(device.UnAllotItems);
            }
            else
            {
                t_device.UnAllotItemsJson = null;
            }

            return(t_device);
        }