Ejemplo n.º 1
0
 /**
  * Show the form for creating a new instrument.
  *
  * @return Response
  */
 public function create()
 {
     // Get a list of all installed plugins
     $plugins = ['' => ''] + Instrument::getInstalledPlugins();
     //Create Instrument view
     return view('instrument.create')->with('instruments', $plugins);
 }
Ejemplo n.º 2
0
 /**
  * Save instrument
  *
  * @param String machineCode, String ip, optional String hostname
  * @return String success/failure message
  */
 public static function saveInstrument($code, $ip, $hostname = "")
 {
     $plugin = Instrument::getInstalledPlugins(true);
     $className = "";
     // Get the class name of the user selected plugin
     foreach ($plugin as $key => $plug) {
         // If the instrument_code matches that of the select box, WE HAVE A MATCH
         if ($key == $code) {
             $className = $plug['class'];
             break;
         }
     }
     if (class_exists($className)) {
         $instrument = new $className($ip);
         $deviceInfo = $instrument->getEquipmentInfo();
         $newInstrument = new Instrument();
         $newInstrument->name = $deviceInfo['name'];
         $newInstrument->description = $deviceInfo['description'];
         $newInstrument->driver_name = $className;
         $newInstrument->ip = $ip;
         $newInstrument->hostname = Input::get('hostname');
         try {
             $newInstrument->save();
             $newInstrument->setTestTypes($deviceInfo['testTypes']);
             return trans('messages.success-creating-instrument');
         } catch (QueryException $e) {
             Log::error($e);
         }
     }
     return trans('messages.failure-creating-instrument');
 }