Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Dialogv5c3ecf03a1915() {
- var me = this;
- this.id = "dialogv5c3ecf03a1915";
- this.GetElement = function() {
- return document.getElementById(me.id);
- };
- this.GetEventHandlerName = function() {
- return "dialoghandlerv5c3ecf03a1915";
- };
- this.dialog_controls = [new DialogInput("RH", this, new ValidatorComplex(new ValidatorNumber(false, false), new ValidatorRange(0, 100)), new ElementAccessorNumber(), new ValidatorComplex(new ValidatorNumber(false, false))), new DialogInput("t", this, new ValidatorComplex(new ValidatorNumber(true, true), new ValidatorRange(-45, 60)), new ElementAccessorNumber(), new ValidatorComplex(new ValidatorNumber(true, true))), new DialogInput("p", this, new ValidatorNumber(false, true), new ElementAccessorNumber(), new ValidatorNumber(false, true)), new DialogInput("units", this, 0, new ElementAccessorSelect()), new DialogInput("precisionmeter", this, 0, new ElementAccessorPrecision(3)), new DialogInput("calculate", this, 0, new ElementAccessorOperation()), new DialogInput("_progress_", this, 0, new ElementAccessorDefault()), new DialogInput("A", this, 0, new ElementAccessorOutput())];
- me.dialog_controls.forEach(function(e) {
- if (me[e.id] === undefined) me[e.id] = e;
- });
- this.addHandler = function(handler) {
- this.dialog_controls.forEach(function(c) {
- c.addHandler(handler);
- });
- };
- this.SetValues = function(values) {
- this.dialog_controls.forEach(function(c) {
- if (values[c.id] !== undefined) {
- c.SetValue(values[c.id]);
- }
- });
- };
- this.Clear = function() {
- this.dialog_controls.forEach(function(c) {
- c.ResetValue();
- });
- };
- this.SetDefaultValues = function() {
- this.Clear();
- };
- this.GetValues = function() {
- var ret = {};
- this.dialog_controls.forEach(function(c) {
- ret[c.id] = c.GetValue();
- });
- return ret;
- };
- this.Validate = function() {
- for (var i = 0; i < me.dialog_controls.length; ++i)
- if (!me.dialog_controls[i].Validate()) return false;
- return true;
- };
- this.layout = function() {
- me.dialog_controls[4].elementAccessor.layout();
- }
- };
- document.addEventListener("DOMContentLoaded", function(event) {
- var dlg = new Dialogv5c3ecf03a1915();
- var hd = new CalculatorHandler(new function() {
- var savedData = {};
- var me = this;
- me.id = 2162;
- me.global = 1;
- var outputs = {};
- me.sinks = {
- change: [],
- done: []
- };
- me.startOnLoad = 1;
- var inputs = {};
- var renderers = {};
- var recordsets = {};
- var diagrams = {};
- var handler, dialog, refreshTimer;
- var worker;
- var proxies;
- var stubs;
- var outer = this;
- var Planetcalc = new function() {
- var inner = this;
- var cpcData = new CalcProgressData();
- var Calculate2159_cpc = new CalcProgressControl(cpcData);
- inner.Calculate2159 = function(___inp___) {
- var progressControl = Calculate2159_cpc;
- var Calculate2159_result = {};
- function __impl__(__inp__) {
- var t = __inp__["t"] === undefined ? 25 : __inp__["t"];
- var p = __inp__["p"] === undefined ? 760 : __inp__["p"];
- var units = __inp__["units"] === undefined ? "mmHg" : __inp__["units"];
- var e = {
- "SetValue": function(v) {
- Calculate2159_result["e"] = v;
- }
- };
- var tp = (units == "mmHg") ? (p * 133.322) / 100 : p;
- var et = 6.112 * Math.exp((17.62 * t) / (243.12 + t));
- var fp = 1.0016 + 3.15 * Math.pow(10, -6) * tp - 0.074 / tp;
- var ept = fp * et;
- e.SetValue(ept);
- };
- __impl__(___inp___);
- if (progressControl.completed()) {
- progressControl.context = null;
- }
- return Calculate2159_result;
- };
- var Calculate2162_cpc = new CalcProgressControl(cpcData);
- inner.Calculate2162 = function(___inp___) {
- var progressControl = Calculate2162_cpc;
- var Calculate2162_result = {};
- function __impl__(__inp__) {
- var RH = __inp__["RH"] === undefined ? 60 : __inp__["RH"];
- var p = __inp__["p"] === undefined ? 760 : __inp__["p"];
- var t = __inp__["t"] === undefined ? 25 : __inp__["t"];
- var units = __inp__["units"] === undefined ? "mmHg" : __inp__["units"];
- var A = {
- "SetValue": function(v) {
- Calculate2162_result["A"] = v;
- }
- };
- var result = Planetcalc.Calculate2159({
- "t": t,
- "p": p,
- "units": units
- });
- var ew = result.e;
- var e = (RH / 100) * ew;
- var Rv = 461.5;
- var T = t + 273.15;
- A.SetValue(e * 100 / (Rv * T));
- };
- __impl__(___inp___);
- if (progressControl.completed()) {
- progressControl.context = null;
- }
- return Calculate2162_result;
- };
- inner.main = inner.Calculate2162;
- inner.progressControl = Calculate2162_cpc;
- inner.init = function() {
- inner.progressControl.onDataReady();
- };
- };
- function startLoad() {
- me.progressControl.addEventListener("ready", handler.onReady);
- Planetcalc.init();
- }
- me.timeout = 1500;
- me.auto = 1;
- me.init = function(h, dlg) {
- var o;
- handler = h;
- dialog = dlg;
- me.progressControl = Planetcalc.progressControl;
- var n;
- var fn;
- n = 'RH';
- if (dlg[n]) {
- inputs[n] = dlg[n];
- PSS.LoadInput(me.id, n, dlg[n], savedData[n]);
- }
- n = 'p';
- if (dlg[n]) {
- inputs[n] = dlg[n];
- PSS.LoadInput(me.id, n, dlg[n], savedData[n]);
- }
- n = 't';
- if (dlg[n]) {
- inputs[n] = dlg[n];
- PSS.LoadInput(me.id, n, dlg[n], savedData[n]);
- }
- n = 'units';
- if (dlg[n]) {
- inputs[n] = dlg[n];
- PSS.LoadInput(me.id, n, dlg[n], savedData[n]);
- }
- o = dlg.A;
- outputs[o.id] = o;
- o.formatter = new FormatterNumber(3, 0, 0, "R");
- startLoad();
- };
- me.stop = function() {
- if (worker) worker.postMessage({
- type: "stop"
- });
- else Planetcalc.progressControl.stop();
- };
- me.start = function() {
- handler.onStart();
- if (worker) {
- me.changeDisplayOptions();
- worker.postMessage({
- type: "start",
- inputs: proxies(dialog.GetValues())
- });
- } else {
- Planetcalc.progressControl.clear();
- me.refresh();
- }
- };
- me.getInputs = function() {
- return inputs;
- };
- function objectValues(a, o) {
- for (var n in o) {
- a.push(o[n]);
- }
- }
- me.getOutputs = function() {
- var ret = [];
- objectValues(ret, outputs);
- objectValues(ret, diagrams);
- objectValues(ret, renderers);
- return ret;
- };
- me.refresh = function() {
- me.doit();
- };
- me.setResult = function(res, done) {
- outputs.A.SetValue(res.A);
- if (done) {
- handler.onStop();
- if (PCF.requestFormulaUpdate(false)) {
- var mjx = window.MathJax;
- mjx.Hub.Queue(["Typeset", mjx.Hub]);
- };
- }
- }
- me.doit = function() {
- var error = false;
- try {
- me.changeDisplayOptions();
- var res = Planetcalc.Calculate2162({
- "RH": Number(inputs.RH.GetValue()),
- "p": Number(inputs.p.GetValue()),
- "t": Number(inputs.t.GetValue()),
- "units": inputs.units.GetValue()
- });
- if (res) me.setResult(res, true);
- } catch (e) {
- handler.onStop(e);
- }
- };
- me.changeDisplayOptions = function() {
- me.calculateDisplay(new DisplayWrapperInput(inputs.RH), new DisplayWrapperInput(inputs.p), new DisplayWrapperInput(inputs.t), new DisplayWrapperInput(inputs.units), new DisplayWrapper(outputs.A));
- dialog.layout();
- }
- me.calculateDisplay = function(RH, p, t, units, A) {};
- }, {
- calculate: "Рассчитать",
- stop: "Остановить"
- });;
- hd.initdialog(dlg);
- dlg.addHandler(hd);
- window.dialoghandlerv5c3ecf03a1915 = hd;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement