コード例 #1
0
	def __init__(self, slicedModel):
		self.slicedModel = slicedModel
		self.isExtrusionActive = False
		self.layerIndex = 0
		self.layerLines = []
		self.lineIndex = 0
		self.lines = None
		self.oldLocation = None
		self.rowIndex = 0
		self.shouldAccumulate = True

		self.centerX = config.getfloat(name, 'center.x')
		self.centerY = config.getfloat(name, 'center.y')
		self.numberOfColumns = config.getint(name, 'columns')
		self.numberOfRows = config.getint(name, 'rows')
		self.reverseSequenceEveryOddLayer = config.getboolean(name, 'sequence.reverse.odd.layers')
		self.separationOverPerimeterWidth = config.getfloat(name, 'separation.over.perimeter.width')
		self.extrusionWidth = config.getfloat('carve', 'extrusion.width')
		self.centerOffset = complex(self.centerX, self.centerY)
		cornerMaximumComplex = self.slicedModel.carvingCornerMaximum.dropAxis()
		cornerMinimumComplex = self.slicedModel.carvingCornerMinimum.dropAxis()

		self.extent = cornerMaximumComplex - cornerMinimumComplex
		self.shapeCenter = 0.5 * (cornerMaximumComplex + cornerMinimumComplex)
		self.separation = self.separationOverPerimeterWidth * abs(self.extrusionWidth)
		self.extentPlusSeparation = self.extent + complex(self.separation, self.separation)
		columnsMinusOne = self.numberOfColumns - 1
		rowsMinusOne = self.numberOfRows - 1
		self.arrayExtent = complex(self.extentPlusSeparation.real * columnsMinusOne, self.extentPlusSeparation.imag * rowsMinusOne)
		self.arrayCenter = 0.5 * self.arrayExtent
コード例 #2
0
ファイル: bottom.py プロジェクト: miso-/SkeinforgeEngine
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.additionalHeightRatio = config.getfloat(name, "additional.height.ratio")
     self.altitude = config.getfloat(name, "altitude")
     self.layerHeight = config.getfloat("carve", "layer.height")
     self.perimeterWidth = config.getfloat("carve", "extrusion.width")
     self.decimalPlaces = config.getint("general", "decimal.places")
コード例 #3
0
	def __init__(self, slicedModel):
		self.slicedModel = slicedModel
		self.additionalHeightRatio = config.getfloat(name, 'additional.height.ratio')
		self.altitude = config.getfloat(name, 'altitude')
		self.layerThickness = config.getfloat('carve', 'layer.height')
		self.perimeterWidth = config.getfloat('carve', 'extrusion.width')
		self.decimalPlaces = config.getint('general', 'decimal.places')
コード例 #4
0
 def __init__(self, inbox, outbox, hostID, queue, monitorInterval):
     # Save arguments
     tpSize = config.getfloat('irs', 'thread_pool_size') / 2
     waitTimeout = 3
     maxTasks = config.getfloat('irs', 'max_tasks')
     self.tp = ThreadPool(tpSize, waitTimeout, maxTasks)
     self._stop = False
     self._flush = False
     self._queue = queue
     self._activeMessages = {}
     self._monitorInterval = monitorInterval
     self._hostID = int(hostID)
     self._used_slots_array = [0] * MESSAGES_PER_MAILBOX
     self._outgoingMail = EMPTYMAILBOX
     self._incomingMail = EMPTYMAILBOX
     # TODO: add support for multiple paths (multiple mailboxes)
     self._spmStorageDir = config.get('irs', 'repository')
     self._inCmd = [
         'dd', 'if=' + str(inbox), 'iflag=direct,fullblock',
         'bs=' + str(BLOCK_SIZE), 'count=' + str(BLOCKS_PER_MAILBOX),
         'skip=' + str(self._hostID * BLOCKS_PER_MAILBOX)
     ]
     self._outCmd = [
         'dd', 'of=' + str(outbox), 'iflag=fullblock', 'oflag=direct',
         'conv=notrunc', 'bs=' + str(BLOCK_SIZE),
         'seek=' + str(self._hostID * BLOCKS_PER_MAILBOX)
     ]
     self._init = False
     self._initMailbox()  # Read initial mailbox state
     self._msgCounter = 0
     self._sendMail()  # Clear outgoing mailbox
     threading.Thread.__init__(self)
     self.start()
コード例 #5
0
ファイル: Extruder.py プロジェクト: miso-/SkeinforgeEngine
    def _setParameters(self, runtimeParameters, section):
        self.decimalPlaces = runtimeParameters.decimalPlaces
        self.dimensionDecimalPlaces = runtimeParameters.dimensionDecimalPlaces
        self.extrusionUnitsRelative = runtimeParameters.extrusionUnitsRelative

        self.layerThickness = runtimeParameters.layerThickness
        self.perimeterWidth = runtimeParameters.perimeterWidth
        self.travelFeedRateMinute = runtimeParameters.travelFeedRateMinute

        self.name = config.get(section, 'name')
        self.filamentDiameter = config.getfloat(section, 'filament.diameter')
        self.filamentPackingDensity = config.getfloat(
            section, 'filament.packing.density')
        self.oozeRate = config.getfloat(section, 'oozerate')
        self.extruderRetractionSpeedMinute = round(
            60.0 * config.getfloat(section, 'retraction.speed'),
            self.dimensionDecimalPlaces)
        self.maximumRetractionDistance = config.getfloat(
            section, 'maximum.retraction')
        self.axisCode = config.get(section, 'axis.code')

        filamentRadius = 0.5 * self.filamentDiameter
        filamentPackingArea = pi * filamentRadius * filamentRadius * self.filamentPackingDensity
        extrusionArea = pi * self.layerThickness**2 / 4 + self.layerThickness * (
            self.perimeterWidth - self.layerThickness)
        #http://hydraraptor.blogspot.sk/2011/03/spot-on-flow-rate.html
        self.flowScaleSixty = 60.0 * extrusionArea / filamentPackingArea
コード例 #6
0
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.additionalHeightRatio = config.getfloat(
         name, 'additional.height.ratio')
     self.altitude = config.getfloat(name, 'altitude')
     self.layerHeight = config.getfloat('carve', 'layer.height')
     self.perimeterWidth = config.getfloat('carve', 'extrusion.width')
     self.decimalPlaces = config.getint('general', 'decimal.places')
コード例 #7
0
    def __init__(self, runtimeParameters):

        self.minimumLayerTime = config.getfloat('cool','minimum.layer.time')
        self.orbitalFeedRateSecond = runtimeParameters.orbitalFeedRateSecond
        self.orbitalFeedRateMinute = runtimeParameters.orbitalFeedRateMinute
        self.oribitalMarginDistance = config.getfloat('cool','orbital.margin')
        self.oribitalMargin = complex(self.oribitalMarginDistance, self.oribitalMarginDistance)
        self.decimalPlaces = runtimeParameters.decimalPlaces
コード例 #8
0
    def __init__(self, pool, maxHostID, monitorInterval=2):
        self._messageTypes = {}
        # Save arguments
        self._stop = False
        self._stopped = False
        self._poolID = str(pool.spUUID)
        self._spmStorageDir = pool.storage_repository
        tpSize = config.getfloat('irs', 'thread_pool_size') / 2
        waitTimeout = 3
        maxTasks = config.getfloat('irs', 'max_tasks')
        self.tp = ThreadPool(tpSize, waitTimeout, maxTasks)
        #  *** IMPORTANT NOTE: The SPM's inbox is the HSMs' outbox and vice versa *** #
        self._inbox = os.path.join(self._spmStorageDir, self._poolID,
                                   "mastersd", sd.DOMAIN_META_DATA, "inbox")
        if not os.path.exists(self._inbox):
            self.log.error(
                "SPM_MailMonitor create failed - inbox %s does not exist" %
                repr(self._inbox))
            raise RuntimeError(
                "SPM_MailMonitor create failed - inbox %s does not exist" %
                repr(self._inbox))
        self._outbox = os.path.join(self._spmStorageDir, self._poolID,
                                    "mastersd", sd.DOMAIN_META_DATA, "outbox")
        if not os.path.exists(self._outbox):
            self.log.error(
                "SPM_MailMonitor create failed - outbox %s does not exist" %
                repr(self._outbox))
            raise RuntimeError(
                "SPM_MailMonitor create failed - outbox %s does not exist" %
                repr(self._outbox))
        self._numHosts = int(maxHostID)
        self._outMailLen = MAILBOX_SIZE * self._numHosts
        self._monitorInterval = monitorInterval
        # TODO: add support for multiple paths (multiple mailboxes)
        self._outgoingMail = self._outMailLen * "\0"
        self._incomingMail = self._outgoingMail
        self._inCmd = [
            'dd', 'if=' + str(self._inbox), 'iflag=direct,fullblock', 'count=1'
        ]
        self._outCmd = [
            'dd', 'of=' + str(self._outbox), 'oflag=direct', 'iflag=fullblock',
            'conv=notrunc', 'count=1'
        ]
        self._outLock = thread.allocate_lock()
        self._inLock = thread.allocate_lock()
        # Clear outgoing mail
        self.log.debug(
            "SPM_MailMonitor - clearing outgoing mail, command is: %s",
            self._outCmd)
        cmd = self._outCmd + ['bs=' + str(self._outMailLen)]
        (rc, out, err) = misc.execCmd(cmd, sudo=False, data=self._outgoingMail)
        if rc:
            self.log.warning(
                "SPM_MailMonitor couldn't clear outgoing mail, dd failed")

        thread.start_new_thread(self.run, (self, ))
        self.log.debug('SPM_MailMonitor created for pool %s' % self._poolID)
