sb.append(runCnt+1);
statusDiplayer.setText(sb.toString());
for (int i = 0; i < cmds.size(); i++) {
if(Thread.interrupted())
throw new StopRequestFromUserException("Operation cancelled by user.");
if (cmds.get(i).getClass().equals(Apdu.class)) {
lastApdu=playApdu((Apdu) cmds.get(i));
lastAtr=null;
}else if (cmds.get(i).getClass().equals(Integer.class)) {
Integer bufferId = (Integer) cmds.get(i);
if(null!=lastApdu)
buffers.put(bufferId, lastApdu);
else if(null!=lastAtr)
buffers.put(bufferId, lastAtr);
else
throw new ScardException("'Save to buffer' invoked but no ATR nor APDU to save");
} else if (cmds.get(i).getClass().equals(BufferOperation.class)) {
BufferOperation bufferOperation = (BufferOperation) cmds.get(i);
bufferOperation.perform(this);
} else if (cmds.get(i).getClass().equals(Frequency.class)) {
Frequency frequency = (Frequency) cmds.get(i);
if(playTerminal instanceof FrequencySetter){
FrequencySetter fs=(FrequencySetter) playTerminal;
fs.setFrequency(frequency.frequency);
}else
terminal.logLine(ScardLogHandler.LOG_WARNING,"Frequency specified in script but frequency setting is not supported with this terminal");
} else if (cmds.get(i).getClass().equals(PowerSupplyVoltage.class)) {
PowerSupplyVoltage power = (PowerSupplyVoltage) cmds.get(i);
if(playTerminal instanceof PowerSupplyVoltageSetter){
PowerSupplyVoltageSetter pss=(PowerSupplyVoltageSetter) playTerminal;
pss.setVoltage(power.voltage);
}else
terminal.logLine(ScardLogHandler.LOG_WARNING,"Voltage specified in script but voltage setting is not supported with this terminal");
} else if (cmds.get(i).getClass().equals(PcscPowerOn.class)) {
PcscPowerOn pcscPowerOn = (PcscPowerOn) cmds.get(i);
terminal.setNegociateComSpeed(true);
terminal.connect(pcscPowerOn.protocol, pcscPowerOn.activation);
lastAtr=terminal.getAtr();
lastApdu=null;
} else if (cmds.get(i).getClass().equals(PowerOn.class)) {
PowerOn powerOn = (PowerOn) cmds.get(i);
terminal.setNegociateComSpeed(false);
terminal.connect(powerOn.activation);
lastAtr=terminal.getAtr();
lastApdu=null;
} else if (cmds.get(i).getClass().equals(PowerOff.class)) {
terminal.disconnect();
} else if (cmds.get(i) instanceof CallBack) {
CallBack callBack = (CallBack) cmds.get(i);
callBack.execute(terminal);
lastAtr=terminal.getAtr();
lastApdu=null;
} else if (cmds.get(i).getClass().equals(DelayNs.class)) {
DelayNs delayNs=(DelayNs)cmds.get(i);
terminal.delay(delayNs.delayNs);
} else if (cmds.get(i).getClass().equals(ApduTimeoutPush.class)) {
ApduTimeoutPush timeout=(ApduTimeoutPush)cmds.get(i);
terminalTimeoutStack.push(terminal.getApduTimeout());
terminal.setApduTimeout(timeout.timeoutMs);
} else if (cmds.get(i).getClass().equals(ApduTimeout.class)) {
ApduTimeout timeout=(ApduTimeout)cmds.get(i);
terminal.setApduTimeout(timeout.timeoutMs);
} else if (cmds.get(i).getClass().equals(ApduTimeoutPop.class)) {
terminal.setApduTimeout(terminalTimeoutStack.pop());
} else if (cmds.get(i).getClass().equals(String.class)) {
String comment = (String) cmds.get(i);
terminal.logLine(ScardLogHandler.LOG_COMMENT,comment);
} else if (cmds.get(i).getClass().equals(ExpectedApduResponse.class)) {
ExpectedApduResponse expectedApduResponse = (ExpectedApduResponse) cmds.get(i);
buffers.put(expectedApduResponse.id, expectedApduResponse);
} else {
if (reportUnsupportedError) {
errorOccured=true;
String msg = "Runtime error: object ";
msg += cmds.get(i).getClass().getCanonicalName();
msg += " not supported. Action not performed."+nl+nl;
msg += "Ignore that kind of error ? (press Cancel to stop sequence)";
long start=System.nanoTime();
int choice = JOptionPane.showConfirmDialog(null, msg, "Runtime error", JOptionPane.YES_NO_CANCEL_OPTION);
deadTime+=System.nanoTime()-start;
if (JOptionPane.YES_OPTION == choice) {
reportUnsupportedError = false;
}
if (JOptionPane.CANCEL_OPTION == choice) {
userCancelled=false;
throw new StopRequestFromUserException("Operation cancelled by user.");
}
}
}
}
runCnt++;