From 41adeb30382bc0d0493dcc6fe2d576f70d2c88e1 Mon Sep 17 00:00:00 2001 From: gac-x04sa Date: Thu, 25 Jan 2018 09:27:41 +0100 Subject: [PATCH] Startup --- plugins/Omega.form | 15 +++++++-------- plugins/Omega.java | 12 ++++++------ script/devices/SimulatedDiode.py | 28 ++++++++++++++++++++++++++++ script/local.py | 8 ++++++++ 4 files changed, 49 insertions(+), 14 deletions(-) create mode 100644 script/devices/SimulatedDiode.py diff --git a/plugins/Omega.form b/plugins/Omega.form index 3c59ab0..77c33e9 100644 --- a/plugins/Omega.form +++ b/plugins/Omega.form @@ -30,20 +30,14 @@ - + - - - - - - - + @@ -51,6 +45,11 @@ + + + + + diff --git a/plugins/Omega.java b/plugins/Omega.java index 68278a6..985da01 100644 --- a/plugins/Omega.java +++ b/plugins/Omega.java @@ -192,21 +192,21 @@ public class Omega extends Panel { .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(77, 77, 77) .addComponent(panelImageCounter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addContainerGap(26, Short.MAX_VALUE)) + .addContainerGap(153, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(layout.createSequentialGroup() - .addContainerGap() - .addComponent(panelImageCounter, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 74, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(buttonStart) .addComponent(buttonAbort)) .addContainerGap(63, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(panelImageCounter, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// //GEN-END:initComponents diff --git a/script/devices/SimulatedDiode.py b/script/devices/SimulatedDiode.py new file mode 100644 index 0000000..ff781a3 --- /dev/null +++ b/script/devices/SimulatedDiode.py @@ -0,0 +1,28 @@ +import random + + +class SimulatedDiode(ReadonlyRegisterBase): + + def __init__(self, name): + ReadonlyRegisterBase.__init__(self, name) + self.x=0.0 + self.y=0.0 + self.radius=0.125 + self.amplitude = 600.0 + self.offset=200.0 + self.border = 0.025 + + def doRead(self): + x,y = scx.position, scy.position + noise = random.random() * self.amplitude/100.0 + d = math.hypot(x-self.x, y-self.y) + #print d + if d>self.radius: + return self.offset + noise + elif d< (self.radius - self.border ): + return self.offset + noise + self.amplitude + else : + return self.offset + noise + self.amplitude *(self.radius - d)/self.border + + def set_center(self, x, y): + self.x, self.y = x, y \ No newline at end of file diff --git a/script/local.py b/script/local.py index f564001..4b04a06 100644 --- a/script/local.py +++ b/script/local.py @@ -2,3 +2,11 @@ # Deployment specific global definitions - executed after startup.py ################################################################################################### + + +#Devices +run("devices/SimulatedDiode") +simulatedDiode = SimulatedDiode("scd_sim") +add_device(simulatedDiode, True) +simulatedDiode.polling=500 + \ No newline at end of file