コード例 #9
0
ファイル: taskManager.py プロジェクト: openSUSE/vdsm
 def __init__(
     self,
     tpSize=config.getfloat("irs", "thread_pool_size"),
     waitTimeout=3,
     maxTasks=config.getfloat("irs", "max_tasks"),
 ):
     self.storage_repository = config.get("irs", "repository")
     self.tp = ThreadPool(tpSize, waitTimeout, maxTasks)
     self._tasks = {}
     self._unqueuedTasks = []
コード例 #10
0
ファイル: inset.py プロジェクト: garyhodgson/SkeinforgeEngine
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.overlapRemovalWidthOverPerimeterWidth = config.getfloat(name, "overlap.removal.scaler")
     self.nozzleDiameter = config.getfloat(name, "nozzle.diameter")
     self.bridgeWidthMultiplier = config.getfloat(name, "bridge.width.multiplier.ratio")
     self.loopOrderAscendingArea = config.getboolean(name, "loop.order.preferloops")
     self.layerThickness = self.slicedModel.runtimeParameters.layerThickness
     self.perimeterWidth = self.slicedModel.runtimeParameters.perimeterWidth
     self.halfPerimeterWidth = 0.5 * self.perimeterWidth
     self.overlapRemovalWidth = self.perimeterWidth * (0.7853) * self.overlapRemovalWidthOverPerimeterWidth
     self.multiprocess = config.getboolean(name, "multiprocess")
コード例 #11
0
ファイル: carve.py プロジェクト: garyhodgson/SkeinforgeEngine
	def __init__(self, slicedModel):
		'Initialize'
		self.slicedModel = slicedModel
		self.layerHeight = config.getfloat(name, 'layer.height')
		self.extrusionWidth = config.getfloat(name, 'extrusion.width')
		self.infillBridgeDirection = config.getboolean(name, 'infill.bridge.direction')
		self.importCoarsenessRatio = config.getfloat(name, 'import.coarseness.ratio')
		self.correctMesh = config.getboolean(name, 'mesh.correct')
		self.decimalPlaces = config.getint('general', 'decimal.places')
		self.layerPrintFrom = config.getint(name, 'layer.print.from')
		self.layerPrintTo = config.getint(name, 'layer.print.to')
コード例 #12
0
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.debug = config.getboolean(name, "debug")
     self.deleteComments = config.getboolean(name, "delete.comments")
     self.fileExtension = config.get(name, "file.extension")
     self.nameOfReplaceFile = config.get(name, "replace.filename")
     self.exportSlicedModel = config.getboolean(name, "export.slicedmodel")
     self.exportSlicedModelExtension = config.get(name, "export.slicedmodel.extension")
     self.addProfileExtension = config.getboolean(name, "file.extension.profile")
     self.overwriteExportedSlicedModel = config.getboolean(name, "overwrite.exported.slicedmodel")
     self.firstLayerFeedRateRatio = config.getfloat("speed", "feed.rate.first.layer.ratio")
     self.firstLayerFlowRateRatio = config.getfloat("speed", "flow.rate.first.layer.ratio")
コード例 #13
0
ファイル: bottom.py プロジェクト: miso-/SkeinforgeEngine
def performAction(slicedModel):
    "Align the model to the bottom of the printing plane"

    # HACK these options are in "speed" section so they should be set no matter if bottom plugin is active
    firstLayerFeedRateRatio = config.getfloat("speed", "feed.rate.first.layer.ratio")
    firstLayerFlowRateRatio = config.getfloat("speed", "flow.rate.first.layer.ratio")
    slicedModel.layers[0].feedAndFlowRateMultiplier = [firstLayerFeedRateRatio, firstLayerFlowRateRatio]

    if not config.getboolean(name, "active"):
        logger.info("%s plugin is not active", name.capitalize())
        return
    BottomSkein(slicedModel).bottom()
コード例 #14
0
ファイル: skirt.py プロジェクト: miso-/SkeinforgeEngine
    def __init__(self, slicedModel):
        self.slicedModel = slicedModel

        self.convex = config.getboolean(name, 'convex')
        self.gapOverPerimeterWidth = config.getfloat(name, 'gap.over.perimeter.width')
        self.layersTo = config.getint(name, 'layers.to.index')
        self.edgeWidth = slicedModel.runtimeParameters.extrusionWidth
        brimWidth = config.getfloat(name, 'brim.width')
        self.skirtGap = self.gapOverPerimeterWidth * self.edgeWidth + brimWidth
        self.brimLoopsCount = int(brimWidth / self.edgeWidth)
        self.outerInner = config.getboolean(name, 'order.outer.inner')
        self.unifiedLoop = LoopCrossDictionary()
        self.createSegmentDictionaries(self.unifiedLoop)
コード例 #15
0
ファイル: carve.py プロジェクト: miso-/SkeinforgeEngine
 def __init__(self, slicedModel):
     'Initialize'
     self.slicedModel = slicedModel
     self.layerHeight = config.getfloat(name, 'layer.height')
     self.extrusionWidth = config.getfloat(name, 'extrusion.width')
     self.infillBridgeDirection = config.getboolean(
         name, 'infill.bridge.direction')
     self.importCoarsenessRatio = config.getfloat(
         name, 'import.coarseness.ratio')
     self.correctMesh = config.getboolean(name, 'mesh.correct')
     self.decimalPlaces = config.getint('general', 'decimal.places')
     self.layerPrintFrom = config.getint(name, 'layer.print.from')
     self.layerPrintTo = config.getint(name, 'layer.print.to')
コード例 #16
0
ファイル: skirt.py プロジェクト: miso-/SkeinforgeEngine
    def __init__(self, slicedModel):
        self.slicedModel = slicedModel

        self.convex = config.getboolean(name, "convex")
        self.gapOverPerimeterWidth = config.getfloat(name, "gap.over.perimeter.width")
        self.layersTo = config.getint(name, "layers.to.index")
        self.edgeWidth = slicedModel.runtimeParameters.extrusionWidth
        brimWidth = config.getfloat(name, "brim.width")
        self.skirtGap = self.gapOverPerimeterWidth * self.edgeWidth + brimWidth
        self.brimLoopsCount = int(brimWidth / self.edgeWidth)
        self.outerInner = config.getboolean(name, "order.outer.inner")
        self.unifiedLoop = LoopCrossDictionary()
        self.createSegmentDictionaries(self.unifiedLoop)
