Esempio n. 1
0
def onInit():
    global running
    running = Collections.synchronizedMap(LinkedHashMap())
    running.put("Rule1", AtomicBoolean(False))
    running.put("Rule2", AtomicBoolean(False))
    running.put("Rule3", AtomicBoolean(False))
    running.put("Rule4", AtomicBoolean(False))
    sponge.setVariable("testStatus", None)
def onInit():
    # Variables for assertions only
    sponge.setVariable("onInitCalled", AtomicBoolean(False))
    sponge.setVariable("onBeforeLoadCalled", AtomicInteger(0))
    sponge.setVariable("onLoadCalled", AtomicInteger(0))
    sponge.setVariable("onAfterLoadCalled", AtomicInteger(0))
    sponge.setVariable("onStartupCalled", AtomicBoolean(False))
    sponge.setVariable("onBeforeReloadCalled", AtomicBoolean(False))
    sponge.setVariable("onAfterReloadCalled", AtomicBoolean(False))

    sponge.logger.debug("onInit")
    sponge.getVariable("onInitCalled").set(True)
Esempio n. 3
0
def onInit():
    # Variables for assertions only.
    sponge.setVariable("actionCalled", AtomicBoolean(False))
    sponge.setVariable("eventSent", AtomicBoolean(False))
    sponge.setVariable("reloaded", AtomicBoolean(False))

    # Variables that simulate a data model.
    sponge.setVariable("actuator1", "A")
    sponge.setVariable("actuator2", False)
    sponge.setVariable("actuator3", 1)
    sponge.setVariable("actuator4", 1)
    sponge.setVariable("actuator5", "X")

    sponge.addCategories(CategoryMeta("category1").withLabel("Category 1").withDescription("Category 1 description"),
                         CategoryMeta("category2").withLabel("Category 2").withDescription("Category 2 description"))
 def __init__(self, period=60, chunks=100, throughput=0):
     self.period = period  # The time period over which to produce throughput
     self.chunks = chunks
     self.throughput = AtomicInteger(throughput)
     self.throughput_success = AtomicInteger(0)
     self.resume = AtomicBoolean(True)
     self.curr_tick = AtomicInteger(0)
Esempio n. 5
0
class LatestNewsCorrelator(Correlator):
    instanceStarted = AtomicBoolean(False)

    def onConfigure(self):
        self.withEvent("news")

    def onAcceptAsFirst(self, event):
        return LatestNewsCorrelator.instanceStarted.compareAndSet(False, True)

    def onInit(self):
        storagePlugin.storedValue = collections.deque(
            maxlen=int(sponge.getVariable("latestNewsMaxSize", 2)))

    def onEvent(self, event):
        storagePlugin.storedValue.append(event.get("title"))
        self.logger.debug("{} - latest news: {}", self.hashCode(),
                          str(storagePlugin.storedValue))
Esempio n. 6
0
 def __init__(self):
     self._mixer = None
     Sound._mixer = self
     Channel._mixer = self
     self.Sound = Sound
     self.Channel = self._get_channel
     self.music = None
     self._channel_max = 8
     self._channels = {}
     self._channel_available = ConcurrentLinkedDeque()
     self._channel_available.addAll(list(range(self._channel_max)))
     self._channel_active = ConcurrentLinkedDeque()
     self._channel_reserved = ConcurrentLinkedDeque()
     self._channel_reserved_num = 0
     self._thread = None
     self.run = self._process
     self._active = AtomicBoolean(False)
     self._initialized = False
Esempio n. 7
0
class SampleCorrelator(Correlator):
    instanceStarted = AtomicBoolean(False)

    def onConfigure(self):
        self.withEvents(["filesystemFailure",
                         "diskFailure"]).withDuration(Duration.ofSeconds(2))

    def onAcceptAsFirst(self, event):
        return SampleCorrelator.instanceStarted.compareAndSet(False, True)

    def onInit(self):
        self.eventLog = []

    def onEvent(self, event):
        self.eventLog.append(event)
        sponge.getVariable("hardwareFailureScriptCount").incrementAndGet()

    def onDuration(self):
        self.logger.debug("{} - log: {}", self.hashCode(), str(self.eventLog))
Esempio n. 8
0
 def __init__(self, id):
     self._id = id
     self._sound = None
     self._stream = None
     self._len = self._mixer._bufferSize
     self._data = jarray.zeros(self._len, 'b')
     self._data_len = 0
     self._data_sum = 0
     self._data_rate = self._mixer._byteRate / 1000
     self._active = AtomicBoolean(False)
     self._pause = False
     self._loops = 0
     self._volume = 1.0
     self._lvolume = 1.0
     self._rvolume = 1.0
     self._queue = None
     self._endevent = None
     self._maxtime = 0
     self._fadein = 0
     self._fadeout = 0
     self._dvol = 1.0
     self._process = False
     self._mixer._register_channel(self)
