Example of a JScript
, [* ]1 ^7 [8 P( G$ n! pvar vbOKCancel = 1; ( T4 T: r) q8 _8 A- @: C: ~/ d
var vbCancel = 2; , U% s: H; R& v; r: \
var vbInformation = 64;
: B# h% h2 h2 Y& E3 P. F/ T8 gvar Finished=false;
/ A- S, j1 T+ ]1 e! I4 I* ? 7 i8 i6 ]) `5 ]- \5 R. y
var WSHShell = new ActiveXObject("WScript.Shell"); ! _/ l$ P# F* F" ?
4 D' V* d# L. C& f
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
. }" g" }9 T$ S0 r" z1 h
& J5 p9 N3 g/ hsimple.SetLicenseType("Runtime"); L7 f5 k: \9 }) c, ?
+ A" H1 \( X0 M* ~try
: d6 S( F3 |! f0 ^2 t$ G{ + u G( o; @ o6 G. [0 R
// Enter the path to a model file! 3 H3 a0 `0 S7 e2 v! U
simple.LoadModel("C:\\Models\\Test.spp"); 6 t o) A' z- q3 @' R
}
+ V. ~0 y. l; M1 A0 v* |5 [catch (e)
7 e6 g; Y4 J; i2 |) z3 s) a{ 1 y; B& h/ e& s' f# m
WScript.Echo("Could not load Model!"); / j6 m w6 {, X% b2 V8 i! ~
WScript.Quit();
/ H% r: P: W0 Q8 M' \} * x' p3 p; _7 z- I; i
! `. l2 }: ^) Y% w) V, m1 ]$ d5 Etry
1 u& }- x" o( h% r{ u5 Q. E- k$ j3 c- ?
simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) {
# c# Z l* _$ t8 Z1 u r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation);
q' j# W# J$ N- Y0 x if (r == vbCancel)
2 m' n! M) [# S; | ^ x. x/ V { |* _) @; a+ d- G/ s- Z; H
simple.CloseModel(); 7 q5 @- h* r7 N) R" J9 @! }
WScript.Quit(); 6 C& j/ T5 e* ?+ `
}
- N% d6 a6 I) F# a D}
+ }: D n5 j- P! o5 A
% b* [% a T7 y) Jsimple.StartSimulation(".Models.Frame.EventController"); , r+ c5 N$ i9 w! A; ?) L3 V
' w6 P# l( w% B3 d, K3 ^
if (simple.IsSimulationRunning())
$ T: s1 M1 x: I: S+ X. @ WScript.Echo("Simulation is running!"); 2 a- _ S+ I! w \/ T. ~# E
. p; N l' P* i7 \& U5 R1 V- z
// Wait until simulation is finished
/ }9 u, `3 V) p( S6 vwhile (!Finished) WScript.Sleep(2000);
& s/ W3 f9 H) P
6 Q" a& r+ {/ ~% X0 a, [simple.CloseModel(); * T9 d) P5 J0 A0 t7 q9 ?
simple.Quit();
" G$ F7 n7 K4 k5 v& U, v2 u8 U; ?WScript.Quit(); . i( j# ~0 r& g7 E* m! j
" h: A5 [5 Y/ m& {
: h: \+ @: T( y% h+ M u" e
function RemoteControl_SimulationFinished() " E$ x8 p) |7 [ z
{
1 _# a" F9 K5 r) q WScript.Echo("Simulation Finished!"); |