コード例 #17
0
    def __init__(self, slicedModel):
        self.slicedModel = slicedModel
        self.boundaryLayers = []
        self.supportLayers = []

        self.debug = config.getboolean(configSection, 'debug')
        self.supportLocation = config.get(configSection, 'location')
        self.supportMinimumAngle = config.getfloat(configSection, 'min.angle')
        self.minimumSupportRatio = math.tan(
            math.radians(self.supportMinimumAngle))
        self.supportCrossHatchNthLayer = config.getint(
            configSection, 'crosshatch.every.nth.layer')
        self.supportFeedRate = config.getfloat('speed', 'feed.rate.support')
        self.supportFlowRateRatio = config.getfloat('speed',
                                                    'flow.rate.support.ratio')

        self.raftAdditionalMarginOverLengthPercent = config.getfloat(
            configSection, 'extension.percent')
        self.raftMargin = config.getfloat(configSection, 'extension.distance')
        self.infillOverhangOverExtrusionWidth = config.getfloat(
            configSection, 'infill.overhang.ratio')

        self.supportStartFile = config.get(configSection, 'support.start.file')
        self.supportEndFile = config.get(configSection, 'support.end.file')
        self.absoluteSupportStartFilePath = os.path.join(
            'alterations', self.supportStartFile)
        self.absoluteSupportEndFilePath = os.path.join('alterations',
                                                       self.supportEndFile)
        self.supportStartLines = archive.getTextLines(
            archive.getFileText(self.absoluteSupportStartFilePath,
                                printWarning=False))
        self.supportEndLines = archive.getTextLines(
            archive.getFileText(self.absoluteSupportEndFilePath,
                                printWarning=False))

        self.extrusionWidth = config.getfloat('carve', 'extrusion.width')
        self.supportGapOverPerimeterExtrusionWidth = config.getfloat(
            configSection, 'gap.over.perimeter.extrusion.width.ratio')
        self.supportOutset = self.extrusionWidth * self.supportGapOverPerimeterExtrusionWidth

        self.interfaceInfillDensity = config.getfloat(
            configSection, 'interface.infill.density')
        self.interfaceLayerThicknessRatio = config.getfloat(
            configSection, 'interface.layer.thickness.ratio')
        interfaceExtrusionWidth = self.extrusionWidth * self.interfaceLayerThicknessRatio
        self.interfaceStep = interfaceExtrusionWidth / self.interfaceInfillDensity

        self.cornerMinimum = self.slicedModel.carvingCornerMinimum
        self.cornerMaximum = self.slicedModel.carvingCornerMaximum
        self.cornerMinimumComplex = self.cornerMinimum.dropAxis()
        self.cornerMaximumComplex = self.cornerMaximum.dropAxis()
コード例 #18
0
ファイル: storage_mailbox.py プロジェクト: openSUSE/vdsm
    def __init__(self, pool, maxHostID, monitorInterval=2):
        self._messageTypes = {}
        # Save arguments
        self._stop = False
        self._stopped = False
        self._poolID = str(pool.spUUID)
        self._spmStorageDir = pool.storage_repository
        tpSize = config.getfloat('irs', 'thread_pool_size') / 2
        waitTimeout = 3
        maxTasks = config.getfloat('irs', 'max_tasks')
        self.tp = ThreadPool(tpSize, waitTimeout, maxTasks)
        #  *** IMPORTANT NOTE: The SPM's inbox is the HSMs' outbox and vice versa *** #
        self._inbox = os.path.join(self._spmStorageDir, self._poolID, "mastersd", sd.DOMAIN_META_DATA, "inbox")
        if not os.path.exists(self._inbox):
            self.log.error("SPM_MailMonitor create failed - inbox %s does not exist" % repr(self._inbox))
            raise RuntimeError("SPM_MailMonitor create failed - inbox %s does not exist" % repr(self._inbox))
        self._outbox = os.path.join(self._spmStorageDir, self._poolID, "mastersd", sd.DOMAIN_META_DATA, "outbox")
        if not os.path.exists(self._outbox):
            self.log.error("SPM_MailMonitor create failed - outbox %s does not exist" % repr(self._outbox))
            raise RuntimeError("SPM_MailMonitor create failed - outbox %s does not exist" % repr(self._outbox))
        self._numHosts = int(maxHostID)
        self._outMailLen = MAILBOX_SIZE * self._numHosts
        self._monitorInterval = monitorInterval
        # TODO: add support for multiple paths (multiple mailboxes)
        self._outgoingMail = self._outMailLen * "\0"
        self._incomingMail = self._outgoingMail
        self._inCmd = ['dd',
                        'if=' + str(self._inbox),
                        'iflag=direct,fullblock',
                        'count=1'
                        ]
        self._outCmd = ['dd',
                        'of=' + str(self._outbox),
                        'oflag=direct',
                        'iflag=fullblock',
                        'conv=notrunc',
                        'count=1'
                        ]
        self._outLock = thread.allocate_lock()
        self._inLock = thread.allocate_lock()
        # Clear outgoing mail
        self.log.debug("SPM_MailMonitor - clearing outgoing mail, command is: %s", self._outCmd)
        cmd = self._outCmd + ['bs=' + str(self._outMailLen)]
        (rc, out, err) = misc.execCmd(cmd, sudo=False, data=self._outgoingMail)
        if rc:
            self.log.warning("SPM_MailMonitor couldn't clear outgoing mail, dd failed")

        thread.start_new_thread(self.run, (self, ))
        self.log.debug('SPM_MailMonitor created for pool %s' % self._poolID)
コード例 #19
0
ファイル: inset.py プロジェクト: miso-/SkeinforgeEngine
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.overlapRemovalWidthOverPerimeterWidth = config.getfloat(
         name, 'overlap.removal.scaler')
     self.nozzleDiameter = config.getfloat(name, 'nozzle.diameter')
     self.bridgeWidthMultiplier = config.getfloat(
         name, 'bridge.width.multiplier.ratio')
     self.loopOrderAscendingArea = config.getboolean(
         name, 'loop.order.preferloops')
     self.layerThickness = self.slicedModel.runtimeParameters.layerThickness
     self.perimeterWidth = self.slicedModel.runtimeParameters.perimeterWidth
     self.halfPerimeterWidth = 0.5 * self.perimeterWidth
     self.overlapRemovalWidth = self.perimeterWidth * (
         0.7853) * self.overlapRemovalWidthOverPerimeterWidth
     self.multiprocess = config.getboolean(name, 'multiprocess')
コード例 #20
0
def performAction(slicedModel):
    "Align the model to the bottom of the printing plane"

    # HACK these options are in "speed" section so they should be set no matter if bottom plugin is active
    firstLayerFeedRateRatio = config.getfloat('speed',
                                              'feed.rate.first.layer.ratio')
    firstLayerFlowRateRatio = config.getfloat('speed',
                                              'flow.rate.first.layer.ratio')
    slicedModel.layers[0].feedAndFlowRateMultiplier = [
        firstLayerFeedRateRatio, firstLayerFlowRateRatio
    ]

    if not config.getboolean(name, 'active'):
        logger.info("%s plugin is not active", name.capitalize())
        return
    BottomSkein(slicedModel).bottom()
    def __init__(self):
        self.subtractor = cv2.createBackgroundSubtractorMOG2()

        self.subtractor.setHistory(config.getint('HISTORY'))
        self.subtractor.setDetectShadows(config.getboolean('DETECT_SHADOWS'))
        self.subtractor.setShadowThreshold(config.getfloat('SHADOW_THRESHOLD'))
        self.subtractor.setShadowValue(0)
        self.subtractor.setNMixtures(config.getint('N_MIXTURES'))
コード例 #22
0
 def __init__(self):
     self.min_dist_between_blobs = config.getint('MIN_DIST_BETWEEN_BLOBS')
     self.filter_by_area = [config.getboolean('FILTER_BY_AREA'),
                            config.getint('MIN_AREA'),
                            config.getint('MAX_AREA')]
     self.overlap_threshold = config.getfloat('OVERLAP_THRESHOLD')
     self.detections = []
     self.blob_assigner = HungarianAlgorithm()
コード例 #23
0
 def __init__(self, gmitm, msg, external):
     self.branch = msg.via0.branch
     self.gmitm = gmitm
     self.cseq = msg.cseq
     self.isInvite = msg.method == 'INVITE'
     self.external = external
     self.cachedRequests  = {} # dict "method" of (msg, raw string of transformed message, addr)
     self.cachedResponses = {} # dict "method" of (msg, raw string of transformed message, addr, code)
     self.logtimer = config.getboolean(consts.SECTION, consts.LOGTIMERS)
     self.logtimer = False # too many output
     self.logbm = config.getboolean(consts.SECTION, consts.LOGBMEVENTS)
     self.sipdelay = config.getboolean(consts.SECTION, consts.SIPDELAY)
     self.log("created")
     if self.isInvite:
         self.set_timeout(config.getfloat(consts.SECTION, consts.TIMERB))
     else:
         self.set_timeout(config.getfloat(consts.SECTION, consts.TIMERF))
