Rev 650 | Rev 653 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 650 | Rev 651 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #!/usr/bin/env python |
1 | #!/usr/bin/env python |
2 | # -*- coding: iso-8859-15 -*- |
2 | # -*- coding: iso-8859-15 -*- |
3 | # generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009 |
3 | # generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009 |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | # |
5 | # |
6 | # Mikrokopter VibrationTest Rev: $Rev: 650 $ |
6 | # Mikrokopter VibrationTest Rev: $Rev: 651 $ |
7 | # |
7 | # |
8 | # Author: Frederic Goddeeris (frederic@rc-flight.be) |
8 | # Author: Frederic Goddeeris (frederic@rc-flight.be) |
Line 9... | Line 9... | ||
9 | # |
9 | # |
Line 24... | Line 24... | ||
24 | import mkProto |
24 | import mkProto |
Line 25... | Line 25... | ||
25 | 25 | ||
- | 26 | ||
- | 27 | ||
26 | 28 | CHANNEL_NAMES = ["GyroYaw", "GyroRoll", "GyroNick", "Pressure", "Batt", "AccTop", "AccRoll", "AccNick"] |
|
27 | 29 | MOTOR_MAX = 16 |
|
28 | CHANNEL_NAMES = ["GyroYaw", "GyroRoll", "GyroNick", "Pressure", "Batt", "AccTop", "AccRoll", "AccNick"] |
30 | |
29 | FS = 11111 |
31 | FS = 11111 |
Line 679... | Line 681... | ||
679 | self.app.onSettingsChanged(True) |
681 | self.app.onSettingsChanged(True) |
Line 680... | Line 682... | ||
680 | 682 | ||
681 | def onStartMeasure(self, event): # wxGlade: MainFrame.<event_handler> |
683 | def onStartMeasure(self, event): # wxGlade: MainFrame.<event_handler> |
682 | # Collect measure parameters |
684 | # Collect measure parameters |
- | 685 | mp = MeasureParameters() |
|
Line 683... | Line 686... | ||
683 | mp = MeasureParameters() |
686 | decoding = "" |
- | 687 | ||
684 | 688 | try: |
|
- | 689 | decoding = "Description" |
|
- | 690 | mp.descr = self.descrCtrl.GetValue() |
|
685 | try: |
691 | |
- | 692 | decoding = "Motor(s)" |
|
- | 693 | mp.motors = map(int,self.motorsCtrl.GetValue().split(',')) |
|
- | 694 | for motor in mp.motors: |
|
- | 695 | if (motor<1) or (motor>MOTOR_MAX): |
|
- | 696 | raise Exception("Motor number should be between 1 and %d" % MOTOR_MAX) |
|
686 | mp.descr = self.descrCtrl.GetValue() |
697 | |
687 | mp.motors = map(int,self.motorsCtrl.GetValue().split(',')) |
698 | decoding = "Channel(s)" |
688 | mp.channels = [] |
699 | mp.channels = [] |
689 | if self.accTopCb.IsChecked(): mp.channels.append(5) |
700 | if self.accTopCb.IsChecked(): mp.channels.append(5) |
690 | if self.accRollCb.IsChecked(): mp.channels.append(6) |
701 | if self.accRollCb.IsChecked(): mp.channels.append(6) |
- | 702 | if self.accNickCb.IsChecked(): mp.channels.append(7) |
|
691 | if self.accNickCb.IsChecked(): mp.channels.append(7) |
703 | |
692 | 704 | decoding = "Speed(s)" |
|
693 | mp.speeds = [] |
705 | mp.speeds = [] |
694 | for speedTxt in self.speedCtrl.GetValue().split(","): |
706 | for speedTxt in self.speedCtrl.GetValue().split(","): |
695 | if speedTxt.count("-") == 1: |
707 | if speedTxt.count("-") == 1: |
Line 705... | Line 717... | ||
705 | speedTxt = speedTxt.split("*") |
717 | speedTxt = speedTxt.split("*") |
706 | for i in range(int(speedTxt[0])): |
718 | for i in range(int(speedTxt[0])): |
707 | mp.speeds.append(int(speedTxt[1])) |
719 | mp.speeds.append(int(speedTxt[1])) |
708 | else: |
720 | else: |
709 | mp.speeds.append(int(speedTxt)) |
721 | mp.speeds.append(int(speedTxt)) |
- | 722 | for speed in mp.speeds: |
|
- | 723 | if (speed<0) or (speed>255): |
|
- | 724 | raise Exception("Speed values should be between 0 and 255") |
|
- | 725 | ||
710 | except Exception,e: |
726 | except Exception,e: |
711 | dial = wx.MessageDialog(None, 'Invalid paramters', 'Error', wx.OK | |
727 | dial = wx.MessageDialog(None, 'Invalid paramter \"%s\"\n\n%s' % (decoding, str(e)), 'Error', wx.OK | |
712 | wx.ICON_ERROR) |
728 | wx.ICON_ERROR) |
713 | dial.ShowModal() |
729 | dial.ShowModal() |
714 | raise e |
730 | raise e |
Line 762... | Line 778... | ||
762 | 778 | ||
763 | def onAbout(self, event): # wxGlade: MainFrame.<event_handler> |
779 | def onAbout(self, event): # wxGlade: MainFrame.<event_handler> |
764 | # First we create and fill the info object |
780 | # First we create and fill the info object |
765 | print "about" |
781 | print "about" |
766 | info = wx.AboutDialogInfo() |
782 | info = wx.AboutDialogInfo() |
767 | info.Name = "- MK Vibration Test - " |
783 | info.Name = "MK Vibration Test - " |
768 | info.Version = "v0.9 RC2" |
784 | info.Version = "v0.9 RC2 ($Rev: 651 $)".replace("$","") |
769 | info.Copyright = "" |
785 | info.Copyright = "" |
770 | info.Developers=["Frederic Goddeeris Frederic@rc-flight.be"] |
786 | info.Developers=["Frederic Goddeeris (Frederic@rc-flight.be)"] |
771 | info.Description = "Please consult the WIKI page for a complete description of the tool:" |
787 | info.Description = "Please consult the WIKI page for a complete description of the tool:" |
772 | info.WebSite = ("http://www.mikrokopter.de/ucwiki/en/VibrationTest", "VibrationTest WIKI page") |
788 | info.WebSite = ("http://www.mikrokopter.de/ucwiki/en/VibrationTest", "VibrationTest WIKI page") |
Line 830... | Line 846... | ||
830 | def _sendEvent(self, msg=None, error=False, parVoltage=None, speed=None): |
846 | def _sendEvent(self, msg=None, error=False, parVoltage=None, speed=None): |
831 | evt = MeasStatusUpdateEvent(running=self.running, msg=msg, error=error, voltage=parVoltage, speed=speed) |
847 | evt = MeasStatusUpdateEvent(running=self.running, msg=msg, error=error, voltage=parVoltage, speed=speed) |
832 | wx.PostEvent(self.evtConsumer, evt) |
848 | wx.PostEvent(self.evtConsumer, evt) |
Line 833... | Line 849... | ||
833 | 849 | ||
834 | def _setMotorSpeed(self, speed, settlingTime): |
850 | def _setMotorSpeed(self, speed, settlingTime): |
Line 835... | Line 851... | ||
835 | speeds = [0,0,0,0] |
851 | speeds = [0]*MOTOR_MAX |
836 | 852 | ||
837 | for motor in self.param.motors: |
853 | for motor in self.param.motors: |
838 | speeds[motor-1] = speed |
854 | speeds[motor-1] = speed |