def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.staticBox = wx.StaticBox(self, -1, _(u"Dimensions")) self.labelWidth = wx.StaticText(self, -1, _(u"Width")) self.spinWidth = wx.ComboBox(self, -1, "", wx.DefaultPosition, (90, -1), style=wx.CB_DROPDOWN, name="dimensionWidth") self.spinWidth.SetValue(u"auto") self.spinWidth.SetValidator(dimensionValidator(self)) self.labelHeight = wx.StaticText(self, -1, _(u"Height")) self.spinHeight = wx.ComboBox(self, -1, "", wx.DefaultPosition, (90, -1), style=wx.CB_DROPDOWN, name="dimensionHeight") self.spinHeight.SetValue(u"auto") self.spinHeight.SetValidator(dimensionValidator(self)) self.unitBox = measureUnit(self) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.label = wx.StaticText(self, -1, _(u"Define the content type of this frame")) self.choice = wx.Choice(self, -1, choices=[ _(u"color frame"), _(u"image frame"), _(u"static text frame"), _(u"variable text frame") ], name="contentType") self.choice.SetValidator(contentTypeValidator(self)) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, noteBook): wx.Panel.__init__(self, noteBook) self.parent = parent self.frame = self.parent.parent self.clientTemplateDirLabel = wx.StaticText(self, -1, _(u"Client Templates")) self.clientTemplateDirInput = wx.DirPickerCtrl( self, message=_(u"Select the clients template directory"), name="clientTemplates") self.clientTemplateDirInput.SetValidator( PathValidator(self.parent, _(u"Please enter a valid client template path!"))) self.clientTemplateDirInput.SetPath(self.frame.clientTemplates()) self.clientImageDirLabel = wx.StaticText(self, -1, _(u"Client Images")) self.clientImageDirInput = wx.DirPickerCtrl( self, message=_(u"Select the clients image directory"), name="clientImages") self.clientImageDirInput.SetValidator( PathValidator(self.parent, _(u"Please enter a valid client image path!"))) self.clientImageDirInput.SetPath(self.frame.clientImages()) self.__doProperties() self.__doLayout() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.staticBox = wx.StaticBox(self, -1, _(u"Contents")) self.status = wx.StaticText(self, -1, "") self.status.SetForegroundColour(wx.Colour(255, 0, 0, 0)) self.text = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE | wx.TE_NO_VSCROLL, name="text") self.text.SetValidator( textValidator(self, _(u"Please enter some text!"))) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, id, title): wx.Dialog.__init__(self, parent, id, title, size=(600, 250), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, pos=wx.DefaultPosition) self.parent = parent self.safetyMode = self.parent.safetyMode self.OverviewText = wx.StaticText(self, -1, _(u"This dialog gives you the possibility to set up Template-Designer. " + \ u"Please take the desired settings.")) self.okayButton = wx.Button(self, wx.ID_OK, name="settingsOkButton") self.okayButton.SetDefault() self.okayButton.Disable() self.cancelButton = wx.Button(self, wx.ID_CANCEL, name="settingsCancelButton") self.__doProperties() self.__doLayout() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.allSizes = PaperSizes() self.usedSizes = [ "a2", "a3", "a4", "a5", "executive", "letter", "legal", "cdsingle", "cddouble", "dvdsingle", "dvddouble" ] self.label = wx.StaticText(self, -1, _(u"Page format")) self.choice = wx.Choice(self, -1, choices=self.usedSizes, name="paperFormat") self.choice.SetValidator(paperFormatValidator(self)) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, style=wx.WS_EX_VALIDATE_RECURSIVELY, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.information = information(self) self.contentType = contentType(self) self.status = wx.StaticText(self, -1, "", name="dimPosStatus") self.status.SetForegroundColour(wx.Colour(255, 0, 0, 0)) self.dimension = dimension(self) self.position = position(self) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.staticBox = wx.StaticBox(self, -1, _(u"Information")) self.status = wx.StaticText(self, -1, "", name="informationStatus") self.status.SetForegroundColour(wx.Colour(255, 0, 0, 0)) self.labelName = wx.StaticText(self, -1, _(u"Name")) self.inputName = wx.TextCtrl(self, -1, "", name="informationName") self.inputName.SetValidator( informationValidator(self, _(u"Please enter a valid name!"))) self.labelDescription = wx.StaticText(self, -1, _(u"Description")) self.inputDescription = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE | wx.TE_NO_VSCROLL, name="informationDescription") self.inputDescription.SetValidator( informationValidator(self, _(u"Please enter a valid description!"))) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def setup(): Safety.setup_terminal_abort() EventBus.subscribe(BT_REQUEST_SENSOR_DATA, communicator.send_sensor_data) EventBus.subscribe(BT_REQUEST_SERVO_DATA, communicator.send_servo_data) EventBus.subscribe(BT_REQUEST_MAP_DATA, communicator.send_map_data) EventBus.subscribe(BT_DRIVE_FORWARD, communicator.drive_forward) EventBus.subscribe(BT_DRIVE_BACK, communicator.drive_backward) EventBus.subscribe(BT_TURN_RIGHT, communicator.turn_right) EventBus.subscribe(BT_TURN_LEFT, communicator.turn_left) EventBus.subscribe(BT_DRIVE_FORWARD_RIGHT, communicator.drive_forward_right) EventBus.subscribe(BT_DRIVE_FORWARD_LEFT, communicator.drive_forward_left) EventBus.subscribe(AUTONOMOUS_MODE, (lambda: navigator.set_mode(Navigator.AUTONOMOUS))) EventBus.subscribe(MANUAL_MODE, (lambda: navigator.set_mode(Navigator.MANUAL))) EventBus.subscribe(CMD_TOGGLE_MODE, navigator.toggle_mode) EventBus.subscribe(REQUEST_PI_IP, communicator.send_ip) EventBus.subscribe(CMD_RETURN_SENSOR_DATA, ir.sensor_data_received) Laser.initialize() Gyro.initialize()
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.staticBox = wx.StaticBox(self, -1, _(u"Position")) self.topLabel = wx.StaticText(self, -1, _(u"top")) self.topSpin = wx.ComboBox(self, -1, "", wx.DefaultPosition, (90, -1), style=wx.CB_DROPDOWN, name="positionTop") self.topSpin.SetValue(u"auto") self.topSpin.SetValidator(positionValidator(self)) self.leftLabel = wx.StaticText(self, -1, _(u"left")) self.leftSpin = wx.ComboBox(self, -1, "", wx.DefaultPosition, (90, -1), style=wx.CB_DROPDOWN, name="positionLeft") self.leftSpin.SetValue(u"auto") self.leftSpin.SetValidator(positionValidator(self)) self.rightLabel = wx.StaticText(self, -1, _(u"right")) self.rightSpin = wx.ComboBox(self, -1, "", wx.DefaultPosition, (90, -1), style=wx.CB_DROPDOWN, name="positionRight") self.rightSpin.SetValue(u"auto") self.rightSpin.SetValidator(positionValidator(self)) self.bottomLabel = wx.StaticText(self, -1, _(u"bottom")) self.bottomSpin = wx.ComboBox(self, -1, "", wx.DefaultPosition, (90, -1), style=wx.CB_DROPDOWN, name="positionBottom") self.bottomSpin.SetValue(u"auto") self.bottomSpin.SetValidator(positionValidator(self)) self.unitBox = measureUnit(self) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def initComponents(self): #~ servo = PWM.Servo() self.servo = "STUB" # Create objects self.projo = Projector() self.z_stepper = ZStepper() self.shutter = Shutter(self.servo) self.tilt = Tilt(self.servo) self.safety = Safety() self.safety.addActivePins(self.z_stepper.getUsedPins()) self.safety.addActivePins(self.shutter.getUsedPins()) self.safety.addActivePins(self.tilt.getUsedPins())
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.information = information(self) self.settings = settingsTemplate(self) self.__doProperties() self.__doLayout() Safety(self)
def __init__(self, parent, title, type): wx.Dialog.__init__(self, parent, -1, title, size=(600, 250), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) self.parent = parent self.frame = self.parent.parent.parent self.title = title self.type = type self.logoPanel = wx.Panel(self, -1) self.settingsPanel = wx.Panel(self, -1) self.description = wx.StaticText(self, -1, _(u"This dialog gives you the opportunity to " + title.lower())) self.oldLabel = wx.StaticText(self, -1, _(u"Old password"), name="oldPasswordLabel") self.oldInput = wx.TextCtrl(self, -1, "", style=wx.TE_PASSWORD, name="oldPassword") self.oldInput.SetValidator(SetPasswordValidator(self)) self.newLabel = wx.StaticText(self, -1, _(u"New password")) self.newInput = wx.TextCtrl(self, -1, "", style=wx.TE_PASSWORD, name="newPassword") self.newInput.SetValidator(SetPasswordValidator(self)) self.repeatLabel = wx.StaticText(self, -1, _(u"Repeat new password")) self.repeatInput = wx.TextCtrl(self, -1, "", style=wx.TE_PASSWORD, name="repeatPassword") self.repeatInput.SetValidator(SetPasswordValidator(self)) self.placeholderPanel = wx.Panel(self.settingsPanel, -1) logo = wx.Bitmap(self.frame.skinGraphics() + "/kgpg_key3_kgpg.png", wx.BITMAP_TYPE_PNG) self.logoBitmap = wx.StaticBitmap(self.logoPanel, -1, logo) self.staticLine = wx.StaticLine(self, -1) self.goButton = wx.Button(self, wx.ID_OK, _(u"OK"), name="goButton") self.goButton.SetValidator(SetPasswordValidator(self)) self.exitButton = wx.Button(self, wx.ID_CANCEL, _(u"Cancel"), name="cancelButton") self.__doProperties() self.__doLayout() Safety(self.frame)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.radio = wx.RadioBox(self, -1, _(u"Orientation"), choices=[_(u"portrait"), _(u"landscape")], majorDimension=2, style=wx.RA_SPECIFY_COLS, name="paperOrientation") self.radio.SetValidator(paperOrientationValidator(self)) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, noteBook): wx.Panel.__init__(self, noteBook) self.parent = parent self.frame = self.parent.parent self.fullAccessLabel = wx.StaticText(self, -1, _(u"Full access password")) self.fullAccessSet = wx.Button(self, -1, _(u"Set"), name="setFullAccess") self.fullAccessSet.SetValidator(PasswordValidator(self)) self.fullAccessUnset = wx.Button(self, -1, _(u"Unset"), name="unsetFullAccess") self.fullAccessUnset.SetValidator(PasswordValidator(self)) self.restrictedAccessLabel = wx.StaticText( self, -1, _(u"Restricted access password")) self.restrictedAccessSet = wx.Button(self, -1, _(u"Set"), name="setRestrictedAccess") self.restrictedAccessSet.SetValidator(PasswordValidator(self)) self.restrictedAccessUnset = wx.Button(self, -1, _(u"Unset"), name="unsetRestrictedAccess") self.restrictedAccessUnset.SetValidator(PasswordValidator(self)) self.viewAccessLabel = wx.StaticText(self, -1, _(u"View access password")) self.viewAccessSet = wx.Button(self, -1, _(u"Set"), name="setViewAccess") self.viewAccessSet.SetValidator(PasswordValidator(self)) self.viewAccessUnset = wx.Button(self, -1, _(u"Unset"), name="unsetViewAccess") self.viewAccessUnset.SetValidator(PasswordValidator(self)) self.__doProperties() self.__doLayout() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.staticBox = wx.StaticBox(self, -1, "Select") self.color = CS.ColourSelect(self, -1, label=_(u"Select color")) self.color.SetValidator(colorSelectValidator(self)) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.staticBox = wx.StaticBox(self, -1, _(u"Hex")) self.label = wx.StaticText(self, -1, "#") self.input = wx.TextCtrl(self, -1, "000000") self.input.SetValidator(colorHexValidator(self)) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.inheritance = wx.CheckBox( self, -1, _(u"Disable inheritance of the template settings"), name="inheritance") self.inheritance.SetValidator(inheritanceValidator(self)) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.label = wx.StaticText(self, -1, _(u"Define input method")) self.choice = wx.Choice(self, -1, choices=[_(u"Rgb"), _(u"Cmyk"), _(u"Hex")]) self.choice.SetValidator(colorUnitValidator(self)) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def main(): startMessage() #servo = PWM.Servo() servo = "STUB" # Create objects projo = Projector() z_stepper = ZStepper() shutter = Shutter(servo) tilt = Tilt(servo) safety = Safety() safety.addActivePins(z_stepper.getUsedPins()) safety.addActivePins(shutter.getUsedPins()) safety.addActivePins(tilt.getUsedPins()) # test projo function projo.switchOn() projo.switchOff() # test Z stepper z_stepper.setTargetPos(199800, 1000) z_stepper.run() # test shutter function shutter.close() shutter.open() shutter.close() #test tilt function tilt.tiltMe() # check output pins to desactivate for safety print "Safety pins watched :" + repr(safety.getActivePins()) #listAllScenarioFiles("/home/lsa/Documents/DLP_Printer_soft_Freaky/gear.slice/") fenetre = Tk() label = Label(fenetre, text="Hello World") label.pack()
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.orientation = paperOrientation(self) self.layout = paperLayout(self) self.format = paperFormat(self) self.status = wx.StaticText(self, -1, "", name="dimPosStatus") self.status.SetForegroundColour(wx.Colour(255, 0, 0, 0)) self.dimension = dimension(self) self.position = position(self) self.__doProperties() self.__doLayout() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.label = wx.StaticText(self, -1, _(u"Base unit")) self.choice = wx.Choice( self, -1, choices=[_(u"mm"), _(u"cm"), _(u"inch"), _(u"point")], name="measureUnit") self.choice.SetValidator(measureUnitValidator(self)) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.staticBox = wx.StaticBox(self, -1, _(u"Rotation")) self.topSpin = wx.RadioButton(self, -1, "", name="contentAngle0") self.topSpin.SetValidator(rotationValidator(self)) self.leftSpin = wx.RadioButton(self, -1, "", name="contentAngle270") self.leftSpin.SetValidator(rotationValidator(self)) self.rightSpin = wx.RadioButton(self, -1, "", name="contentAngle90") self.rightSpin.SetValidator(rotationValidator(self)) self.bottomSpin = wx.RadioButton(self, -1, "", name="contentAngle180") self.bottomSpin.SetValidator(rotationValidator(self)) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, *args, **kwds): wx.gizmos.TreeListCtrl.__init__(self, parent, style=wx.TR_DEFAULT_STYLE | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_HIDE_ROOT) self.parent = parent.parent self.frame = self.parent.parent self.tree = self.parent.parent.document self.AddColumn("Category") self.AddColumn("Description") self.AddColumn("Example") self.SetMainColumn(0) self.SetColumnWidth(0, 130) self.SetColumnWidth(1, 400) self.SetColumnWidth(2, 300) self.SetMinSize((600, 250)) root = self.AddRoot("Date/Time Placeholders") data = self.isoData() self.imageList = wx.ImageList(16, 16) self.catImg = self.imageList.Add( wx.Image(self.frame.programGraphics() + "/alarmclock.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()) self.valImg = self.imageList.Add( wx.Image(self.frame.programGraphics() + "/clock.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()) self.AssignImageList(self.imageList) self.addItems(root, data) self.Expand(root) self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnActivated, self) Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.staticBox = wx.StaticBox(self, -1, _(u"Rgb")) self.rLabel = wx.StaticText(self, -1, _(u"R")) self.rSpin = wx.SpinCtrl(self, -1, "0", min=0, max=255, name="rColor") self.rSpin.SetValidator(colorRgbValidator(self)) self.gLabel = wx.StaticText(self, -1, _(u"G")) self.gSpin = wx.SpinCtrl(self, -1, "0", min=0, max=255, name="gColor") self.gSpin.SetValidator(colorRgbValidator(self)) self.bLabel = wx.StaticText(self, -1, _(u"B")) self.bSpin = wx.SpinCtrl(self, -1, "0", min=0, max=255, name="bColor") self.bSpin.SetValidator(colorRgbValidator(self)) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, style=wx.WS_EX_VALIDATE_RECURSIVELY, *args, **kwargs) self.parent = self.GetTopLevelParent() self.tree = self.parent.document self.item = self.tree.GetSelection() self.xml = self.tree.GetItemPyData(self.item) self.staticBox = wx.StaticBox(self, -1, _(u"Color")) self.rgb = colorRgb(self) self.hex = colorHex(self) self.cmyk = colorCmyk(self) self.select = colorSelect(self) self.unit = colorUnit(self) self.__doProperties() self.__doLayout() wx.CallAfter(self.InitDialog) Safety(self)
def __init__(self, parent, *args, **kwds): wx.MiniFrame.__init__(self, parent, -1, _(u"Date/Time Placeholders"), style=wx.ICONIZE|wx.MINIMIZE|wx.MAXIMIZE|wx.CLOSE_BOX|wx.STAY_ON_TOP|wx.DEFAULT_MINIFRAME_STYLE) self.parent = parent self.frame = self.parent.parent self.safetyMode = self.parent.parent.safetyMode self.tree = datetimetree.dateTimeTree(self) img = wx.Image(self.frame.programGraphics() + "/edit_add.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.addButton = wx.BitmapButton(self, -1, img) self.Bind(wx.EVT_BUTTON, self.tree.OnActivated, self.addButton) img = wx.Image(self.frame.programGraphics() + "/2downarrow.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.expandAllButton = wx.BitmapButton(self, -1, img) self.Bind(wx.EVT_BUTTON, self.tree.OnExpandAll, self.expandAllButton) img = wx.Image(self.frame.programGraphics() + "/2uparrow.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.collapseAllButton = wx.BitmapButton(self, -1, img) self.Bind(wx.EVT_BUTTON, self.tree.OnCollapseAll, self.collapseAllButton) img = wx.Image(self.frame.programGraphics() + "/1uparrow.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.collapseAllButCurrentButton = wx.BitmapButton(self, -1, img) self.Bind(wx.EVT_BUTTON, self.tree.OnCollapseAllButCurrent, self.collapseAllButCurrentButton) self.slider = wx.Slider(self, -1, 255, 0, 255, style=wx.SL_HORIZONTAL) self.Bind(wx.EVT_SLIDER, self.OnSlide, self.slider) img = wx.Image(self.frame.programGraphics() + "/button_ok.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() self.closeButton = wx.BitmapButton(self, -1, img) self.Bind(wx.EVT_BUTTON, self.OnClose, self.closeButton) self.__doProperties() self.__doLayout() self.InitDialog() Safety(self)
class printProcess(): def __init__(self): working_path = '' count_layers = 0 self.servo = "" self.z_stepper = "" self.tilt = "" self.safety = "" self.projo = "" def printPrintingCinfig(self): print("PRINTING CONFIG :") print("Z init pos: " + repr(Configuration.z_init_pos/1000) + "mm") def initComponents(self): #~ servo = PWM.Servo() self.servo = "STUB" # Create objects self.projo = Projector() self.z_stepper = ZStepper() self.shutter = Shutter(self.servo) self.tilt = Tilt(self.servo) self.safety = Safety() self.safety.addActivePins(self.z_stepper.getUsedPins()) self.safety.addActivePins(self.shutter.getUsedPins()) self.safety.addActivePins(self.tilt.getUsedPins()) def millis_interval(self, start, end): #~ """start and end are datetime instances""" diff = end - start return diff*1000 def printTimeHMSMs(self): return "["+datetime.utcnow().strftime('%H:%M:%S.%f')[:-3]+"]" def printScenario(self, path): self.printPrintingCinfig() files = os.listdir(path) layer_actual = 1 #~ initial configuration #~ shutter.close() closedTime = time.time() #~ set to Z+ position Configuration.z_shift_distance print (self.printTimeHMSMs() + " Lowering Z axis to " + repr(Configuration.z_shift_distance)+ "mm") self.z_stepper.setTargetPosUm(Configuration.z_shift_distance, Configuration.z_shift_speed) #~ load first picture #~ start operation for each layer print ("-----------------------------------------------------------------------------------------------") for file in sorted(files): #~ ---------------- LOADING IMAGE PHASE print (self.printTimeHMSMs() + " Loading image: " + repr(file)) #~ ---------------- LOWER Z AXIS + 1 LAYER HEIGHT self.z_stepper.waitMoveEnded() self.z_stepper.setTargetPosUm(layer_actual*Configuration.layer_height, Configuration.z_shift_speed) self.z_stepper.waitMoveEnded() print (self.printTimeHMSMs() + " Z lowered at " + ("%.3f" %self.z_stepper.getZPosMm()) + "mm") while (self.millis_interval(closedTime, time.time()) < (Configuration.curing_time_intervall_layer_delay*1000)) : time.sleep(0.05) #~ ---------------- OPENING SHUTTER --> T0 CURING #~ opening shutter #~ shutter.open() print (self.printTimeHMSMs() + " Shutter opened, start curing layer #" + repr(layer_actual)) #~ ---------------- CURING PHASE if layer_actual <= Configuration.curing_first_layers_count: print (self.printTimeHMSMs() + " Wait " + repr( Configuration.curing_time_first_layers) + "s") time.sleep(Configuration.curing_time_first_layers) else: print (self.printTimeHMSMs() + " Wait " + repr( Configuration.curing_time) + "s") time.sleep(Configuration.curing_time) #~ ---------------- CLOSING SHUTTER --> T CURING #~ closing shutter #~ shutter.close() closedTime = time.time() print (self.printTimeHMSMs() + " Shutter closed") #~ ---------------- TILTING AND Z INCREMENT PHASE print (self.printTimeHMSMs() + " Start tilting") self.tilt.tiltMe() print (self.printTimeHMSMs() + " Tilt done") #~ ---------------- RAISE Z AXIS raise_z = self.z_stepper.getZPosUm() + Configuration.z_shift_distance*1000 self.z_stepper.setTargetPosUm(raise_z, Configuration.z_shift_speed) print (self.printTimeHMSMs() + " Z raising at " + ("%.3f" %(raise_z/1000)) + "mm") layer_actual += 1 print ("-----------------------------------------------------------------------------------------------")
elif user_mode_single == "matrixapply": # 0 - column, 1 - row axis = params["matrixapply_dimension"] # sd, mean, max, min, sum, median, summary operation = params["matrixapply_op"] if operation is None: use_custom = params["matrixapply_custom"] if use_custom: custom_func = params["matrixapply_custom_func"] def fun(vec): """Dummy Function""" return vec ss = Safety(custom_func, ['vec'], 'pd.Series') fun_string = ss.generateFunction() exec(fun_string) # SUPER DUPER SAFE... out_table = data.apply(fun, axis) else: print("No operation given") exit(-1) else: op = getattr(pd.DataFrame, operation) out_table = op(data, axis) elif user_mode_single == "element": # lt, gt, ge, etc. operation = params["element_op"] bool_mat = None
from controller import Controller from safety import Safety import threading if __name__ == "__main__": controller = Controller() safety_control = Safety() quit_program = False safety_thread = threading.Thread(target=safety_control.check_distances, args=(controller, 0), daemon=True) safety_thread.start() while not quit_program: quit_program = controller.choose_action()
def getTensor(self): fw = Framework() if self.carID in traci.vehicle.getIDList(): ego_trajectory = fw.getTrajectory(self.carID) intersections = fw.getIntersectingTrajectories( self.carID, ego_trajectory) if intersections is not None: #if len(ego_trajectory) > 1: framework = fw.getTensorFramework(self.carID, intersections, ego_trajectory) auto = Autonomous(self.carID, framework, ego_trajectory) distances = auto.getDistanceToIntercept() tfc = Traffic(distances) vehicles = tfc.getConflictoryTraffic() distances_tfc = tfc.getDistanceToIntercept(vehicles) self.distances_tfc = distances_tfc safe = Safety(self.carID, framework, distances, distances_tfc) trc_safety = safe.getTrafficSafetyMeasures() # print(len(distances), len(trc_safety)) ego_safety = safe.getEgoSafetyMeasures() # print(ego_safety) prio = safe.getPriotizedTraffic(ego_safety, trc_safety) rel = safe.getRelevantTraffic(prio) #print('\n', prio) #print(rel) self.rel = rel # print(rel) # for i in range(len(rel)): # if rel[i][1]: # safe.getEgoSecurityDistance(carID, rel[i][1][0][0]) env = Tensor(self.carID, distances, rel, ego_safety, ego_trajectory) #print(env.createEnvironmentTensor()) return env.createEnvironmentTensor() else: corridor = np.full((200, 3), fill_value=-1.0) #corridor[0:199, 2] = 0 corridor[0:200, 2] = 100 / np.maximum( traci.vehicle.getSpeed(self.carID), 0.001) #tensor = np.reshape(corridor[0:200], 600) return corridor
def run(self, carID): """ Executes the Traci client and the environment representation """ ego = carID step = 0 while traci.simulation.getTime() < 60: traci.simulationStep() fw = Framework() if carID in traci.vehicle.getIDList(): ego_trajectory = fw.getTrajectory(carID) intersections = fw.getIntersectingTrajectories( carID, ego_trajectory) if intersections is not None: #if len(ego_trajectory) > 1: framework = fw.getTensorFramework(carID, intersections, ego_trajectory) auto = Autonomous(carID, framework, ego_trajectory) distances = auto.getDistanceToIntercept() tfc = Traffic(distances) vehicles = tfc.getConflictoryTraffic() distances_tfc = tfc.getDistanceToIntercept(vehicles) safe = Safety(carID, framework, distances, distances_tfc) trc_safety = safe.getTrafficSafetyMeasures() #print(len(distances), len(trc_safety)) ego_safety = safe.getEgoSafetyMeasures() #print(ego_safety) prio = safe.getPriotizedTraffic(ego_safety, trc_safety) rel = safe.getRelevantTraffic(prio) #print(rel) # for i in range(len(rel)): # if rel[i][1]: # safe.getEgoSecurityDistance(carID, rel[i][1][0][0]) env = Tensor(carID, distances, rel, ego_safety, ego_trajectory) env.createEnvironmentTensor() #print(env.createEnvironmentTensor()) else: corridor = np.full((200, 3), fill_value=-1.0) corridor[0:200, 2] = 100 / np.maximum( traci.vehicle.getSpeed(self.carID), 0.001) #print(corridor) step += 1 traci.close() sys.stdout.flush()