/** * Fetch details of the given analyzer id * * @param int $id * @return Response */ public function fetch() { $id = Input::get('analyzer_id'); $analyzer = Analyser::find($id); $analyzer->labSection = $analyzer->testCategory->name; $analyzer->commtype = $analyzer->commtype(); $analyzer->feedsource = $analyzer->feedsource(); return json_encode($analyzer); }
/** * @return \Illuminate\Routing\Route|null|string */ public function ingnoreId() { $id = $this->route('analyser'); $name = $this->input('name'); return Analyser::where(compact('id', 'name'))->exists() ? $id : ''; }
/** * * Function to generate config file for instrumentation * */ public function configFile() { $id = Input::get('analyzer_id'); $analyzer = Analyser::find($id); $cId = Configurable::idByName($analyzer->name); $setting = Configurable::find($cId); $fields = $setting->fields; // Part 1 $file = 'BLISInterfaceClient/part1.txt'; $current = file_get_contents($file); $config_p1 = str_replace("--FS--", $analyzer->feedsource(), $current); //Part2 if ($analyzer->feed_source == Analyser::RS232) { $file = 'BLISInterfaceClient/rs232.txt'; } else { if ($analyzer->feed_source == Analyser::TEXT) { $file = 'BLISInterfaceClient/flatfile.txt'; } else { if ($analyzer->feed_source == Analyser::MSACCESS) { $file = 'BLISInterfaceClient/msaccess.txt'; } else { if ($analyzer->feed_source == Analyser::HTTP) { $file = 'BLISInterfaceClient/http.txt'; } else { if ($analyzer->feed_source == Analyser::TCPIP) { $file = 'BLISInterfaceClient/tcpip.txt'; } } } } } $current = file_get_contents($file); $config_p2 = ""; foreach ($fields as $field) { $config_p2 = str_replace("--" . $field->field_name . "--", $field->field_name . " = " . $field->conf($setting->id)->setting->value, $current); $current = $config_p2; } echo $config_p2; //Part 3 $file = 'BLISInterfaceClient/part3.txt'; $current = file_get_contents($file); $config_p3 = str_replace("--BLIS_URL--", 'http://' . $_SERVER['HTTP_HOST'], $current); //Part 4 $file = 'BLISInterfaceClient/part4.txt'; $current = file_get_contents($file); $config_p4 = str_replace("--EQUIP_NAME--", $analyzer->name, $current); //Concatenated file $config_file_content = $config_p1 . "\n" . $config_p2 . "\n" . $config_p3 . "\n" . $config_p4; $file2 = 'BLISInterfaceClient/BLISInterfaceClient.ini'; file_put_contents($file2, $config_file_content); }