コード例 #24
0
 def __init__(self, slicedModel):
     # TODO - remove or reduce dependency on slicedModel
     self.slicedModel = slicedModel
     
     self.infillSolidity = config.getfloat('fill', 'infill.solidity.ratio')
     self.infillWidthOverThickness = config.getfloat('fill', 'extrusion.lines.extra.spacer.scaler')
     self.infillPerimeterOverlap = config.getfloat('fill', 'infill.overlap.over.perimeter.scaler')
     self.extraShellsAlternatingSolidLayer = config.getint('fill', 'shells.alternating.solid')
     self.extraShellsBase = config.getint('fill', 'shells.base')
     self.extraShellsSparseLayer = config.getint('fill', 'shells.sparse')
     self.solidSurfaceThickness = config.getint('fill', 'fully.filled.layers')
     self.doubleSolidSurfaceThickness = self.solidSurfaceThickness + self.solidSurfaceThickness
     self.startFromChoice = config.get('fill', 'extrusion.sequence.start.layer')
     self.threadSequenceChoice = config.get('fill', 'extrusion.sequence.print.order')
     self.threadSequence = self.threadSequenceChoice.split(",")
     self.diaphragmPeriod = config.getint('fill', 'diaphragm.every.n.layers')
     self.diaphragmThickness = config.getint('fill', 'diaphragm.thickness')
     self.infillBeginRotation = math.radians(config.getfloat('fill', 'infill.rotation.begin'))
     self.infillBeginRotationRepeat = config.getint('fill', 'infill.rotation.repeat')
     self.infillOddLayerExtraRotation = math.radians(config.getfloat('fill', 'infill.rotation.odd.layer'))
     self.bridgeWidthMultiplier = config.getfloat('inset', 'bridge.width.multiplier.ratio')
     self.extrusionWidth = config.getfloat('carve', 'extrusion.width')
     self.infillWidth = self.extrusionWidth * self.infillWidthOverThickness * (0.7853)
     self.betweenWidth = self.extrusionWidth * self.infillWidthOverThickness * (0.7853)
     self.previousExtraShells = -1
     self.oldOrderedLocation = None
コード例 #25
0
ファイル: CallController.py プロジェクト: zsipos/zsipos
 def __init__(self, gmitm, msg, incoming):
     self.gmitm = gmitm
     self.logevents = config.getboolean(consts.SECTION, consts.LOGCCEVENTS)
     self.logmessages = config.getboolean(consts.SECTION,
                                          consts.LOGCCMESSAGES)
     self.logfullmessage = config.getboolean(consts.SECTION,
                                             consts.LOGFULLMESSAGE)
     self.cseq = msg.cseq
     self.cid = msg.cid
     self.incoming = incoming
     self.finalCode = None
     self.lastcseq = self.cseq
     self.cseqoffset = [0, 0]
     self.t3seconds = config.getfloat(consts.SECTION, consts.TIMERC)
     self.tsseconds = config.getfloat(consts.SECTION, consts.TIMERS)
     self.zsession = CyZRTPSession(self, consts.ZIDFILE)
     self.logtimer = config.getboolean(consts.SECTION, consts.LOGTIMERS)
     self.terminated = False
     self.clear_udp_addresses()
     self.on_created(msg)
コード例 #26
0
ファイル: Extruder.py プロジェクト: miso-/SkeinforgeEngine
    def _setParameters(self, runtimeParameters, section):
        self.decimalPlaces = runtimeParameters.decimalPlaces
        self.dimensionDecimalPlaces = runtimeParameters.dimensionDecimalPlaces
        self.extrusionUnitsRelative = runtimeParameters.extrusionUnitsRelative

        self.layerThickness = runtimeParameters.layerThickness
        self.perimeterWidth = runtimeParameters.perimeterWidth
        self.travelFeedRateMinute = runtimeParameters.travelFeedRateMinute

        self.name = config.get(section, 'name')
        self.filamentDiameter = config.getfloat(section, 'filament.diameter')
        self.filamentPackingDensity = config.getfloat(section, 'filament.packing.density')
        self.oozeRate = config.getfloat(section, 'oozerate')
        self.extruderRetractionSpeedMinute  = round(60.0 * config.getfloat(section, 'retraction.speed'), self.dimensionDecimalPlaces)
        self.maximumRetractionDistance = config.getfloat(section, 'maximum.retraction')
        self.axisCode = config.get(section, 'axis.code')

        filamentRadius = 0.5 * self.filamentDiameter
        filamentPackingArea = pi * filamentRadius * filamentRadius * self.filamentPackingDensity
        extrusionArea = pi * self.layerThickness ** 2 / 4 + self.layerThickness * (self.perimeterWidth - self.layerThickness)
            #http://hydraraptor.blogspot.sk/2011/03/spot-on-flow-rate.html
        self.flowScaleSixty = 60.0 * extrusionArea / filamentPackingArea
コード例 #27
0
ファイル: storage_mailbox.py プロジェクト: openSUSE/vdsm
 def __init__(self, inbox, outbox, hostID, queue, monitorInterval):
     # Save arguments
     tpSize = config.getfloat('irs', 'thread_pool_size') / 2
     waitTimeout = 3
     maxTasks = config.getfloat('irs', 'max_tasks')
     self.tp = ThreadPool(tpSize, waitTimeout, maxTasks)
     self._stop = False
     self._flush = False
     self._queue = queue
     self._activeMessages = {}
     self._monitorInterval = monitorInterval
     self._hostID = int(hostID)
     self._used_slots_array = [ 0 ] * MESSAGES_PER_MAILBOX
     self._outgoingMail = EMPTYMAILBOX
     self._incomingMail = EMPTYMAILBOX
     # TODO: add support for multiple paths (multiple mailboxes)
     self._spmStorageDir = config.get('irs', 'repository')
     self._inCmd = ['dd',
                     'if=' + str(inbox),
                     'iflag=direct,fullblock',
                     'bs=' + str(BLOCK_SIZE),
                     'count=' + str(BLOCKS_PER_MAILBOX),
                     'skip=' + str(self._hostID*BLOCKS_PER_MAILBOX)
                     ]
     self._outCmd = ['dd',
                     'of=' + str(outbox),
                     'iflag=fullblock',
                     'oflag=direct',
                     'conv=notrunc',
                     'bs=' + str(BLOCK_SIZE),
                     'seek=' + str(self._hostID*BLOCKS_PER_MAILBOX)
                     ]
     self._init = False
     self._initMailbox() # Read initial mailbox state
     self._msgCounter = 0
     self._sendMail() # Clear outgoing mailbox
     threading.Thread.__init__(self)
     self.start()
コード例 #28
0
    def __init__(self, slicedModel):
        self.slicedModel = slicedModel
        self.boundaryLayers = []
        self.supportLayers = []

        self.debug = config.getboolean(configSection, 'debug')
        self.supportLocation = config.get(configSection, 'location')
        self.supportMinimumAngle = config.getfloat(configSection, 'min.angle')
        self.minimumSupportRatio = math.tan(math.radians(self.supportMinimumAngle))
        self.supportCrossHatchNthLayer = config.getint(configSection, 'crosshatch.every.nth.layer')
        self.supportFeedRate = config.getfloat('speed', 'feed.rate.support')
        self.supportFlowRateRatio = config.getfloat('speed', 'flow.rate.support.ratio')

        self.raftAdditionalMarginOverLengthPercent = config.getfloat(configSection, 'extension.percent')
        self.raftMargin = config.getfloat(configSection, 'extension.distance')
        self.infillOverhangOverExtrusionWidth = config.getfloat(configSection, 'infill.overhang.ratio')

        self.supportStartFile = config.get(configSection, 'support.start.file')
        self.supportEndFile = config.get(configSection, 'support.end.file')
        self.absoluteSupportStartFilePath = os.path.join('alterations', self.supportStartFile)
        self.absoluteSupportEndFilePath = os.path.join('alterations', self.supportEndFile)
        self.supportStartLines = archive.getTextLines(archive.getFileText(self.absoluteSupportStartFilePath, printWarning=False))
        self.supportEndLines = archive.getTextLines(archive.getFileText(self.absoluteSupportEndFilePath, printWarning=False))

        self.extrusionWidth = config.getfloat('carve', 'extrusion.width')
        self.supportGapOverPerimeterExtrusionWidth = config.getfloat(configSection, 'gap.over.perimeter.extrusion.width.ratio')
        self.supportOutset = self.extrusionWidth * self.supportGapOverPerimeterExtrusionWidth

        self.interfaceInfillDensity = config.getfloat(configSection, 'interface.infill.density')
        self.interfaceLayerThicknessRatio = config.getfloat(configSection, 'interface.layer.thickness.ratio')
        interfaceExtrusionWidth = self.extrusionWidth * self.interfaceLayerThicknessRatio
        self.interfaceStep = interfaceExtrusionWidth / self.interfaceInfillDensity

        self.cornerMinimum = self.slicedModel.carvingCornerMinimum
        self.cornerMaximum = self.slicedModel.carvingCornerMaximum
        self.cornerMinimumComplex = self.cornerMinimum.dropAxis()
        self.cornerMaximumComplex = self.cornerMaximum.dropAxis()
