Set exposure and autoscale when restoring state

This commit is contained in:
mmcw-dev 2017-10-23 00:17:02 -04:00
parent 6368ece015
commit 796d1604f0
1 changed files with 12 additions and 8 deletions

View File

@ -229,7 +229,7 @@
</label> </label>
</div> </div>
<div> <div>
<div class="label">Exposure = <span id="str">1/5</span></div> <div class="label">Exposure <span id="str">1/5</span></div>
<input type="number" id="exposure" value="630" min="0" oninput="setExposure();" /> <input type="number" id="exposure" value="630" min="0" oninput="setExposure();" />
<select id="scale" onchange="setExposureScale();"> <select id="scale" onchange="setExposureScale();">
<option value="ms" selected>ms</option> <option value="ms" selected>ms</option>
@ -283,7 +283,8 @@ null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"
<script> <script>
var BOLEX = { var BOLEX = {
angle : 133, angle : 133,
prism : 0.8 prism : 0.8,
expected : 630
}; };
var STATE = { var STATE = {
dir : true, dir : true,
@ -302,11 +303,11 @@ null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"
//ms //ms
var shutter = function (exposure) { var shutter = function (exposure) {
'use strict'; 'use strict';
var fraction = 630 / 1000; var fraction = BOLEX.expected / 1000;
var speed; var speed;
var corrected; var corrected;
var str; var str;
if (typeof exposure !== 'undefined' && exposure !== 0) { if ((typeof exposure !== 'undefined' && exposure !== 0) || exposure > BOLEX.expected) {
//if exposure is explicitly set //if exposure is explicitly set
fraction = exposure / 1000; fraction = exposure / 1000;
speed = fraction; speed = fraction;
@ -316,7 +317,7 @@ null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"
corrected = speed * BOLEX.prism; corrected = speed * BOLEX.prism;
if (corrected < 1.0) { if (corrected < 1.0) {
//less than a second //less than a second
str = '1/' + Math.round(Math.pow(corrected, -1)); str = '1/' + Math.round(Math.pow(corrected, -1)) + ' sec';
} else if (corrected >= 1.0 && corrected < 60) { } else if (corrected >= 1.0 && corrected < 60) {
//greater than a second, less than a minute //greater than a second, less than a minute
str = '' + (Math.round(corrected * 10) / 10) + ' sec' str = '' + (Math.round(corrected * 10) / 10) + ' sec'
@ -472,6 +473,7 @@ null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"
web.getStateSuccess = function (res) { web.getStateSuccess = function (res) {
'use strict'; 'use strict';
var exposure; var exposure;
var scale;
if (res.frame.dir !== true) { if (res.frame.dir !== true) {
$('#dir').prop('checked', true); $('#dir').prop('checked', true);
STATE.dir = res.frame.dir; STATE.dir = res.frame.dir;
@ -480,12 +482,14 @@ null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"
$('#counter').val(res.counter); $('#counter').val(res.counter);
STATE.count = res.counter; STATE.count = res.counter;
if (res.frame.exposure === 0) { if (res.frame.exposure === 0) {
res.frame.exposure = 630; res.frame.exposure = BOLEX.expected;
} }
$('#exposure').val(res.frame.exposure); $('#exposure').val(res.frame.exposure);
STATE.exposure = res.frame.exposure; STATE.exposure = res.frame.exposure;
exposure = shutter(STATE.exposure); exposure = shutter(STATE.exposure);
$('#str').text(exposure.str); $('#str').text(exposure.str);
scale = autoScale(STATE.exposure);
$('#scale').val(scale);
$('#delay').val(res.frame.delay); $('#delay').val(res.frame.delay);
STATE.delay = res.frame.delay; STATE.delay = res.frame.delay;
}; };
@ -495,7 +499,7 @@ null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"
$.ajax({ $.ajax({
method : 'POST', method : 'POST',
url : '/exposure', url : '/exposure',
data : JSON.stringify({ exposure : exposure }), data : JSON.stringify({ exposure : scaledExposure }),
contentType: 'application/json', contentType: 'application/json',
dataType : 'json', dataType : 'json',
success : web.setExposureSuccess success : web.setExposureSuccess
@ -506,7 +510,7 @@ null==d?void 0:d))},attrHooks:{type:{set:function(a,b){if(!o.radioValue&&"radio"
'use strict'; 'use strict';
var exposure; var exposure;
if (res.exposure) { if (res.exposure) {
res.exposure = 630; res.exposure = BOLEX.expected;
} }
STATE.exposure = res.exposure; STATE.exposure = res.exposure;
exposure = shutter(STATE.exposure); exposure = shutter(STATE.exposure);