Example of a JScript
2 i! p# Q: z& ]9 l$ svar vbOKCancel = 1;
c4 i/ U* p! U. }9 gvar vbCancel = 2;
: ^) ]" D7 c; kvar vbInformation = 64; 1 w) K _+ L& X# M
var Finished=false;
O. W, K( x8 @$ g4 m" i ) t( B$ @/ b* I! U3 _' `+ Q
var WSHShell = new ActiveXObject("WScript.Shell");
3 {. r: o0 q e Q7 u' K8 b8 _' J* T2 T# J# `' P. [
var simple = WScript.CreateObject("Tecnomatix.PlantSimulation.RemoteControl.9", "RemoteControl_");
5 A. C# C/ x6 O8 i
4 Y' C. W8 U9 K5 K' Hsimple.SetLicenseType("Runtime");
% v7 z6 r# ~" v' r2 t; Q/ I
1 l% W1 r. |9 N% u1 y8 | @try % i1 v# N& Q2 W+ {6 Y' S
{
9 B6 O- T4 q8 Z9 M+ H+ ] // Enter the path to a model file! % X' }4 x) B ?1 ?2 N ~
simple.LoadModel("C:\\Models\\Test.spp"); 3 C' j, O% c* E5 o
}
: u+ W( Q9 [/ n+ U* l$ a1 e0 |catch (e)
5 E& c, V* Y0 y/ t4 H{
K+ _) j" S: ~5 A; }7 v% V WScript.Echo("Could not load Model!");
; D6 M- L, F0 V9 g% M! `5 R WScript.Quit(); 4 V# s3 a" M6 M9 p* ^/ T
} 4 `) n* ]& o, Q9 t
- S( v, D; m% {try
" c8 s8 s4 D' }' ?7 t{
4 X A% _- @2 v2 Y simple.SetValue(".Models.Frame.Buffer.procTime", 700.0); } catch (e) { , \; ~$ T8 i+ k: {
r=WSHShell.Popup(e.description, 0, "Continue?", vbOKCancel + vbInformation); " H7 ^. p& F) y* _( O8 V1 I
if (r == vbCancel) $ x5 @8 s* B; s; c
{ * A) y. G# G2 h2 l, o( n7 `
simple.CloseModel(); 0 g1 @+ h ~2 i8 f1 O/ T( q* e) p- [
WScript.Quit();
! C' H' o0 P2 v/ Y1 f. p; s6 p _ } V% ~5 q- q' }' [% F3 N _ B
} " a2 m- w2 K' B/ t! S7 Q8 j8 v
2 u% U. S5 R# \# D# B5 @
simple.StartSimulation(".Models.Frame.EventController"); + r3 U% Q1 g4 g
4 C1 K! h2 |' ?2 Uif (simple.IsSimulationRunning())
) |5 ]) c" K, U WScript.Echo("Simulation is running!"); r+ i/ H. n4 C& E6 W1 R
+ y5 V! @# t" j+ X
// Wait until simulation is finished
* d* X' S2 Z/ R# S. }while (!Finished) WScript.Sleep(2000);
2 e: @4 T( F; B! E& @5 V
" I# k: W7 E! m4 Psimple.CloseModel();
) { A$ X" s; ]/ @! L P* G. lsimple.Quit();
, ?7 h' x5 l! D4 W0 j/ E( S0 m6 gWScript.Quit();
) u6 p0 k( y9 p9 a& q! ~ 4 F' g& y, m- Q3 L5 k; k
+ P r" ^% ~2 L$ \function RemoteControl_SimulationFinished() . C6 D2 S3 O2 R, J/ {
{ 5 O6 o9 Y$ C9 d t; l$ |, m1 `8 ^; F
WScript.Echo("Simulation Finished!"); |