コード例 #29
0
    def __init__(self, slicedModel):
        self.slicedModel = slicedModel
        self.isExtrusionActive = False
        self.layerIndex = 0
        self.layerLines = []
        self.lineIndex = 0
        self.lines = None
        self.oldLocation = None
        self.rowIndex = 0
        self.shouldAccumulate = True

        self.centerX = config.getfloat(name, 'center.x')
        self.centerY = config.getfloat(name, 'center.y')
        self.numberOfColumns = config.getint(name, 'columns')
        self.numberOfRows = config.getint(name, 'rows')
        self.reverseSequenceEveryOddLayer = config.getboolean(
            name, 'sequence.reverse.odd.layers')
        self.separationOverPerimeterWidth = config.getfloat(
            name, 'separation.over.perimeter.width')
        self.extrusionWidth = config.getfloat('carve', 'extrusion.width')
        self.centerOffset = complex(self.centerX, self.centerY)
        cornerMaximumComplex = self.slicedModel.carvingCornerMaximum.dropAxis()
        cornerMinimumComplex = self.slicedModel.carvingCornerMinimum.dropAxis()

        self.extent = cornerMaximumComplex - cornerMinimumComplex
        self.shapeCenter = 0.5 * (cornerMaximumComplex + cornerMinimumComplex)
        self.separation = self.separationOverPerimeterWidth * abs(
            self.extrusionWidth)
        self.extentPlusSeparation = self.extent + complex(
            self.separation, self.separation)
        columnsMinusOne = self.numberOfColumns - 1
        rowsMinusOne = self.numberOfRows - 1
        self.arrayExtent = complex(
            self.extentPlusSeparation.real * columnsMinusOne,
            self.extentPlusSeparation.imag * rowsMinusOne)
        self.arrayCenter = 0.5 * self.arrayExtent
コード例 #30
0
class TP3Spacy:
    DATA_DIR = 'data'

    OUTPUT_DATAFILE = config.get('files', 'words data file')

    SIMILARITY_TOLERANCE = config.getfloat('misc', 'similarity tolerance')

    REPORT_SIZE = config.getint('misc', 'report size')

    nlp: Union[None, English] = None

    @classmethod
    def get_data(cls):
        cls.nlp = spacy.load(cls.DATA_DIR)

    @classmethod
    def most_similar(cls, word: Lexeme) -> List[Lexeme]:
        """
        Basé sur: https://stackoverflow.com/a/58932131/313273
        """
        queries = [
            w for w in word.vocab if w.is_lower == word.is_lower
            and w.prob >= -25 and word.similarity(w) > cls.SIMILARITY_TOLERANCE
        ]
        by_similarity = sorted(queries,
                               key=lambda w: word.similarity(w),
                               reverse=True)
        return by_similarity

    @classmethod
    def produce_report_data(cls):
        if cls.nlp is None:
            cls.get_data()
        index = 0
        words = []
        with open(cls.OUTPUT_DATAFILE, 'r') as f:
            while index < cls.REPORT_SIZE:
                index += 1
                line = f.readline()
                line = line.split('\t')
                line = line[0]
                words.append(line)
        words = [cls.nlp.vocab[w] for w in words]
        cls.report = {}
        for word in words:
            similar = cls.most_similar(word)
            cls.report[word.text] = [s.text for s in similar]
コード例 #31
0
    def __init__(self, slicedModel):
        # TODO - remove or reduce dependency on slicedModel
        self.slicedModel = slicedModel

        self.infillSolidity = config.getfloat('fill', 'infill.solidity.ratio')
        self.infillWidthOverThickness = config.getfloat(
            'fill', 'extrusion.lines.extra.spacer.scaler')
        self.infillPerimeterOverlap = config.getfloat(
            'fill', 'infill.overlap.over.perimeter.scaler')
        self.extraShellsAlternatingSolidLayer = config.getint(
            'fill', 'shells.alternating.solid')
        self.extraShellsBase = config.getint('fill', 'shells.base')
        self.extraShellsSparseLayer = config.getint('fill', 'shells.sparse')
        self.solidSurfaceThickness = config.getint('fill',
                                                   'fully.filled.layers')
        self.doubleSolidSurfaceThickness = self.solidSurfaceThickness + self.solidSurfaceThickness
        self.startFromChoice = config.get('fill',
                                          'extrusion.sequence.start.layer')
        self.threadSequenceChoice = config.get(
            'fill', 'extrusion.sequence.print.order')
        self.threadSequence = self.threadSequenceChoice.split(",")
        self.diaphragmPeriod = config.getint('fill',
                                             'diaphragm.every.n.layers')
        self.diaphragmThickness = config.getint('fill', 'diaphragm.thickness')
        self.infillBeginRotation = math.radians(
            config.getfloat('fill', 'infill.rotation.begin'))
        self.infillBeginRotationRepeat = config.getint(
            'fill', 'infill.rotation.repeat')
        self.infillOddLayerExtraRotation = math.radians(
            config.getfloat('fill', 'infill.rotation.odd.layer'))
        self.bridgeWidthMultiplier = config.getfloat(
            'inset', 'bridge.width.multiplier.ratio')
        self.extrusionWidth = config.getfloat('carve', 'extrusion.width')
        self.infillWidth = self.extrusionWidth * self.infillWidthOverThickness * (
            0.7853)
        self.betweenWidth = self.extrusionWidth * self.infillWidthOverThickness * (
            0.7853)
        self.previousExtraShells = -1
        self.oldOrderedLocation = None
コード例 #32
0
import multiprocessing
import itertools
import numpy as np   
import tensorflow as tf
import time
import random
import scipy.stats as ss
import sys
import os 
os.environ["TF_CPP_MIN_LOG_LEVEL"]='2'
#####################  hyper parameters  ##############################

MAX_EPISODES = config.getint('parameter', 'max_episodes')
MAX_EP_STEPS = config.getint('parameter', 'max_ep_steps')
LR_A = config.getfloat('parameter', 'lr_a')
LR_C = config.getfloat('parameter', 'lr_c')
GAMMA = config.getfloat('parameter', 'gamma')
TAU = config.getfloat('parameter', 'tau')
H_DEF = config.getint('parameter', 'h_def')
H_ADV = config.getint('parameter', 'h_adv')

TRAINING_MODE = config.get('parameter', 'training_mode')
TEST_MODE = config.get('parameter', 'test_mode')
MEMORY_CAPACITY = config.getint('parameter', 'memory_capacity')
MEMORY_INIT = config.getint('parameter', 'memory_init')
BATCH_SIZE = config.getint('parameter', 'batch_size')
LEARNING_STEP = config.getint('parameter', 'learning_step')
LEARNING_COUNT = config.getint('parameter', 'learning_count')
EPSILON_DISCOUNT = config.getfloat('parameter', 'epsilon_discount')
EPSILON_MAX = config.getfloat('parameter', 'epsilon_max')
コード例 #33
0
ファイル: fill.py プロジェクト: miso-/SkeinforgeEngine
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.extrusionWidth = config.getfloat('carve', 'extrusion.width')
     self.fillStrategyName = config.get(name, 'strategy')
     self.fillStrategyPath = config.get(name, 'strategy.path')
コード例 #34
0
from common import connectClient
from mysocket import connectTcp, connectTcpFail
from config import config
from socket import gethostbyname

TIMEOUT = config.getfloat("filter", "timeout")
VALID_PORT = config.getint("filter", "valid_port")
INVALID_PORT = config.getint("filter", "invalid_port")
HOST = gethostbyname(config.get("filter", "host"))
IFACE = config.get("filter", "iface")


def testPortFailure(testcase, iptables, client, port, err):
    # Enable iptables filtering
    iptables.filterTcp(VALID_PORT)

    # Connect user
    if client:
        testcase.assert_(connectClient(client))

    # Create socket
    testcase.assertEqual(connectTcpFail(HOST, port, TIMEOUT), err)


def testPort(testcase, iptables, client, port, ok, host=HOST):
    # Enable iptables filtering
    iptables.filterTcp(VALID_PORT)

    # Connect user
    if client:
        testcase.assert_(connectClient(client))
