Skip to content

Commit 188fdcb

Browse files
author
Jan Červený
authored
Merge pull request #11 from GCRI-DoAB/devel
Devel
2 parents 3a72039 + 09539db commit 188fdcb

4 files changed

Lines changed: 239 additions & 174 deletions

File tree

LL-Luminostat.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// static parameters
2+
var odLinMin = 0.5
3+
var odLinMax = 1.23
4+
var lightMin = 400
5+
var expRegMult = 281.9177
6+
var expRegExpo = 1.016269
7+
8+
/**
9+
* Luminostat regulator
10+
*
11+
* @script Lights - Luminostat
12+
* @author CzechGlobe - Department of Adaptive Biotechnologies (JaCe)
13+
* @version 0.1.1
14+
* @modified 11.7.2018 (JaCe)
15+
*
16+
* @notes For proper function of the script a pump has to be set to ID 4
17+
*
18+
* @param {number} odLinMin Min OD for linear regulated range
19+
* @param {number} odLinMax Max OD for linear regulated range
20+
* @param {number} lightMin Min light for linear regulated range
21+
* @param {number} expRegMult Exponential regression multiplier
22+
* @param {number} expRegExpo Exponential regression exponent
23+
*
24+
* @return Light intensity
25+
*
26+
*/
27+
28+
// dynamic parameters
29+
var lightMax = lightMin * (1 + (odLinMax - odLinMin) / odLinMin)
30+
31+
importPackage(java.util)
32+
importPackage(java.lang)
33+
importPackage(Packages.psi.bioreactor.core.protocol)
34+
35+
function round(number, decimals) {
36+
// Rounding specific decimal point number
37+
return +(Math.round(number + 'e+' + decimals) + 'e-' + decimals)
38+
}
39+
40+
function controlLight(odValue) {
41+
// Check for OD noise/overshots and do primitive OD averaging
42+
if (theAccessory.context().getInt('odNoise', 1)) {
43+
theAccessory.context().put('odNoise', 0)
44+
theAccessory.context().put('odLast', odValue)
45+
return null
46+
}
47+
if (Math.abs(1 - odValue / odLast) < 0.04) {
48+
odValue = (odValue + odLast) / 2
49+
theAccessory.context().put('odLast', odValue)
50+
if (odValue > odLinMax) {
51+
result = Math.min(expRegMult * Math.exp(expRegExpo * odValue), theAccessory.getMax());
52+
} else if (odValue > odLinMin) {
53+
result = Math.min(lightMin + (lightMax - lightMin) * (odValue - odLinMin) / (odLinMax - odLinMin), theAccessory.getMax());
54+
} else {
55+
result = theAccessory.getValue();
56+
}
57+
} else {
58+
theAccessory.context().put('odNoise', 1)
59+
theAccessory.context().put('odLast', odValue)
60+
return null
61+
}
62+
}
63+
64+
// dynamic parameters
65+
var odSensor = theGroup.getAccessory("od-sensors.od-680") // query OD accessory by key
66+
var odValue = odSensor.getValue()
67+
var odLast = theAccessory.context().getDouble('odLast', 0.0)
68+
69+
if (!isNaN(odValue) && (round(odValue, 3) !== round(odLast, 3))) {
70+
controlLight(odValue)
71+
}

O2-PIcurveMeasurement.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ var UserDefinedProtocol = {
88
photosynthesisMeasurementPeriod: 3600,
99
turbidostatSynchronization: false,
1010
growthStabilitySynchronization: false,
11-
stirrerIntensityValues: [30, 60],
11+
stirrerIntensityValues: [50, 75],
1212
lightStepMultiplierValues: [ 1 ],
1313
lightStepMultiplierColors: ['red'],
1414
photosynthesisCurveLightMultiplierValues: [ 1 ]
1515
}
1616

1717
/* globals
18-
importPackage, java, Packages, theGroup, theAccessory, theExperiment, theLogger, ProtoConfig, ETrendFunction, result:true
18+
importPackage, java, Packages, theGroup, theAccessory, theExperiment, theLogger, ProtoConfig, ETrendFunction, result: true
1919
*/
2020

