Example of a JScript
2 p: l& p/ K* ]var vbOKCancel = 1;
a$ T+ o, O5 [- H% _5 Qvar vbCancel = 2; ! b8 j7 B+ w" v' M
var vbInformation = 64;
# L( P8 Q9 R+ S3 kvar Finished=false;
, t$ F" |6 M! M& v + V$ l5 h1 {; R, y; t
var WSHShell = new ActiveXObject("WScript.Shell");
5 o6 v' M$ G# q% X% Z, x- k* w 5 V3 i1 d2 s9 Y7 s
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_"); c% s/ @7 I }$ |2 j' r- L$ ]
( e& H# y- x8 {/ y! p
simple.SetLicenseType("Runtime"); 1 @9 `, ~ c# a
& R- M' g5 A5 ]3 _% b. G8 x! x
try % h$ E3 H; z+ u5 l
{ 9 \5 p1 N. |; U
// Enter the path to a model file!
$ _7 @7 s: |) m# T5 K, p simple.LoadModel("C:\\Models\\Test.spp");
' n$ Y. T9 a2 Y& g} + S5 Y- Z3 j4 U! @- F$ r
catch (e)
7 i- [' u" a+ o0 f; _. m{
\. }* X# Z3 F1 q; C+ c; d8 p WScript.Echo("Could not load Model!"); 2 E; ^) m6 T F- D# E+ }
WScript.Quit(); 5 W$ u8 v0 Y' Q+ [# w" Z
}
% G4 h/ _& @/ ]% v) B& q+ h# T! t
$ P" w8 ~. [. ]' ntry * Z) W" A( R' C6 \0 v
{ 6 j, m& i7 j' \+ K; r( b9 J
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
' i1 |0 Z, t$ M) W: f9 s. O r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
' j h! b( z1 S1 Y4 U, v! w4 N. E if (r == vbCancel) 9 {1 j) V( h$ t% s* a: M1 h
{ # Q$ P$ j' s$ l7 |$ ^# R3 K
simple.CloseModel(); 2 s( K$ }# b6 e+ t% Z! i5 S
WScript.Quit();
! d/ X1 G" {4 V } 1 w. w- y5 g0 X2 {2 o. G6 |
}
/ |' k3 [* f% n9 _. ?& ~* _7 F4 b
3 n% |* _6 C7 V2 M4 F+ o* isimple.StartSimulation(".Models.Frame.EventController");
0 z1 C: m+ ] `8 Z0 s* x) a0 g3 V ; F' f, c, @4 M4 d& p* W
if (simple.IsSimulationRunning()) / l, [" d4 P0 Z6 o0 u
WScript.Echo("Simulation is running!"); ! o$ A+ N6 p7 r2 w* |
( v: y8 U; l) [- Q/ Q* t
// Wait until simulation is finished
: i% i) E# |+ ^( l- qwhile (!Finished) WScript.Sleep(2000); 8 g1 i1 v/ _1 _# o
% _2 p0 b% U( F3 n0 Csimple.CloseModel();
( ^, @$ @" D$ E; ?+ M$ gsimple.Quit();
+ T6 d! n% n, z5 G7 X7 ~- w, gWScript.Quit(); / m$ N Z# L8 |& X' Y7 T
. s! v. g* P0 X: H& D
% L8 l# y- [+ k/ {. r3 }2 Z) Hfunction RemoteControl_SimulationFinished() ; ?7 F; e* o& z! a L1 `
{ g8 W7 e* t0 O# W0 e2 w; y" u* q
WScript.Echo("Simulation Finished!"); |