コード例 #35
0
ファイル: nuauth.py プロジェクト: regit/nufw
import atexit
from inl_tests.process import Process
from signal import SIGHUP
from mysocket import connectTcp
from config import config, NUAUTH_PROG, NUAUTH_START_TIMEOUT, USE_VALGRIND
from time import time

RELOAD_TIMEOUT = config.getfloat("nuauth", "reload_timeout")
INIT_TIMEOUT = 0.100   # 100 ms

class NuauthProcess(Process):
    __instance = None

    @classmethod
    def hasInstance(cls):
        return not(cls.__instance is None)

    @classmethod
    def getInstance(cls):
        if cls.__instance is None:
            cls.__instance = NuauthProcess()
            atexit.register(cls._reallyStop)
        return cls.__instance

    def __init__(self, debug_level=9):
        arg = ["-" + "v" * min(max(debug_level, 1), 9)]
        program = NUAUTH_PROG
        if USE_VALGRIND:
            #arg = ["--tool=callgrind", program] + arg
            #program = "valgrind"
            arg = ["--log-file-exactly=nuauth.valgrind.log", "--verbose", program] + arg
コード例 #36
0
    def __init__(self):
        self.startTime = time.time()
        self.endTime = None
        self.inputFilename = None
        self.outputFilename = None

        self.profileMemory = config.getboolean('general', 'profile.memory')

        self.decimalPlaces = config.getint('general', 'decimal.places')
        self.layerThickness = config.getfloat('carve', 'layer.height')
        self.perimeterWidth = config.getfloat('carve', 'extrusion.width')
        self.profileName = None
        self.bridgeWidthMultiplier = None
        self.nozzleDiameter = None
        self.threadSequence = None
        self.infillWidth = None
        self.operatingFeedRatePerSecond = None
        self.perimeterFeedRatePerSecond = None
        self.operatingFlowRate = None
        self.verboseGcode = config.getboolean('general', 'verbose.gcode')

        self.overlapRemovalWidthOverPerimeterWidth = config.getfloat('inset', 'overlap.removal.scaler')
        self.nozzleDiameter = config.getfloat('inset', 'nozzle.diameter')
        self.bridgeWidthMultiplier = config.getfloat('inset', 'bridge.width.multiplier.ratio')
        self.loopOrderAscendingArea = config.getboolean('inset', 'loop.order.preferloops')

        self.layerHeight = config.getfloat('carve', 'layer.height')
        self.extrusionWidth = config.getfloat('carve', 'extrusion.width')
        self.infillBridgeDirection = config.getboolean('carve', 'infill.bridge.direction')
        self.importCoarsenessRatio = config.getfloat('carve', 'import.coarseness.ratio')
        self.correctMesh = config.getboolean('carve', 'mesh.correct')
        self.decimalPlaces = config.getint('general', 'decimal.places')
        self.layerPrintFrom = config.getint('carve', 'layer.print.from')
        self.layerPrintTo = config.getint('carve', 'layer.print.to')

        self.speedActive = config.getboolean('speed', 'active')
        self.addFlowRate = config.getboolean('speed', 'add.flow.rate')
        self.addAccelerationRate = config.getboolean('speed', 'add.acceleration.rate')
        self.feedRate = config.getfloat('speed', 'feed.rate')
        self.flowRateRatio = config.getfloat('speed', 'flow.rate.ratio')
        self.accelerationRate = config.getfloat('speed', 'acceleration.rate')
        self.orbitalFeedRateRatio = config.getfloat('speed', 'feed.rate.orbiting.ratio')
        self.perimeterFeedRate = config.getfloat('speed', 'feed.rate.perimeter')
        self.perimeterFlowRateRatio = config.getfloat('speed', 'flow.rate.perimeter.ratio')
        self.bridgeFeedRateRatio = config.getfloat('speed', 'feed.rate.bridge.ratio')
        self.bridgeFlowRateRatio = config.getfloat('speed', 'flow.rate.bridge.ratio')
        self.travelFeedRate = config.getfloat('speed', 'feed.rate.travel')
        self.supportFeedRate = config.getfloat('speed', 'feed.rate.support')

        self.dimensionActive = config.getboolean('dimension', 'active')
        self.extrusionUnitsRelative = config.getboolean('dimension', 'extrusion.units.relative')
        self.dimensionDecimalPlaces = config.getint('dimension', 'decimal.places')

        self.extrusionPrintOrder = config.get('fill', 'extrusion.sequence.print.order').split(',')

        self.bridgeFeedRateMinute = self.bridgeFeedRateRatio * self.perimeterFeedRate * 60 # todo former reference to main feed now perimeter feed
        self.perimeterFeedRateMinute = self.perimeterFeedRate * 60
        self.extrusionFeedRateMinute = self.feedRate * 60.0
        self.travelFeedRateMinute = self.travelFeedRate * 60

        self.supportFeedRateMinute = self.supportFeedRate * 60

        self.minimumLayerFeedRate = config.getfloat('cool', 'minimum.layer.feed.rate')
        self.minimumLayerFeedRateMinute = self.minimumLayerFeedRate * 60

        self.minimumBridgeFeedRateMultiplier = self.minimumLayerFeedRateMinute / self.bridgeFeedRateMinute
        self.minimumPerimeterFeedRateMultiplier = self.minimumLayerFeedRateMinute / self.perimeterFeedRateMinute
        self.minimumExtrusionFeedRateMultiplier = self.minimumLayerFeedRateMinute / self.extrusionFeedRateMinute
        self.minimumTravelFeedRateMultiplier = self.minimumLayerFeedRateMinute / self.travelFeedRateMinute

        nozzleXsection = (self.nozzleDiameter / 2) ** 2 * pi
        extrusionXsection = ((abs(self.perimeterWidth) + self.layerThickness) / 4) ** 2 * pi

        self.flowRate = self.flowRateRatio * self.feedRate
        self.bridgeFlowRate = (self.bridgeFlowRateRatio * self.bridgeFeedRateRatio) * (self.perimeterFlowRateRatio * self.perimeterFeedRate) * (nozzleXsection / extrusionXsection)
        self.perimeterFlowRate = self.perimeterFlowRateRatio * self.perimeterFeedRate

        self.orbitalFeedRateSecond = (self.feedRate * self.orbitalFeedRateRatio)
        self.orbitalFeedRateMinute = self.orbitalFeedRateSecond * 60

        self.combActive = config.getboolean('comb', 'active')
コード例 #37
0
 def __init__(self, runtimeParameters):
     
     self.minimumLayerTime = config.getfloat('cool','minimum.layer.time')
コード例 #38
0
# Config location
data_dir = config.get('Configuration', 'dir', fallback=DEFAULT_DATA_DIR)

# Link Issuer name
issuer = config.get('App', 'issuer', fallback="")

# Link validity in days
validity_days = config.getint('App', 'validity_days', fallback="")

# Request lifetime in seconds
request_lifetime = config.getint('App', 'request_lifetime', fallback="")

# Similarity threshold to consider a request accepted
acceptance_threshold = config.getfloat('App',
                                       'acceptance_threshold',
                                       fallback="")

# Which LLoA will have the resulting link if accepted
lloa = config.get('App', 'lloa', fallback="low")

# Type of the generated link dataset
dataset_type = config.get('App', 'dataset_type', fallback="")

# Private RSA key to use
httpsig_private_key = config.get('HTTPSig', 'private_key')

# Identifier of the entity (usually the SHA256 hex-encoded fingerprint of the key)
httpsig_key_id = config.get('HTTPSig', 'key_id', fallback=None)

# As SM sometimes fails to validate signature, we retry the connection for resilience
コード例 #39
0
ファイル: taskManager.py プロジェクト: vikas-lamba/vdsm
 def __init__(self, tpSize=config.getfloat('irs', 'thread_pool_size'), waitTimeout=3, maxTasks=config.getfloat('irs', 'max_tasks')):
     self.storage_repository = config.get('irs', 'repository')
     self.tp = ThreadPool(tpSize, waitTimeout, maxTasks)
     self._tasks = {}
     self._unqueuedTasks = []
コード例 #40
0
ファイル: fill.py プロジェクト: miso-/SkeinforgeEngine
 def __init__(self, slicedModel):
     self.slicedModel = slicedModel
     self.extrusionWidth = config.getfloat('carve', 'extrusion.width')
     self.fillStrategyName = config.get(name, 'strategy')
     self.fillStrategyPath = config.get(name, 'strategy.path')