2121
/**
2222
* PI-Curves Measurement
2323
*
2424
* @script PI-Curves Measurement - Photosynthesis Efficiency Quantification
2525
* @author CzechGlobe - Department of Adaptive Biotechnologies (JaCe)
26-
* @version 1.2.1
27-
* @modified 21.4.2018 (JaCe)
26+
* @version 1.2.2
27+
* @modified 26.10.2018 (JaCe)
2828
* @notes For proper function of the script following protocols have to be disabled: "Lights", "Bubble intr. valve" and "Stirrer"
2929
*
3030
* @param {number} oxygenMeasurementDuration [s] Duration of O2 evolution measurement
@@ -127,32 +127,32 @@ if (experimentDuration >= measurementTime) {
127127
}
128128
if ((experimentDuration > (resumeTime - UserDefinedProtocol.respirationMeasurementDuration)) && !photosynthesis) {
129129
theAccessory.context().put('photosynthesis', 1)
130+
if (UserDefinedProtocol.respirationMeasurementDuration > 0) {
131+
light0.suspend(resumeTime)
132+
light1.suspend(resumeTime)
133+
}
130134
regCoefLin = theAccessory.getDataHistory().regression(ETrendFunction.LIN, Math.ceil(UserDefinedProtocol.photosynthesisRateCurveEvalFraction * UserDefinedProtocol.oxygenMeasurementDuration / UserDefinedProtocol.oxygenRapidMeasurementInterval))
131135
debugLogger('O2 evol. parameters: ' + regCoefLin.join(', '))
132136
rateO2Evol = theAccessory.context().get('rateO2Evol', [])
133137
rateO2EvolR2 = theAccessory.context().get('rateO2EvolR2', [])
134138
rateO2Evol[changeCounter] = round(regCoefLin[1] * 600, 2)
135139
rateO2EvolR2[changeCounter] = round(regCoefLin[2], 3)
136-
if (UserDefinedProtocol.respirationMeasurementDuration > 0) {
137-
light0.suspend(resumeTime)
138-
light1.suspend(resumeTime)
139-
// TODO should be function1
140-
}
140+
// TODO should be function1
141141
}
142142
if ((experimentDuration > resumeTime) && !respiration) {
143143
theAccessory.context().put('respiration', 1)
144144
bubbles.setRunningProtoConfig(ProtoConfig.ON)
145145
stirrer.setRunningProtoConfig(new ProtoConfig(UserDefinedProtocol.stirrerIntensityValues[0]))
146146
if (UserDefinedProtocol.respirationMeasurementDuration > 0) {
147+
light0.resume(experimentDuration)
148+
light1.resume(experimentDuration)
149+
controlLights(theAccessory.context().getDouble('light0Value', light0.getValue()), theAccessory.context().getDouble('light1Value', light1.getValue()))
147150
regCoefLin = theAccessory.getDataHistory().regression(ETrendFunction.LIN, Math.ceil(UserDefinedProtocol.photosynthesisRateCurveEvalFraction * UserDefinedProtocol.respirationMeasurementDuration / UserDefinedProtocol.oxygenRapidMeasurementInterval))
148151
debugLogger('O2 resp. parameters: ' + regCoefLin.join(', '))
149152
rateO2Resp = theAccessory.context().get('rateO2Resp', [])
150153
rateO2RespR2 = theAccessory.context().get('rateO2RespR2', [])
151154
rateO2Resp[changeCounter] = round(regCoefLin[1] * 600, 2)
152155
rateO2RespR2[changeCounter] = round(regCoefLin[2], 3)
153-
controlLights(theAccessory.context().getDouble('light0Value', light0.getValue()), theAccessory.context().getDouble('light1Value', light1.getValue()))
154-
light0.resume(experimentDuration)
155-
light1.resume(experimentDuration)
156156
// TODO should be function1
157157
}
158158
}
@@ -162,29 +162,29 @@ if (experimentDuration >= measurementTime) {
162162
theAccessory.context().put('respiration', 0)
163163
theAccessory.context().put('changeCounter', ++changeCounter)
164164
if (changeCounter >= UserDefinedProtocol.lightStepMultiplierValues.length) {
165+
theAccessory.context().put('changeCounter', 0)
166+
theAccessory.context().put('measurementTime', experimentDuration + UserDefinedProtocol.photosynthesisMeasurementPeriod - UserDefinedProtocol.lightStepMultiplierValues.length * (UserDefinedProtocol.oxygenMeasurementDuration + UserDefinedProtocol.respirationMeasurementDuration + UserDefinedProtocol.relaxationPhaseDuration))
167+
bubbles.setRunningProtoConfig(ProtoConfig.ON)
168+
stirrer.setRunningProtoConfig(new ProtoConfig(UserDefinedProtocol.stirrerIntensityValues[0]))
169+
theAccessory.context().put('modeO2EvolResp', 0)
170+
multiplierStep = multiplierStep < (UserDefinedProtocol.photosynthesisCurveLightMultiplierValues.length - 1) ? ++multiplierStep : 0
171+
theAccessory.context().put('multiplierStep', multiplierStep)
165172
rateO2Evol = theAccessory.context().get('rateO2Evol', [])
166173
rateO2EvolR2 = theAccessory.context().get('rateO2EvolR2', [])
167174
rateO2Resp = theAccessory.context().get('rateO2Resp', [])
168175
rateO2RespR2 = theAccessory.context().get('rateO2RespR2', [])
169-
theAccessory.context().put('changeCounter', 0)
170-
theAccessory.context().put('measurementTime', experimentDuration + UserDefinedProtocol.photosynthesisMeasurementPeriod - UserDefinedProtocol.lightStepMultiplierValues.length * (UserDefinedProtocol.oxygenMeasurementDuration + UserDefinedProtocol.respirationMeasurementDuration + UserDefinedProtocol.relaxationPhaseDuration))
171-
theExperiment.addEvent('PI-curve DONE. O2 rates are ' + rateO2Evol.join(', ') + ' and ' + rateO2Resp.join(', ') + ' units/min (R2 ' + rateO2EvolR2.join(', ') + ' and ' + rateO2RespR2.join(', ') + ')')
172176
theAccessory.context().put('rateO2Evol', [])
173177
theAccessory.context().put('rateO2EvolR2', [])
174178
theAccessory.context().put('rateO2Resp', [])
175179
theAccessory.context().put('rateO2RespR2', [])
176-
bubbles.setRunningProtoConfig(ProtoConfig.ON)
177-
stirrer.setRunningProtoConfig(new ProtoConfig(UserDefinedProtocol.stirrerIntensityValues[0]))
178-
theAccessory.context().put('modeO2EvolResp', 0)
179-
multiplierStep = multiplierStep < (UserDefinedProtocol.photosynthesisCurveLightMultiplierValues.length - 1) ? ++multiplierStep : 0
180-
theAccessory.context().put('multiplierStep', multiplierStep)
180+
theExperiment.addEvent('PI-curve DONE. O2 rates are ' + rateO2Evol.join(', ') + ' and ' + rateO2Resp.join(', ') + ' units/min (R2 ' + rateO2EvolR2.join(', ') + ' and ' + rateO2RespR2.join(', ') + ')')
181181
debugLogger('PI-curve finished.')
182182
}
183183
}
184184
result = UserDefinedProtocol.oxygenRapidMeasurementInterval
185185
}
186186
} else if (experimentDuration > theAccessory.context().getInt('checkupTime', 0)) {
187-
// Here comes a hack that solves an issue with strange periodic behaviour of both bubble interrupting valve and stirrer, when they turn off in uncontrolled manner - most likely bug in the software
187+
// Here comes a hack that solves an issue with strange periodic behaviour of both the bubble interrupting valve and the stirrer, when they turn off in uncontrolled manner - most likely bug in the software
188188
stirrer = theGroup.getAccessory('pwm.stirrer')
189189
bubbles = theGroup.getAccessory('switches.valve-0')
190190
theAccessory.context().put('checkupTime', experimentDuration + 10)

0 commit comments

Comments
 (0)