Example of a JScript
- \6 h# r1 A6 O1 @, X" o7 rvar vbOKCancel = 1;
8 T" W+ f& W$ M) O2 D+ H8 Cvar vbCancel = 2; * p( {6 g" z3 G
var vbInformation = 64;
2 h; B8 r9 O6 b/ H9 K1 k; bvar Finished=false; ! I8 w* |' {& D1 S& r( [( R7 {
" w5 }" t# @) }6 ?$ M/ U
var WSHShell = new ActiveXObject("WScript.Shell"); 1 ` h" P( g3 }* ~5 e; j& _3 N
& I1 L6 X- ?+ D/ U& x/ kvar simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
% \ h* h9 O7 y * `2 c. c! M9 J( ?/ M
simple.SetLicenseType("Runtime");
0 J: v$ _. B7 [+ \( h4 i7 e; { . Q5 w5 ], w4 t+ n; F$ t# F7 A+ Q
try - O9 `8 O6 ]+ D' H4 ?8 b9 n
{
5 I) l: U1 m/ P3 b // Enter the path to a model file!
1 q* x: c1 ^- p simple.LoadModel("C:\\Models\\Test.spp");
' Q+ z/ L4 L6 z9 j) E# _} . y, {3 }6 U, J$ J4 B t* n
catch (e)
2 T% m1 N9 t) W3 `{
) C3 R9 Y9 R) ]" l6 ~8 V6 N/ @ WScript.Echo("Could not load Model!"); 8 c% f* F( ]8 f7 i% Q
WScript.Quit();
7 b( A/ y! P! u; J; B) X& ^) R}
4 V4 A$ h, D& E# Z4 J / z" { p+ n4 {
try
# f- y4 p+ [6 G5 z{
4 ^5 _4 @/ t6 m) w+ u8 b, Q/ ?% A simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { % I1 M ^# ?# E8 |
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
( e7 k6 H# `, W8 G7 D; l* f% Y if (r == vbCancel) , k) y/ l, c s% d
{ 5 U- R5 V* G2 G. @& ~ _* k! t- a
simple.CloseModel(); 3 F' i9 V5 [0 n, \. S7 L3 x
WScript.Quit(); ~- z0 G1 a5 d- n
} : J4 S v% E2 z, J0 `" h8 B
}
3 u& V; T4 O: ]# c4 X/ g& A # B4 | {, I% g+ [8 ^( e- w
simple.StartSimulation(".Models.Frame.EventController");
% r3 w2 V2 S( P8 @ { ' b- b5 f- ^/ ~% T! K/ s$ n0 q
if (simple.IsSimulationRunning())
4 M8 p1 j- a# R4 N/ {; z WScript.Echo("Simulation is running!");
Y& {$ k9 Y" |7 w+ F: ?
" f/ M. V7 S6 f2 f// Wait until simulation is finished
. M: V+ ?& h: g: d @while (!Finished) WScript.Sleep(2000); ' Y2 s- Y9 J6 H0 z
/ U# y# K% e' k* m0 D- e }( F( {$ x5 d
simple.CloseModel(); $ M- X6 h$ O9 B' F! W5 s- z
simple.Quit(); / N' a* r0 B/ B4 x- O! D H
WScript.Quit(); : N5 L4 g4 j4 ]8 t2 V
# _+ \6 `* N0 i0 g7 @- e 1 [5 L' _8 a. W7 q
function RemoteControl_SimulationFinished() " G" g/ z4 z: Z& S
{ 8 q5 D; D2 `% O$ j2 U9 j
WScript.Echo("Simulation Finished!"); |