コード例 #41
0
ファイル: common.py プロジェクト: rusbomber/nufw
        args = args + more_args
    return Client(username, password, CLIENT_IP, more_args=args)


def connectClient(client):
    client.info("connectClient()")
    try:
        client.start(timeout=connectClient.timeout)
    except RuntimeError, err:
        client.warning("connectClient(): error: %s" % err)
        return False
    client.warning("connectClient(): connected")
    return True


connectClient.timeout = config.getfloat('nutcpc', 'connect_timeout')


def getNuauthConf():
    return NuauthConf()


def retry(timeout=1.0, step=0.250):
    start = time()
    while True:
        when = time() - start
        yield when
        if timeout < when:
            raise RuntimeError("Timeout (%.1f sec)!" % timeout)
            return
        if step:
コード例 #42
0
ファイル: test_mysql.py プロジェクト: rusbomber/nufw
    tm = timestamp.timetuple()
    return int(mktime(tm))


POSTGRESQL = False

config = NuauthConf()
if POSTGRESQL:
    import pgdb
    DB_PACKET_TABLE = config["pgsql_table_name"]
    DB_USER_TABLE = config["pgsql_users_table_name"]
    DB_SERVER = config["pgsql_server_addr"]
    DB_USER = config["pgsql_user"]
    DB_PASSWORD = config["pgsql_passwd"]
    DB_DBNAME = config["pgsql_db_name"]
    QUERY_TIMEOUT = test_config.getfloat('test_pgsql', 'query_timeout')
else:
    import MySQLdb
    DB_PACKET_TABLE = config["mysql_table_name"]
    DB_USER_TABLE = config["mysql_users_table_name"]
    DB_SERVER = config["mysql_server_addr"]
    DB_USER = config["mysql_user"]
    DB_PASSWORD = config["mysql_passwd"]
    DB_DBNAME = config["mysql_db_name"]
    QUERY_TIMEOUT = test_config.getfloat('test_mysql', 'query_timeout')

OS_SYSNAME = platform.system()  # 'Linux'
OS_RELEASE = platform.release()  # '2.6.19.2-haypo'
OS_VERSION = platform.version()  # '#2 Mon Feb 5 10:55:30 CET 2007'
CLIENT_OS = "-".join((OS_SYSNAME, OS_VERSION, OS_RELEASE))
CLIENT_APP = realpath(executable)
コード例 #43
0
    def __init__(self):
        self.startTime = time.time()
        self.endTime = None
        self.inputFilename = None
        self.outputFilename = None

        self.profileMemory = config.getboolean('general', 'profile.memory')

        self.decimalPlaces = config.getint('general', 'decimal.places')
        self.layerThickness = config.getfloat('carve', 'layer.height')
        self.perimeterWidth = config.getfloat('carve', 'extrusion.width')
        self.profileName = None
        self.bridgeWidthMultiplier = None
        self.nozzleDiameter = None
        self.threadSequence = None
        self.infillWidth = None
        self.operatingFeedRatePerSecond = None
        self.perimeterFeedRatePerSecond = None
        self.operatingFlowRate = None
        self.verboseGcode = config.getboolean('general', 'verbose.gcode')

        self.overlapRemovalWidthOverPerimeterWidth = config.getfloat(
            'inset', 'overlap.removal.scaler')
        self.nozzleDiameter = config.getfloat('inset', 'nozzle.diameter')
        self.bridgeWidthMultiplier = config.getfloat(
            'inset', 'bridge.width.multiplier.ratio')
        self.loopOrderAscendingArea = config.getboolean(
            'inset', 'loop.order.preferloops')

        self.layerHeight = config.getfloat('carve', 'layer.height')
        self.extrusionWidth = config.getfloat('carve', 'extrusion.width')
        self.infillBridgeDirection = config.getboolean(
            'carve', 'infill.bridge.direction')
        self.importCoarsenessRatio = config.getfloat(
            'carve', 'import.coarseness.ratio')
        self.correctMesh = config.getboolean('carve', 'mesh.correct')
        self.decimalPlaces = config.getint('general', 'decimal.places')
        self.layerPrintFrom = config.getint('carve', 'layer.print.from')
        self.layerPrintTo = config.getint('carve', 'layer.print.to')

        self.speedActive = config.getboolean('speed', 'active')
        self.addFlowRate = config.getboolean('speed', 'add.flow.rate')
        self.addAccelerationRate = config.getboolean('speed',
                                                     'add.acceleration.rate')
        self.feedRate = config.getfloat('speed', 'feed.rate')
        self.flowRateRatio = config.getfloat('speed', 'flow.rate.ratio')
        self.accelerationRate = config.getfloat('speed', 'acceleration.rate')
        self.orbitalFeedRateRatio = config.getfloat(
            'speed', 'feed.rate.orbiting.ratio')
        self.perimeterFeedRate = config.getfloat('speed',
                                                 'feed.rate.perimeter')
        self.perimeterFlowRateRatio = config.getfloat(
            'speed', 'flow.rate.perimeter.ratio')
        self.bridgeFeedRateRatio = config.getfloat('speed',
                                                   'feed.rate.bridge.ratio')
        self.bridgeFlowRateRatio = config.getfloat('speed',
                                                   'flow.rate.bridge.ratio')
        self.travelFeedRate = config.getfloat('speed', 'feed.rate.travel')
        self.supportFeedRate = config.getfloat('speed', 'feed.rate.support')

        self.dimensionActive = config.getboolean('dimension', 'active')
        self.extrusionUnitsRelative = config.getboolean(
            'dimension', 'extrusion.units.relative')
        self.dimensionDecimalPlaces = config.getint('dimension',
                                                    'decimal.places')

        self.extrusionPrintOrder = config.get(
            'fill', 'extrusion.sequence.print.order').split(',')

        self.bridgeFeedRateMinute = self.bridgeFeedRateRatio * self.perimeterFeedRate * 60  # todo former reference to main feed now perimeter feed
        self.perimeterFeedRateMinute = self.perimeterFeedRate * 60
        self.extrusionFeedRateMinute = self.feedRate * 60.0
        self.travelFeedRateMinute = self.travelFeedRate * 60

        self.supportFeedRateMinute = self.supportFeedRate * 60

        self.minimumLayerFeedRate = config.getfloat('cool',
                                                    'minimum.layer.feed.rate')
        self.minimumLayerFeedRateMinute = self.minimumLayerFeedRate * 60

        self.minimumBridgeFeedRateMultiplier = self.minimumLayerFeedRateMinute / self.bridgeFeedRateMinute
        self.minimumPerimeterFeedRateMultiplier = self.minimumLayerFeedRateMinute / self.perimeterFeedRateMinute
        self.minimumExtrusionFeedRateMultiplier = self.minimumLayerFeedRateMinute / self.extrusionFeedRateMinute
        self.minimumTravelFeedRateMultiplier = self.minimumLayerFeedRateMinute / self.travelFeedRateMinute

        nozzleXsection = (self.nozzleDiameter / 2)**2 * pi
        extrusionXsection = (
            (abs(self.perimeterWidth) + self.layerThickness) / 4)**2 * pi

        self.flowRate = self.flowRateRatio * self.feedRate
        self.bridgeFlowRate = (
            self.bridgeFlowRateRatio * self.bridgeFeedRateRatio) * (
                self.perimeterFlowRateRatio *
                self.perimeterFeedRate) * (nozzleXsection / extrusionXsection)
        self.perimeterFlowRate = self.perimeterFlowRateRatio * self.perimeterFeedRate

        self.orbitalFeedRateSecond = (self.feedRate *
                                      self.orbitalFeedRateRatio)
        self.orbitalFeedRateMinute = self.orbitalFeedRateSecond * 60

        self.combActive = config.getboolean('comb', 'active')
コード例 #44
0
 def completed(self):
     self.log("completed")
     if self.isInvite:
         self.reset_timeout(config.getfloat(consts.SECTION, consts.TIMERD))
     else:
         self.reset_timeout(config.getfloat(consts.SECTION, consts.TIMERK))
コード例 #45
0
ファイル: filter.py プロジェクト: regit/nufw
from common import connectClient
from mysocket import connectTcp, connectTcpFail
from config import config
from socket import gethostbyname

TIMEOUT = config.getfloat("filter", "timeout")
VALID_PORT = config.getint("filter", "valid_port")
INVALID_PORT = config.getint("filter", "invalid_port")
HOST = gethostbyname(config.get("filter", "host"))
IFACE = config.get("filter", "iface")

