Пример #1
0
        public EditMotorClassWin(MotorClass component)
        {
            InitializeComponent();

            Component        = component;
            this.DataContext = Component;
        }
Пример #2
0
 static MotorClassExamples()
 {
     MotorClass1 = new MotorClass()
     {
         Name          = "测试电机1",
         Guid          = Guid.NewGuid(),
         LineFrequency = 50,
         Poles         = 2,
         RotorBars     = 3,
         StatorCoils   = 50,
         WindingSlots  = 2,
         SCRs          = 3,
         MotorType     = CoreType.MotorType.AC,
     };
     MotorClass2 = new MotorClass()
     {
         Name          = "测试电机2",
         Guid          = Guid.NewGuid(),
         LineFrequency = 50,
         Poles         = 4,
         RotorBars     = 3,
         StatorCoils   = 50,
         WindingSlots  = 2,
         SCRs          = 6,
         MotorType     = CoreType.MotorType.AC,
     };
     MotorClassLib.Add(MotorClass1);
     MotorClassLib.Add(MotorClass2);
 }
Пример #3
0
        private void SelectedMotorChanged(object para)
        {
            MotorClass componentclass = para as MotorClass;

            if (componentclass != null)
            {
                selectedshaft.Component.SelectedComponent.Component = componentclass.DeepClone();
            }
        }
        public async Task GetMotorClasses(string serverip)
        {
            //电机
            if (MotorClasses.ContainsKey(serverip))
            {
                MotorClasses.Remove(serverip);
            }
            var t_motors = await _databaseComponent.Query <T_Motor>(serverip, null, null, null);

            if (t_motors != null)
            {
                List <MotorClass> motors = new List <MotorClass>();
                foreach (var t_motor in t_motors)
                {
                    var motor = MotorClass.ConvertFromDB(t_motor);
                    motors.Add(motor);
                }
                MotorClasses.Add(serverip, motors);
            }

            MotorClassList.Clear();
            MotorClassList.AddRange(MotorClasses.SelectMany(p => p.Value));
        }
Пример #5
0
        private async void ShowWin()
        {
            if (DevicesIsSelected == true)
            {
                EditDeviceClassWin win = new EditDeviceClassWin(SelectedDevice);
                win.ShowDialog();

                T_DeviceDiagnose t_model = DeviceDiagnoseClass.ConvertToDB(SelectedDevice);
                if (SelectedDevice.id == -1)
                {
                    var id = await _databaseComponent.Add <T_DeviceDiagnose>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedDevice.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_DeviceDiagnose>(ServerIP, null, t_model);
                }
            }
            else if (ShaftsIsSelected == true)
            {
                EditShaftClassWin win = new EditShaftClassWin(SelectedShaft);
                win.ShowDialog();

                T_Shaft t_model = ShaftClass.ConvertToDB(SelectedShaft);
                if (SelectedShaft.id == -1)
                {
                    var id = await _databaseComponent.Add <T_Shaft>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedShaft.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_Shaft>(ServerIP, null, t_model);
                }
            }
            else if (BearingsIsSelected == true)
            {
                EditBearingClassWin win = new EditBearingClassWin(SelectedBearing);
                win.ShowDialog();

                T_Bearing t_model = BearingClass.ConvertToDB(SelectedBearing);
                if (SelectedBearing.id == -1)
                {
                    var id = await _databaseComponent.Add <T_Bearing>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedBearing.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_Bearing>(ServerIP, null, t_model);
                }
            }
            else if (BeltsIsSelected == true)
            {
                EditBeltClassWin win = new EditBeltClassWin(SelectedBelt);
                win.ShowDialog();

                T_Belt t_model = BeltClass.ConvertToDB(SelectedBelt);
                if (SelectedBelt.id == -1)
                {
                    var id = await _databaseComponent.Add <T_Belt>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedBelt.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_Belt>(ServerIP, null, t_model);
                }
            }
            else if (GearsIsSelected == true)
            {
                ;
                EditGearClassWin win = new EditGearClassWin(SelectedGear);
                win.ShowDialog();

                T_Gear t_model = GearClass.ConvertToDB(SelectedGear);
                if (SelectedGear.id == -1)
                {
                    var id = await _databaseComponent.Add <T_Gear>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedGear.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_Gear>(ServerIP, null, t_model);
                }
            }
            else if (ImpellersIsSelected == true)
            {
                EditImpellerClassWin win = new EditImpellerClassWin(SelectedImpeller);
                win.ShowDialog();

                T_Impeller t_model = ImpellerClass.ConvertToDB(SelectedImpeller);
                if (SelectedImpeller.id == -1)
                {
                    var id = await _databaseComponent.Add <T_Impeller>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedImpeller.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_Impeller>(ServerIP, null, t_model);
                }
            }
            else if (MotorsIsSelected == true)
            {
                EditMotorClassWin win = new EditMotorClassWin(SelectedMotor);
                win.ShowDialog();

                T_Motor t_model = MotorClass.ConvertToDB(SelectedMotor);
                if (SelectedMotor.id == -1)
                {
                    var id = await _databaseComponent.Add <T_Motor>(ServerIP, t_model);

                    if (id == -1)
                    {
                        UploadError = true;
                    }
                    else
                    {
                        SelectedMotor.id = id;
                    }
                }
                else
                {
                    UploadError = !await _databaseComponent.Modify <T_Motor>(ServerIP, null, t_model);
                }
            }
        }
