<commit_before>import { Injectable } from '@angular/core';
import { Headers, Http, Response } from '@angular/http';

import 'rxjs/add/operator/map';

import { Route } from './route';

import { environment } from '../../environments/environment';

@Injectable()
export class RouteService {
  constructor(private http: Http) { }

  getRoute(route: any) {
    return this.http.get(environment.apiURL + '/routes/get/' + route)
               .map(response => {
                 return response.json() as Route;
               });
  }

  getTotalMessages() {
    return this.http.get(environment.apiURL + '/routes/list/')
               .map(response => {
                 let routes = response.json() as Route[];
                 let messages = 0;
                 routes.forEach((route) => messages += +route.messages);

                 return messages;
               });
  }

  getRoutes() {
    return this.http.get(environment.apiURL + '/routes/list/')
               .map(response => {
                 return response.json() as Route[];
               });
  }

  stopRoute(routeId: string) {
      // -------------------------------------------------------------------------------
      // Hardcoded just for demonstration
      if(routeId == "OPC-UA: Read Engine RPM (Trusted)") {
        this.http.get('http://iot-connector1.netsec.aisec.fraunhofer.de/led/1/power/false')
          .map(response => {
            return {};
          });
      } else if(routeId == "OPC-UA: Read Engine Current (Untrusted)") {
        this.http.get('http://iot-connector1.netsec.aisec.fraunhofer.de/led/2/power/false')
          .map(response => {
            return {};
          });
      }
      // -------------------------------------------------------------------------------

      return this.http.get(environment.apiURL + '/routes/stoproute/' + routeId)
                 .map(response => {
                   return response.json() as string;
                 });
  }

  startRoute(routeId: string) {
    // -------------------------------------------------------------------------------
    // Hardcoded just for demonstration
    if(routeId == "OPC-UA: Read Engine RPM (Trusted)") {
      this.http.get('http://iot-connector1.netsec.aisec.fraunhofer.de:8282/led/1/power/true')
        .map(response => {
          return {};
        });
    } else if(routeId == "OPC-UA: Read Engine Current (Untrusted)") {
      this.http.get('http://iot-connector1.netsec.aisec.fraunhofer.de:8282/led/2/power/true')
        .map(response => {
          return {};
        });
    }
    // -------------------------------------------------------------------------------

      //Start Camel route
      return this.http.get(environment.apiURL + '/routes/startroute/' + routeId)<commit_msg>can write to LED now<commit_after>import { Injectable } from '@angular/core';
import { Headers, Http, Response } from '@angular/http';

import 'rxjs/add/operator/map';

import { Route } from './route';

import { environment } from '../../environments/environment';

@Injectable()
export class RouteService {
  constructor(private http: Http) { }

  getRoute(route: any) {
    return this.http.get(environment.apiURL + '/routes/get/' + route)
               .map(response => {
                 return response.json() as Route;
               });
  }

  getTotalMessages() {
    return this.http.get(environment.apiURL + '/routes/list/')
               .map(response => {
                 let routes = response.json() as Route[];
                 let messages = 0;
                 routes.forEach((route) => messages += +route.messages);

                 return messages;
               });
  }

  getRoutes() {
    return this.http.get(environment.apiURL + '/routes/list/')
               .map(response => {
                 return response.json() as Route[];
               });
  }

  stopRoute(routeId: string) {
      // -------------------------------------------------------------------------------
      // Hardcoded just for demonstration
      if(routeId == "OPC-UA: Read Engine RPM (Trusted)") {
        this.http.post('http://iot-connector1.netsec.aisec.fraunhofer.de:8282/led/1/power/false', {}).subscribe();
        this.http.post('http://iot-connector1.netsec.aisec.fraunhofer.de:8282/led/3/power/false', {}).subscribe();
        this.http.post('http://iot-connector1.netsec.aisec.fraunhofer.de:8282/led/4/power/false', {}).subscribe();        
      } else if(routeId == "OPC-UA: Read Engine Current (Untrusted)") {
        this.http.post('http://iot-connector1.netsec.aisec.fraunhofer.de:8282/led/2/power/false', {}).subscribe();
      }
      // -------------------------------------------------------------------------------

      return this.http.get(environment.apiURL + '/routes/stoproute/' + routeId)
                 .map(response => {
                   return response.json() as string;
                 });
  }

  startRoute(routeId: string) {
    // -------------------------------------------------------------------------------
    // Hardcoded just for demonstration
    if(routeId == "OPC-UA: Read Engine RPM (Trusted)") {
      this.http.post('http://iot-connector1.netsec.aisec.fraunhofer.de:8282/led/1/power/true', {}).subscribe();
      this.http.post('http://iot-connector1.netsec.aisec.fraunhofer.de:8282/led/3/power/true', {}).subscribe();
      this.http.post('http://iot-connector1.netsec.aisec.fraunhofer.de:8282/led/4/power/true', {}).subscribe();
    } else if(routeId == "OPC-UA: Read Engine Current (Untrusted)") {
      this.http.post('http://iot-connector1.netsec.aisec.fraunhofer.de:8282/led/2/power/true', {}).subscribe();
    }
    // -------------------------------------------------------------------------------

      //Start Camel route
      return this.http.get(environment.apiURL + '/routes/startroute/' + routeId)
{'fraction_non_alphanumeric': 0.25389221556886227, 'fraction_numerical': 0.011291702309666382, 'mean_word_length': 1.5384281372123318, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '259216', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1628, 'n_words': 269}