def testPortFailure(testcase, iptables, client, port, err):
    # Enable iptables filtering
    iptables.filterTcp(VALID_PORT)

    # Connect user
    if client:
        testcase.assert_(connectClient(client))

    # Create socket
    testcase.assertEqual(connectTcpFail(HOST, port, TIMEOUT), err)

def testPort(testcase, iptables, client, port, ok, host=HOST):
    # Enable iptables filtering
    iptables.filterTcp(VALID_PORT)

    # Connect user
    if client:
        testcase.assert_(connectClient(client))

    # Create socket
コード例 #46
0
ファイル: extract.py プロジェクト: mateuszsygula/hikstract
def extract(vrec):
    start_dt = vrec.start_dt
    start_dt_str = start_dt.strftime('%Y-%m-%d_%H:%M:%S')
    out_dir = os.path.join(config['main']['output_dir'],
                           '{:04d}'.format(start_dt.year),
                           '{:02d}'.format(start_dt.month),
                           '{:02d}'.format(start_dt.day))
    try:
        os.makedirs(out_dir, mode=0o750)
    except FileExistsError:
        pass

    in_fpath = os.path.join(os.path.dirname(vrec._h_idx_file.name),
                            'hiv{:05d}.mp4'.format(vrec.section.idx))
    converter = config['main']['converter']
    out_fmt = config['main']['output_format'] if converter else 'mp4'
    out_fname = 'rec_{}.{}'.format(start_dt_str, out_fmt)
    out_fpath = os.path.join(out_dir, out_fname)
    out_fpath_skip = out_fpath + '.skip'

    # We want FileExistsError propagated.
    # open(fpath, 'x') leaves a 0-length file which should be deleted before
    # we start extraction.
    for fpath in (out_fpath, out_fpath_skip):
        open(fpath, 'x')
        os.remove(fpath)

    # Create a temp file with just the portion of the stream we need
    with NamedTemporaryFile() as temp:
        with open(in_fpath, 'rb') as inpt:
            inpt.seek(vrec.start_offset)
            left = vrec.length
            while left > 0:
                buf = inpt.read(max(16 * 1024, left))
                left -= len(buf)
                temp.write(buf)

        temp.flush()
        temp_fpath = temp.name

        if config.getboolean('main', 'analyze_motion'):
            from motion import has_motion
            if not has_motion(temp_fpath):
                logger.info('No motion detected in {}, skipping'
                            .format(temp_fpath))
                open(out_fpath_skip, 'x')
                return

        logger.info('Extracting video record from ' + start_dt_str)
        logger.debug('Reading from {}, start {}, end {}'
                     .format(in_fpath,
                             log_int(vrec.start_offset),
                             log_int(vrec.start_offset + vrec.length)))

        if converter:
            xcoder_args = config['advanced']['converter_args'].split()
            transcode(temp_fpath, out_fpath,
                      converter=converter,
                      additional_flags=xcoder_args)
        else:
            logger.debug('Saving original stream to {}'.format(out_fpath))
            copyfile(temp_fpath, out_fpath)

    # Create a snapshot
    snap_fmt = config['main']['snapshot_format']
    if snap_fmt:
        fname_snap = 'snap_{}.{}'.format(start_dt_str, snap_fmt)
        out_fpath_snap = os.path.join(out_dir, fname_snap)
        ss = vrec.duration * config.getfloat('advanced', 'snapshot_pos')

        logger.info('Extracting snapshot from {}'.format(out_fpath))

        xcoder_args = config['advanced']['converter_args_snap'].split()
        xcoder_args += ['-ss', str(ss)]
        transcode(out_fpath, out_fpath_snap,
                  converter=converter,
                  additional_flags=xcoder_args)
コード例 #47
0
ファイル: nuauth.py プロジェクト: rusbomber/nufw
import atexit
from inl_tests.process import Process
from signal import SIGHUP
from mysocket import connectTcp
from config import config, NUAUTH_PROG, NUAUTH_START_TIMEOUT, USE_VALGRIND
from time import time

RELOAD_TIMEOUT = config.getfloat("nuauth", "reload_timeout")
INIT_TIMEOUT = 0.100  # 100 ms


class NuauthProcess(Process):
    __instance = None

    @classmethod
    def hasInstance(cls):
        return not (cls.__instance is None)

    @classmethod
    def getInstance(cls):
        if cls.__instance is None:
            cls.__instance = NuauthProcess()
            atexit.register(cls._reallyStop)
        return cls.__instance

    def __init__(self, debug_level=9):
        arg = ["-" + "v" * min(max(debug_level, 1), 9)]
        program = NUAUTH_PROG
        if USE_VALGRIND:
            #arg = ["--tool=callgrind", program] + arg
            #program = "valgrind"
コード例 #48
0
import numpy as np
import random
import logging
import pickle
import sys
import tensorflow as tf
import os
import pickle

os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2'
"""Implementation of double-oracle algorithms."""

##################### CONFIGURATION ######################
MAX_EPISODES = config.getint('parameter', 'max_episodes')
MAX_STEPS = config.getint('parameter', 'max_ep_steps')
GAMMA = config.getfloat('parameter', 'gamma')
MAX_ITERATION = config.getint('double-oracle', 'max_iteration')
N_TRIAL = config.getint('double-oracle', 'n_trial')
##########################################################


def find_mixed_NE(payoff):
    """
    Function for returning mixed strategies of the first step of double oracle iterations.
    :param payoff: Two dimensinal array. Payoff matrix of the players. The row is defender and column is attcker. 
    :return: List, mixed strategy of the attacker and defender at NE by solving maxmini problem. 
    """
    # This implementation is based on page 88 of the book multiagent systems (Shoham etc.)
    n_action = payoff.shape[0]
    c = np.zeros(n_action)
    c = np.append(c, 1)
コード例 #49
0
ファイル: test_mysql.py プロジェクト: regit/nufw
def datetime2unix(timestamp):
    tm = timestamp.timetuple()
    return int(mktime(tm))

POSTGRESQL = False

config = NuauthConf()
if POSTGRESQL:
    import pgdb
    DB_PACKET_TABLE = config["pgsql_table_name"]
    DB_USER_TABLE = config["pgsql_users_table_name"]
    DB_SERVER = config["pgsql_server_addr"]
    DB_USER = config["pgsql_user"]
    DB_PASSWORD = config["pgsql_passwd"]
    DB_DBNAME = config["pgsql_db_name"]
    QUERY_TIMEOUT = test_config.getfloat('test_pgsql', 'query_timeout')
else:
    import MySQLdb
    DB_PACKET_TABLE = config["mysql_table_name"]
    DB_USER_TABLE = config["mysql_users_table_name"]
    DB_SERVER = config["mysql_server_addr"]
    DB_USER = config["mysql_user"]
    DB_PASSWORD = config["mysql_passwd"]
    DB_DBNAME = config["mysql_db_name"]
    QUERY_TIMEOUT = test_config.getfloat('test_mysql', 'query_timeout')

OS_SYSNAME = platform.system()    # 'Linux'
OS_RELEASE = platform.release()   # '2.6.19.2-haypo'
OS_VERSION = platform.version()   # '#2 Mon Feb 5 10:55:30 CET 2007'
CLIENT_OS = "-".join( (OS_SYSNAME, OS_VERSION, OS_RELEASE) )
CLIENT_APP = realpath(executable)
コード例 #50
0
ファイル: common.py プロジェクト: regit/nufw
    if not (more_args and "-K" in more_args):
        args = args + ["-K",key]
    if more_args:
        args = args + more_args
    return Client(username, password, CLIENT_IP, more_args=args)

def connectClient(client):
    client.info("connectClient()")
    try:
        client.start(timeout=connectClient.timeout)
    except RuntimeError, err:
        client.warning("connectClient(): error: %s" % err)
        return False
    client.warning("connectClient(): connected")
    return True
connectClient.timeout = config.getfloat('nutcpc', 'connect_timeout')

def getNuauthConf():
    return NuauthConf()

def retry(timeout=1.0, step=0.250):
    start = time()
    while True:
        when = time() - start
        yield when
        if timeout < when:
            raise RuntimeError("Timeout (%.1f sec)!" % timeout)
            return
        if step:
            warning("(retry) sleep(%.3f)" % step)
            sleep(step)
コード例 #51
0
    def __init__(self, runtimeParameters):

        self.minimumLayerTime = config.getfloat('cool','minimum.layer.time')