List<File> logFiles = null;
StdParams params;
public void nimpSmartCardShell(String[] args) throws FileNotFoundException, IOException, InterruptedException, ScardException, ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
long start = System.nanoTime();
ATextScreenOutputJFrame mainWindow;
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
final SplashScreen splash = SplashScreen.getSplashScreen();
PipedOutputStream pos = new PipedOutputStream();
PrintStream outputStream = new PrintStream(pos);
mainWindow = new ATextScreenOutputJFrame(true);
mainWindow.monitorStream(pos);
mainWindow.setTitle(ATimeUtilities.getTimeForUi() + " - Nimp smart card script player");
System.setOut(outputStream);
System.setErr(outputStream);
if (splash != null) {
splash.close();
}
mainWindow.setExtendedState(JFrame.MAXIMIZED_BOTH);
mainWindow.setBackground(mainWindow.getBackground());//this get the system color for window background and apply it to the log area
mainWindow.setVisible(true);
ACommandLineUtilities.dispArgs(args);
ACommandLineUtilities clUtil = null;
try {
List<GenericTerminal> availableTerminals = new LinkedList<GenericTerminal>();
ArgSpec argSpecs[] = {
new ArgSpec(ARG_PARALLEL_MODE, ARG_PARALLEL_MODE_ID),
new ArgSpec(ARG_CHECK_CARD_CONNECTION, ARG_CHECK_CARD_CONNECTION_ID)
};
//params = processStdArgs(args, argSpecs, Main.class, "NimpSmartCardScriptPlayer");
ArgSpec internalArgSpecs[] = addStdArgSpecs(argSpecs);
//internalArgSpecs = ACommandLineUtilities.addArgFileArgSpecs(internalArgSpecs);
Set specs = ACommandLineUtilities.addArgFileArgSpecs(internalArgSpecs);
internalArgSpecs = new ArgSpec[specs.size()];
specs.toArray(internalArgSpecs);
ConfigArgProcessor configArgProcessor = new ConfigArgProcessor(Main.class, "NimpSmartCardScriptPlayer");
clUtil = new ACommandLineUtilities(new File(AFileUtilities.getCurrentDirectory()), args, internalArgSpecs, configArgProcessor, true);
clUtil.processArgs();
clUtil.setAllowUnprocessedArgs(false);
clUtil.throwIfError();
params = configArgProcessor.getStdParams();
//params.args = clUtil.getArgsAsArray();
params.args=null;
getAvailableTerminals(params.terminalManagers, availableTerminals);
if (0 == availableTerminals.size()) {
printNoTerminalMessage(params.terminalManagers);
//throw new RuntimeException();
error = new RuntimeException();
return;
}
try {
long startOfTerminalChooser = System.nanoTime();
selectedTerminals = new LinkedList<GenericTerminal>();
players = new LinkedList<ScriptPlayer>();
errors = new LinkedList<Boolean>();
logFiles = new LinkedList<File>();
if (clUtil.hasArg(ARG_PARALLEL_MODE)) {
StringBuilder sb = new StringBuilder("Cards detected in following readers:\n");
StringBuilder terminalNames = new StringBuilder();
for (GenericTerminal terminal : availableTerminals) {
if (terminal.isCardPresent()) {
selectedTerminals.add(terminal);
players.add(new ScriptPlayer());
errors.add(Boolean.FALSE);
logFiles.add(null);
terminalNames.append("\t- ");
terminalNames.append(terminal.getName());
terminalNames.append("\n");
}
}
if (0 == selectedTerminals.size()) {
System.out.println("Could not find any card.");
mainWindow.setBackground(Color.red);
return;
}
if (clUtil.hasArg(ARG_FIXED_PARALLEL_MODE)) {
String nTerminalsStr = clUtil.getArgValue(ARG_FIXED_PARALLEL_MODE, null);