Пример #6
0
        private async void Delete(object value)
        {
#if XBAP
            MessageBoxResult result = MessageBox.Show("确定要删除?", "删除", MessageBoxButton.OK, MessageBoxImage.Warning);
#else
            MessageBoxResult result = Xceed.Wpf.Toolkit.MessageBox.Show("确定要删除?", "删除", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
#endif
            if (result == MessageBoxResult.OK)
            {
                if (DevicesIsSelected == true)
                {
                    T_DeviceDiagnose t_model = DeviceDiagnoseClass.ConvertToDB(SelectedDevice);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_DeviceDiagnose>(ServerIP, t_model.id);
                    }
                    Devices.Remove(SelectedDevice);
                }
                else if (ShaftsIsSelected == true)
                {
                    T_Shaft t_model = ShaftClass.ConvertToDB(SelectedShaft);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_Shaft>(ServerIP, t_model.id);
                    }
                    Shafts.Remove(SelectedShaft);
                }
                else if (BearingsIsSelected == true)
                {
                    T_Bearing t_model = BearingClass.ConvertToDB(SelectedBearing);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_Bearing>(ServerIP, t_model.id);
                    }
                    Bearings.Remove(SelectedBearing);
                }
                else if (BeltsIsSelected == true)
                {
                    Belts.Remove(SelectedBelt);
                    T_Belt t_model = BeltClass.ConvertToDB(SelectedBelt);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_Belt>(ServerIP, t_model.id);
                    }
                }
                else if (GearsIsSelected == true)
                {
                    T_Gear t_model = GearClass.ConvertToDB(SelectedGear);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_Gear>(ServerIP, t_model.id);
                    }
                    Gears.Remove(SelectedGear);
                }
                else if (ImpellersIsSelected == true)
                {
                    T_Impeller t_model = ImpellerClass.ConvertToDB(SelectedImpeller);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_Impeller>(ServerIP, t_model.id);
                    }
                    Impellers.Remove(SelectedImpeller);
                }
                else if (MotorsIsSelected == true)
                {
                    T_Motor t_model = MotorClass.ConvertToDB(SelectedMotor);
                    if (t_model.id != -1)
                    {
                        await _databaseComponent.Delete <T_Motor>(ServerIP, t_model.id);
                    }
                    Motors.Remove(SelectedMotor);
                }
            }
        }
Пример #7
0
 private void Add(object value)
 {
     if (DevicesIsSelected == true)
     {
         SelectedDevice = new DeviceDiagnoseClass()
         {
             Name = "新建设备"
         };
         Devices.Add(SelectedDevice);
     }
     else if (ShaftsIsSelected == true)
     {
         SelectedShaft = new ShaftClass()
         {
             Name = "新建轴"
         };
         Shafts.Add(SelectedShaft);
     }
     else if (BearingsIsSelected == true)
     {
         SelectedBearing = new BearingClass()
         {
             Name = "新建轴承"
         };
         Bearings.Add(SelectedBearing);
     }
     else if (BeltsIsSelected == true)
     {
         SelectedBelt = new BeltClass()
         {
             Name = "新建皮带"
         };
         Belts.Add(SelectedBelt);
     }
     else if (GearsIsSelected == true)
     {
         SelectedGear = new GearClass()
         {
             Name = "新建齿轮"
         };
         Gears.Add(SelectedGear);
     }
     else if (ImpellersIsSelected == true)
     {
         SelectedImpeller = new ImpellerClass()
         {
             Name = "新建叶轮"
         };
         Impellers.Add(SelectedImpeller);
     }
     else if (MotorsIsSelected == true)
     {
         SelectedMotor = new MotorClass()
         {
             Name = "新建电机"
         };
         Motors.Add(SelectedMotor);
     }
     ShowWin();
     //立即更新到服务器
 }