Esempio n. 1
0
 public override void Initialize()
 {
     initializeTwisterPositions();
     try
     {
         TwisterClsServer = new clsServer();
         string iniFile = TwisterClsServer.ApplicationPath + "\\" + InitiationFile;//"Twister.ini";//hope this is right one
         TwisterClsServer.ConfigureRobot(iniFile, ref SimulationMode);
         TwisterClsServer.Initialize();
         //THE TWISTER SERVE MUST BE INITIALIZED BEFORE IT WILL GIVE A ROBOT REF PROPERLY
         RobotServ = TwisterClsServer.GetRobotRef();//this line must follow the server initialization
         RobotServ.HomeAllAxes();
         //BIG ERROR IF NOT FOLLOWED!!!!
         short windowState = 1;//0 normal, 1 minimized, 2 maximized
         TwisterClsServer.ShowWindow(ref windowState);
         RobotServ.SpeedAsPercentMax = (short)50;
         StatusOK = true;
     }
     catch(Exception thrown)
     {
          StatusOK = false;
          throw new InstrumentError("Could not initialize Twister: "+thrown.Message, false, this);
     }
 }
Esempio n. 2
0
 public override bool CloseAndFreeUpResources()
 {
     //in vb6 these things are closed by setting them equal to none, not so in C# or .NET
     //this setup is terrible
     StatusOK = false;
     try { DisableVerticalMotor(); }
     catch { }
     try
     {
         if (TwisterClsServer != null)
         {
             System.Runtime.InteropServices.Marshal.ReleaseComObject(TwisterClsServer);
             TwisterClsServer = null;
         }
             //GC.Collect();
     }
     catch{}
     try
     {
         if (RobotServ != null)
         {
             System.Runtime.InteropServices.Marshal.ReleaseComObject(RobotServ);
             RobotServ = null;
         }
         //GC.Collect();
     }
     catch{}
     string[] ToKill = new string[2]{"TwisterII Robot ICP","ZymarkRobotICP"};
     foreach (string str in ToKill)
     {
         KillProcessAttempt(str);
     }
     return true;
 }