<commit_before>/*******************************************************************************
 * Copyright (c) 2012 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.csstudio.scan.server;

import java.io.PrintStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.csstudio.apputil.macros.MacroUtil;
import org.csstudio.scan.ScanSystemPreferences;
import org.csstudio.scan.device.ScanConfig;
import org.csstudio.scan.device.SimulatedDevice;

/** Context used for the simulation of {@link ScanCommandImpl}
 *  @author <NAME>
 */
@SuppressWarnings("nls")
public class SimulationContext
{
	final private ScanConfig simulation_info;

    /** Macros for resolving device names */
    final private MacroContext macros;
	
	final private Map<String, SimulatedDevice> devices = new HashMap<String, SimulatedDevice>();

	final private PrintStream log_stream;

	private double simulation_seconds = 0.0;

	/** Initialize
	 *  @param log_stream Stream for simulation progress log
	 *  @throws Exception on error while initializing {@link SimulationInfo}
	 */
	public SimulationContext(final PrintStream log_stream) throws Exception
	{
	    this.simulation_info = new ScanConfig(ScanSystemPreferences.getSimulationConfigPath());
        this.macros = new MacroContext(ScanSystemPreferences.getMacros());
		this.log_stream = log_stream;
	}

    /** @return Macro support */
    public MacroContext getMacros()
    {
        return macros;
    }

    /** @return Current time of simulation in seconds */
	public double getSimulationSeconds()
	{
		return simulation_seconds;
	}

	/** @return Current time of simulation, "HH:MM:SS" */
    public String getSimulationTime()
    {
		double time = simulation_seconds;
		final long hours = (long) (time / (60*60));
		time -= hours * (60 * 60);
		final long minutes = (long) (time / 60);
		time -= minutes * 60;
		final long secs = (long) (time);<commit_msg>o.c.scan: Simulation config didn't work with plugin:// as path<commit_after>/*******************************************************************************
 * Copyright (c) 2012 Oak Ridge National Laboratory.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 ******************************************************************************/
package org.csstudio.scan.server;

import java.io.InputStream;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.csstudio.apputil.macros.MacroUtil;
import org.csstudio.scan.ScanSystemPreferences;
import org.csstudio.scan.device.ScanConfig;
import org.csstudio.scan.device.SimulatedDevice;
import org.csstudio.scan.server.internal.PathStreamTool;

/** Context used for the simulation of {@link ScanCommandImpl}
 *  @author <NAME>
 */
@SuppressWarnings("nls")
public class SimulationContext
{
	final private ScanConfig simulation_info;

    /** Macros for resolving device names */
    final private MacroContext macros;
	
	final private Map<String, SimulatedDevice> devices = new HashMap<String, SimulatedDevice>();

	final private PrintStream log_stream;

	private double simulation_seconds = 0.0;

	/** Initialize
	 *  @param log_stream Stream for simulation progress log
	 *  @throws Exception on error while initializing {@link SimulationInfo}
	 */
	public SimulationContext(final PrintStream log_stream) throws Exception
	{
        final InputStream config_stream = PathStreamTool.openStream(ScanSystemPreferences.getSimulationConfigPath());
	    this.simulation_info = new ScanConfig(config_stream);
        this.macros = new MacroContext(ScanSystemPreferences.getMacros());
		this.log_stream = log_stream;
	}

    /** @return Macro support */
    public MacroContext getMacros()
    {
        return macros;
    }

    /** @return Current time of simulation in seconds */
	public double getSimulationSeconds()
	{
		return simulation_seconds;
	}

	/** @return Current time of simulation, "HH:MM:SS" */
    public String getSimulationTime()
    {
		double time = simulation_seconds;
		final long hours = (long) (time / (60*60));
		time -= hours * (60 * 60);
		final long minutes = (long) (time / 60);
		time -= minutes * 60;
		final long secs = (long) (time);
{'fraction_non_alphanumeric': 0.15880102040816327, 'fraction_numerical': 0.00935374149659864, 'mean_word_length': 4.561465721040189, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7665525', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1248, 'n_words': 385}