需要 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);