def onInit():
    # Variables for assertions only
    sponge.setVariable("calledCustomAction", None)
    sponge.setVariable("sentCamelMessage_spongeProducer", AtomicBoolean(False))
Esempio n. 10
0
def onInit():
    # Variables for assertions only
    sponge.setVariable("verifyTriggerEnabled", AtomicBoolean(False))
    sponge.setVariable("verifyTriggerDisabled", AtomicBoolean(False))
    sponge.setVariable("verificationDone", AtomicBoolean(False))
Esempio n. 11
0
 def __init__(self, size):
     JPanel.__init__(self)
     self.setPreferredSize(Dimension(size[0],size[1]))
     self.surface = pyj2d.surface.Surface(size, BufferedImage.TYPE_INT_RGB)
     self.setBackground(Color.BLACK)
     self._repainting = AtomicBoolean(False)
Esempio n. 12
0
def onInit():
    # Variables for assertions only
    sponge.setVariable("receivedEventA", AtomicBoolean(False))
    sponge.setVariable("receivedEventBCount", AtomicInteger(0))
Esempio n. 13
0
def onInit():
    global hearbeatEventEntry
    hearbeatEventEntry = None
    sponge.setVariable("soundTheAlarm", AtomicBoolean(False))
Esempio n. 14
0
File: time.py Progetto: jggatc/pyj2d
 def __init__(self):
     self._time_init = System.nanoTime() // 1000000
     self.Clock = Clock
     self.Clock._repaint_sync = AtomicBoolean(False)
     self._timers = {}
Esempio n. 15
0
def onInit():
    sponge.setVariable("alarmSounded", AtomicBoolean(False))
def onInit():
    # Variables for assertions only
    sponge.setVariable("sentCamelMessage_camelEvent", AtomicBoolean(False))
    sponge.setVariable("sentCamelMessage_spongeProducer", AtomicBoolean(False))
Esempio n. 17
0
def onInit():
    sponge.setVariable("soundTheAlarm", AtomicBoolean(False))
Esempio n. 18
0
# Load the CSV file if it exists, otherwise use an empty data structure
if os.path.exists(csv_image_notes):
    header_rows, entries = openCSV(csv_image_notes, header_length=1)
    header = header_rows[0]
else:
    header = ["name", "first opened", "last opened", "filepath", "notes"]
    entries = []

# The subset of entries that are shown in the table (or all)
table_entries = entries

# Map of file paths vs. index of entries
image_paths = {row[3]: i for i, row in enumerate(entries)}

# Flag to set to True to request the table model data be saved to the CSV file
requested_save_csv = AtomicBoolean(False)


# A function to save the table to disk in CSV format.
# Checks if the requested_save_csv flag was set, and if so, writes the CSV file.
def saveTable():
    def after():
        # UI elements to alter under the event dispatch thread
        note_status.setText("Saved.")
        edit_note.setEnabled(True)
        save_note.setEnabled(False)

    # Repeatedly attempt to write the CSV until there are no more updates,
    # in which case the scheduled thread (see below) will pause for a bit before retrying.
    while requested_save_csv.getAndSet(False):
        writeCSV(csv_image_notes, header, entries)
Esempio n. 19
0
def onInit():
    # Variables for assertions only
    sponge.setVariable("receivedCamelMessage", AtomicBoolean(False))
Esempio n. 20
0
def onInit():
    sponge.setVariable("onRun", AtomicBoolean(False))
    sponge.setVariable("trigger", AtomicBoolean(False))
Esempio n. 21
0
def onInit():
    # Variables for assertions only
    sponge.setVariable("ruleAFired", AtomicBoolean(False))
    sponge.setVariable("ruleBFired", AtomicBoolean(False))
    sponge.setVariable("ruleCFired", AtomicBoolean(False))
    sponge.setVariable("endTest", AtomicBoolean(False))
Esempio n. 22
0
def onInit():
    sponge.setVariable("alarmSounded", AtomicBoolean(False))
    sponge.setVariable("alarmForwarded", AtomicBoolean(False))
    sponge.setVariable("sourceRoutesStopped", AtomicBoolean(False))
def onInit():
    # Variables for assertions only
    sponge.setVariable("test1", AtomicBoolean(False))
    sponge.setVariable("test2", AtomicBoolean(False))
    sponge.setVariable("stopped", AtomicBoolean(False))