<commit_before>/*
 * ----------------------------------------------------------------------------
 *  (C) Copyright Testing Technologies.  All Rights Reserved.
 *
 *  All copies of this program, whether in whole or in part, and whether
 *  modified or not, must display this and all other embedded copyright
 *  and ownership notices in full.
 *
 *  See the file COPYRIGHT for details of redistribution and use.
 *
 *  You should have received a copy of the COPYRIGHT file along with
 *  this file; if not, write to the Testing Technologies,
 *  Michaelkirchstr. 17/18, 10179 Berlin, Germany.
 *
 *  TESTING TECHNOLOGIES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
 *  SOFTWARE. IN NO EVENT SHALL TESTING TECHNOLOGIES BE LIABLE FOR ANY
 *  SPECIAL, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 *  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
 *  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
 *  THIS SOFTWARE.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
 *  EITHER EXPRESSED OR IMPLIED, INCLUDING ANY KIND OF IMPLIED OR
 *  EXPRESSED WARRANTY OF NON-INFRINGEMENT OR THE IMPLIED WARRANTIES
 *  OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
 * ----------------------------------------------------------------------------
 */
package com.testingtech.playits.canfilter;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.util.Date;
import java.util.Hashtable;
import java.util.Scanner;

import org.json.JSONException;
import org.json.JSONObject;

public class Car2XEntryUpdater extends Thread {

	private static final String DEFAULT_SIMULATOR_HOST = "localhost";
	private static final int DEFAULT_SIMULATOR_PORT = 50001;

	private Hashtable<String, Car2XEntry> car2xEntries;
	private InetSocketAddress address;

	/**
	 * Connects to the openXC simulator and updates openXC respectively obd2
	 * values within a hash table provided as a parameter.
	 * 
	 * @param car2xEntries
	 */
	public Car2XEntryUpdater(Hashtable<String, Car2XEntry> car2xEntries) {
		this.car2xEntries = car2xEntries;
		this.address = new InetSocketAddress(DEFAULT_SIMULATOR_HOST,
				DEFAULT_SIMULATOR_PORT);
	}

	/**
	 * Connects to the openXC simulator and updates values as long as there are
	 * updated requested (at least one entry exists).
	 */
	public void run() {
		Socket socket = null;
		Scanner scanner = null;
		try {
			socket = new Socket();
			System.out
					.println("[EntryUpdater] Connecting to openXC simulator at "<commit_msg>Entry updater implements runnable instead of extending thread<commit_after>/*
 * ----------------------------------------------------------------------------
 *  (C) Copyright Testing Technologies.  All Rights Reserved.
 *
 *  All copies of this program, whether in whole or in part, and whether
 *  modified or not, must display this and all other embedded copyright
 *  and ownership notices in full.
 *
 *  See the file COPYRIGHT for details of redistribution and use.
 *
 *  You should have received a copy of the COPYRIGHT file along with
 *  this file; if not, write to the Testing Technologies,
 *  Michaelkirchstr. 17/18, 10179 Berlin, Germany.
 *
 *  TESTING TECHNOLOGIES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
 *  SOFTWARE. IN NO EVENT SHALL TESTING TECHNOLOGIES BE LIABLE FOR ANY
 *  SPECIAL, DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 *  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
 *  AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 *  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
 *  THIS SOFTWARE.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
 *  EITHER EXPRESSED OR IMPLIED, INCLUDING ANY KIND OF IMPLIED OR
 *  EXPRESSED WARRANTY OF NON-INFRINGEMENT OR THE IMPLIED WARRANTIES
 *  OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
 * ----------------------------------------------------------------------------
 */
package com.testingtech.playits.canfilter;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.util.Date;
import java.util.Hashtable;
import java.util.Scanner;

import org.json.JSONException;
import org.json.JSONObject;

public class Car2XEntryUpdater implements Runnable {

	private static final String DEFAULT_SIMULATOR_HOST = "localhost";
	private static final int DEFAULT_SIMULATOR_PORT = 50001;

	private Hashtable<String, Car2XEntry> car2xEntries;
	private InetSocketAddress address;

	/**
	 * Connects to the openXC simulator and updates openXC respectively obd2
	 * values within a hash table provided as a parameter.
	 * 
	 * @param car2xEntries
	 */
	public Car2XEntryUpdater(Hashtable<String, Car2XEntry> car2xEntries) {
		this.car2xEntries = car2xEntries;
		this.address = new InetSocketAddress(DEFAULT_SIMULATOR_HOST,
				DEFAULT_SIMULATOR_PORT);
	}

	/**
	 * Connects to the openXC simulator and updates values as long as there are
	 * updated requested (at least one entry exists).
	 */
	public void run() {
		Socket socket = null;
		Scanner scanner = null;
		try {
			socket = new Socket();
			System.out
					.println("[EntryUpdater] Connecting to openXC simulator at "
{'fraction_non_alphanumeric': 0.11734028683181226, 'fraction_numerical': 0.008940212330042838, 'mean_word_length': 3.169254658385093, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7394969', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1440, 'n_words': 583}