@@ -10,7 +10,6 @@ var UserDefinedProtocol = {
1010 // -optimizer stability check
1111 growthStatistics : true ,
1212 regressionODType : 680 ,
13- regressionCoDMin : 0.8 ,
1413 stabilizationTimeMin : 8 ,
1514 stabilizationTimeMax : 24 ,
1615 growthRateEvalFrac : 2 / 3 ,
@@ -143,14 +142,13 @@ function controlParameter (parameter, values) {
143142// Inicialization of the script
144143if ( ! theAccessory . context ( ) . getInt ( 'initialization' , 0 ) ) {
145144 theAccessory . context ( ) . clear ( )
146- theAccessory . context ( ) . put ( 'stabilizedTimeMax' , theExperiment . getDurationSec ( ) + UserDefinedProtocol . stabilizationTimeMax * 3600 )
147145 switch ( UserDefinedProtocol . controlledParameter ) {
148146 case 'lights' :
149147 if ( theGroup . getAccessory ( 'actinic-lights.light-Red' ) . getProtoConfigValue ( ) ) {
150148 theExperiment . addEvent ( '!!! Disable red light protocol' )
151149 }
152150 if ( theGroup . getAccessory ( 'actinic-lights.light-Blue' ) . getProtoConfigValue ( ) ) {
153- theExperiment . addEvent ( '!!! Disable blue light protocol' )
151+ theExperiment . addEvent ( '!!! Disable red light protocol' )
154152 }
155153 break
156154 case 'temperature' :
@@ -304,37 +302,16 @@ function controlPump () {
304302 UserDefinedProtocol . turbidostatODMin = ( UserDefinedProtocol . turbidostatODMax - UserDefinedProtocol . turbidostatODMin ) + ( UserDefinedProtocol . turbidostatODMax = UserDefinedProtocol . turbidostatODMin )
305303 debugLogger ( 'OD range reversed.' , 0 )
306304 }
307- var changeCounter
308- if ( theAccessory . context ( ) . getInt ( 'stabilizedTimeMax' , 0 ) <= Number ( theExperiment . getDurationSec ( ) ) ) {
309- theAccessory . context ( ) . put ( 'stabilizedTimeMax' , theExperiment . getDurationSec ( ) + UserDefinedProtocol . stabilizationTimeMax * 3600 )
310- changeCounter = theAccessory . context ( ) . getInt ( 'changeCounter' , 0 )
311- if ( UserDefinedProtocol . controlledParameterSteps . length > 1 ) {
312- if ( changeCounter < ( UserDefinedProtocol . controlledParameterSteps . length - 1 ) ) {
313- controlParameter ( UserDefinedProtocol . controlledParameter , UserDefinedProtocol . controlledParameterSteps [ ++ changeCounter ] )
314- theAccessory . context ( ) . put ( 'changeCounter' , changeCounter )
315- } else if ( changeCounter < 2 * ( UserDefinedProtocol . controlledParameterSteps . length - 1 ) ) {
316- controlParameter ( UserDefinedProtocol . controlledParameter , UserDefinedProtocol . controlledParameterSteps [ 2 * ( UserDefinedProtocol . controlledParameterSteps . length - 1 ) - ( ++ changeCounter ) ] )
317- theAccessory . context ( ) . put ( 'changeCounter' , changeCounter )
318- } else {
319- controlParameter ( UserDefinedProtocol . controlledParameter , UserDefinedProtocol . controlledParameterSteps [ 1 ] )
320- theAccessory . context ( ) . put ( 'changeCounter' , 1 )
321- }
322- theAccessory . context ( ) . remove ( 'stepCounter' )
323- theAccessory . context ( ) . remove ( 'expDuration' )
324- theAccessory . context ( ) . remove ( 'stepDoublingTime' )
325- theAccessory . context ( ) . remove ( 'stabilizedTime' )
326- theAccessory . context ( ) . remove ( 'stabilizedTimeMax' )
327- }
328- }
329305 // Start step growth rate evaluation
330- if ( ( ( odValue > ( UserDefinedProtocol . turbidostatODMax * odMaxModifier ) ) && ! pumpState ) ) {
306+ if ( ( odValue > ( UserDefinedProtocol . turbidostatODMax * odMaxModifier ) ) && ! pumpState ) {
331307 theAccessory . context ( ) . put ( 'modeDilution' , 1 )
332308 theAccessory . context ( ) . put ( 'modeStabilized' , 0 )
333309 var stepCounter = theAccessory . context ( ) . getInt ( 'stepCounter' , 0 )
334310 var expDuration = theAccessory . context ( ) . get ( 'expDuration' , 0.0 )
335311 var stepDuration = theAccessory . context ( ) . get ( 'stepDuration' , 0.0 )
336312 var stepDoublingTime = theAccessory . context ( ) . get ( 'stepDoublingTime' , 0.0 )
337313 var stabilizedTime = theAccessory . context ( ) . getInt ( 'stabilizedTime' , 0 )
314+ var stabilizedTimeMax = theAccessory . context ( ) . getInt ( 'stabilizedTimeMax' , 0 )
338315 if ( ! Array . isArray ( expDuration ) ) {
339316 stepCounter = 0
340317 expDuration = [ ] ; stepDuration = [ ] ; stepDoublingTime = [ ]
@@ -351,17 +328,14 @@ function controlPump () {
351328 var DHCapacity = ( Math . floor ( stepDuration [ stepCounter ] / UserDefinedProtocol . ODReadoutInterval ) - 3 ) > 0 ? ( Math . floor ( stepDuration [ stepCounter ] / UserDefinedProtocol . ODReadoutInterval ) - 3 ) : 60
352329 var regCoefExp = odSensorRegression . getDataHistory ( ) . regression ( ETrendFunction . EXP , Math . ceil ( DHCapacity - ( UserDefinedProtocol . growthRateEvalFrac ? DHCapacity * ( UserDefinedProtocol . growthRateEvalFrac / 100 ) : UserDefinedProtocol . growthRateEvalDelay / UserDefinedProtocol . ODReadoutInterval ) ) )
353330 debugLogger ( 'Growth parameters: ' + regCoefExp . join ( ', ' ) )
354- if ( Number ( regCoefExp [ 2 ] ) >= UserDefinedProtocol . regressionCoDMin ) {
355- stepDoublingTime [ stepCounter ] = ( 1 / ( Number ( regCoefExp [ 1 ] ) * 3600 * 10 ) ) * Math . LN2
356- theAccessory . context ( ) . put ( 'stepCounter' , ++ stepCounter )
357- }
358- theExperiment . addEvent ( 'Doubling time of the step was ' + round ( ( 1 / ( Number ( regCoefExp [ 1 ] ) * 3600 * 10 ) ) * Math . LN2 , 2 ) + ' h (CoD ' + round ( Number ( regCoefExp [ 2 ] ) * 100 , 1 ) + '%)' )
331+ stepDoublingTime [ stepCounter ] = ( 1 / ( Number ( regCoefExp [ 1 ] ) * 3600 * 10 ) ) * Math . LN2
332+ theExperiment . addEvent ( 'Doubling time of the step was ' + round ( stepDoublingTime [ stepCounter ] , 2 ) + ' h (CoD ' + round ( Number ( regCoefExp [ 2 ] ) * 100 , 1 ) + '%) and step no. is ' + ( ++ stepCounter ) )
333+ theAccessory . context ( ) . put ( 'stepCounter' , stepCounter )
359334 if ( stepCounter >= UserDefinedProtocol . analyzedSteps ) {
360335 var stepDoublingTimeAvg = 0
361336 var stepDoublingTimeSD = 0
362337 var stepDoublingTimeIC95 = 0
363338 var stepTrend = 0
364- var stepCoD = 0
365339 var sumXY = 0
366340 var sumX = 0
367341 var sumY = 0
@@ -390,9 +364,9 @@ function controlPump () {
390364 stepCoD = ( UserDefinedProtocol . analyzedSteps * sumXY - sumX * sumY ) / ( Math . sqrt ( ( UserDefinedProtocol . analyzedSteps * sumX2 - Math . pow ( sumX , 2 ) ) * ( UserDefinedProtocol . analyzedSteps * sumY2 - Math . pow ( sumY , 2 ) ) ) )
391365 theExperiment . addEvent ( 'Steps doubling time Avg: ' + round ( stepDoublingTimeAvg , 2 ) + ' h, IC95 ' + round ( stepDoublingTimeIC95 , 2 ) + ' h (' + round ( stepDoublingTimeIC95 / stepDoublingTimeAvg * 100 , 1 ) + '%) with ' + round ( stepTrend , 2 ) + ' h/h trend (' + round ( stepTrend / stepDoublingTimeAvg * 100 , 1 ) + '%)' )
392366 // Growth stability test and parameters control
393- if ( ( ( stepDoublingTimeIC95 / stepDoublingTimeAvg ) <= ( UserDefinedProtocol . intervalOfConfidenceMax / 100 ) && ( Math . abs ( stepTrend / stepDoublingTimeAvg ) <= ( UserDefinedProtocol . growthTrendMax / 100 ) ) && ( stabilizedTime <= Number ( theExperiment . getDurationSec ( ) ) ) ) ) {
367+ if ( ( ( stepDoublingTimeIC95 / stepDoublingTimeAvg ) <= ( UserDefinedProtocol . intervalOfConfidenceMax / 100 ) && ( Math . abs ( stepTrend / stepDoublingTimeAvg ) <= ( UserDefinedProtocol . growthTrendMax / 100 ) ) && ( stabilizedTime <= Number ( theExperiment . getDurationSec ( ) ) ) ) || ( stabilizedTimeMax <= Number ( theExperiment . getDurationSec ( ) ) ) ) {
394368 theAccessory . context ( ) . put ( 'modeStabilized' , 1 )
395- changeCounter = theAccessory . context ( ) . getInt ( 'changeCounter' , 0 )
369+ var changeCounter = theAccessory . context ( ) . getInt ( 'changeCounter' , 0 )
396370 theExperiment . addEvent ( '*** Stabilized doubling time Dt (' + theGroup . getAccessory ( 'thermo.thermo-reg' ) . getValue ( ) + String . fromCharCode ( 176 ) + 'C, ' + theAccessory . context ( ) . getString ( 'controlledParameterText' , 'no parameter' ) + ') is ' + round ( stepDoublingTimeAvg , 2 ) + String . fromCharCode ( 177 ) + round ( stepDoublingTimeIC95 , 2 ) + ' h (IC95)' )
397371 if ( UserDefinedProtocol . controlledParameterSteps . length > 1 ) {
398372 if ( changeCounter < ( UserDefinedProtocol . controlledParameterSteps . length - 1 ) ) {
0 commit comments