需要 JSL 的压力补偿温度公式帮助你好,
我正在寻找有关如何开始为以下压力补偿温度编写 JSL 的示例或指导:
- 创建一个 UI 以选择温度列和压力列。还让用户输入参考压力、转换系数、纯度系数。
- 使用 UI 数据使用多个 IF 语句和数学表达式计算每行的压力补偿温度。
- 创建一个新列并用上面计算的压力补偿温度填充它。
任何帮助表示赞赏!
质量和工艺工程回复:需要 JSL 的帮助以获得压力补偿温度公式@txnelson @Craige_Hales
非常感谢你们!这正是我所需要的。这可能不是最佳的,但我最终创建了带有公式的中间柱来导出压力补偿温度 (pct)。我不想在我的数据表中有几个中间列,所以我从 pct 中删除了公式并删除了中间列。如果我添加更多的数据行,我将不得不重新运行脚本。
我在下面粘贴了我想出的代码(但请注意,我必须更改所有常量/系数,因为这是我的工作)
//Script for creating a pressure compensated temperature tag
//Rev 1 8/25/20
names default to here(1);
/*dtList = New Table("Example Data",
new column("Temperature"),
new column("Pressure")
);*/
dtList = CurrentDataTable();
dlg = Column Dialog(
temperatureCol = ColList( "Temperature", Max Col( 1 ), Modeling Type( {"Continuous", "Multiple Response"} ) ),
pressureCol = ColList( "Pressure", Max Col( 1 ), Modeling Type( {"Continuous", "Multiple Response"} ) ),
Line Up( 2,
Text Box( "Reference Pressure" ), refPressure = EditNumber( . ),
Text Box( "Conversion Factor" ), conFactor = EditNumber( 1 ),
Text Box( "Purity Factor" ), purFactor = EditNumber( 1 ),
Text Box( "Pressure Units"), unitsP = comboBox( {"Gauge","Absolute"}),
Text Box( "PComp Tag Name"), pcompTag = EditText( "PComp Tag" )
),
Text Box("
**Reference Pressure is the base pressure and must be in the same units as the pressure tag.
**Pressure Units is a logical to indicate if the pressure being measured is absolute or gauge. For most
situations, the pressure will be measure in terms of gauge. However, vacuum pipestills typically use absolute.
**PComp Tag Name will be the column name of the new Pressure Compensate Temperature tag.
"),
);
show(dlg);
//Absolute needs to be 0 and Gauge needs to be 1. The combo box has Absolute as 2 and Gauge as 1,
If( dlg["unitsP"] == 1, dlg["unitsP"] = 1, dlg["unitsP"] = 0 );
//Write("unitsP equals: ", dlg["unitsP"]);
Eval( // run the code below
Eval Expr( // convert the Expr(...) below into a hard coded value
// eval(evalexpr(expr(...))) is a pattern for getting values from the dlg INTO
// A FORMULA. if you follow this pattern, the formula will be self contained.
dtList << New Column( "PA",
formula( // random formula that uses all the variables AND shows an if() stmt
Expr( dlg["purFactor"] ) *
(Expr( dlg["unitsP"] ) + Expr( dlg["pressureCol"][1] ) * Expr( dlg["purFactor"] ) / 12)
)
)
)
);
Eval( // run the code below
Eval Expr(
dtList << New Column( "PB",
formula( // random formula that uses all the variables AND shows an if() stmt
Expr( dlg["refPressure"] ) * Expr( dlg["conFactor"] ) / 12 + Expr( dlg["unitsP"] )
)
)
)
);
Eval(
Eval Expr(
dtList << New Column( "TA",
formula( // random formula that uses all the variables AND shows an if() stmt
Expr( dlg["temperatureCol"][1] ) + 400
)
)
)
);
New Column( "AA",
formula(
If( :PA >= 1.1111 ,
(4 - LOG10(:PA)) / (2000 - 25*LOG10(:PA)) - 0.0001
, // else
(3- LOG10(:PA)) / (2000 - 25*LOG10(:PA)) - 0.0001
)
)
);
New Column( "AB",
formula(
If( :PB >= 1.1111 ,
(4 - LOG10(:PB)) / (2000 - 25*LOG10(:PB)) - 0.0001
, // else
(3 - LOG10(:PB)) / (2000 - 100*LOG10(:PB)) - 0.0001
)
)
);
New Column( "DEN",
formula(
:AB / :AA * ((1.1 / :TA) - 0.0001) + 0.0001
)
);
New Column( "TB",
formula(
1.1 / :DEN - 400
)
);
Column("TB") << delete formula;
Column("TB") << Set Name( dlg["pcompTag"] );
dtList << delete columns( {"PA","PB","TA","AA","AB","DEN"} );回复:需要 JSL 的帮助以获得压力补偿温度公式你好,
你是什么意思 ”压力补偿温度”? 更具体的细节将更容易获得支持
回复:需要 JSL 的帮助以获得压力补偿温度公式凉爽的!不确定我是否使用过列对话框,但它似乎非常适合这项工作。
运行 Jim 的示例后,尝试使用类似这样的代码将公式列添加到您的表中。
Eval( // run the code below
Eval Expr( // convert the Expr(...) below into a hard coded value
// eval(evalexpr(expr(...))) is a pattern for getting values from the dlg INTO
// A FORMULA. if you follow this pattern, the formula will be self contained.
dtList << New Column( "adjusted",
formula( // random formula that uses all the variables AND shows an if() stmt
If( Expr( dlg["refPressure"] ) > Expr( dlg["pressureCol"][1] ),
Expr( dlg["temperatureCol"][1] ) + // first item of list
Expr( dlg["pressureCol"][1] ) + //
Expr( dlg["conFactor"] ) + // simple value
Expr( dlg["purFactor"] ) + //
Expr( dlg["refPressure"] )// do the ususal stuff...
, // else refPressure <= pressureCol...
Expr( dlg["temperatureCol"][1] ) + // first item of list
Expr( dlg["pressureCol"][1] ) + //
Expr( dlg["conFactor"] ) + // simple value
Expr( dlg["purFactor"] ) + //
Sqrt( Expr( dlg["refPressure"] ) )// do something extra for low ref
)
)
)
)
);这里发生了几件事。
- formula() 不计算它的参数,所以你必须给它一些帮助
- 我求助于 eval(evalexpr(expr(...))) 技术。 还有其他方法。
- 你说你需要一个 if(...) 所以我做了一个。 您可以使用任何您喜欢的 JSL 来为结果生成一个简单的数字。 if() 的结果是它计算的最后一个值。
- 如果您需要在公式中多次使用一个变量,请查看上面的公式。
- 显然我的公式不是您要找的那个!
- 对于简单的公式,您不需要所有的 evalexpr 东西。公式(:压力*:温度)工作正常。 但是在这个例子中,您不知道列的名称;相反,您知道保存列名称的变量的名称。
作为参考,dlg 返回此列表:
// this is what the dlg returns; the columns are a list of 1 item
// and the parameters are simple values:
//
// {temperatureCol = {:Temperature}, pressureCol = {:Pressure},
// Text Box, refPressure = 3, Text Box, conFactor = 33,
// Text Box, purFactor = 333, Button( 1 )}最后,请务必查看您使用公式编辑器创建的公式,以确保它确实符合您的期望!
Click the + next to the column name to open the formula in the editorClick the + next to the column name to open the formula in the editorClick the + next to the column name to open the formula in the editor单击列名称旁边的 + 以在编辑器中打开公式
回复:需要 JSL 的帮助以获得压力补偿温度公式- 阅读安装 JMP 时下载的 JMP 文档库中的脚本指南
- 我可以在 UI 方面为您提供一些帮助,但是“使用 UI 数据使用多个 IF 语句和数学表达式计算每一行的压力补偿温度。 “太模糊,无法真正指导你。

这是上面的 JSL。您只需要从窗口获取信息并将其插入您的公式即可。阅读文档中有关 Column Dialog() 和 New Column() 的部分
names default to here(1);
dtList = New Table("Example Data",
new column("Temperature"),
new column("Pressure")
);
dlg = Column Dialog(
temperatureCol = ColList( "Temperature", Min Col( 1 ), Max Col( 2 ), Data Type( "Numeric" ) ),
pressureCol = ColList( "Pressure", Max Col( 1 ), Modeling Type( {"Continuous", "Multiple Response"} ) ),
Line Up( 2,
Text Box( "Reference Pressure" ), refPressure = EditNumber( . ),
Text Box( "Conversion Factor" ), conFactor = EditNumber( . ),
Text Box( "Purity Factor" ), purFactor = EditNumber( . )
));
show(dlg);