/// <summary> /// Process the parameters of a Sequence. If a parameter of the same name is found in the list of parameters /// it overrides the XML parameter of the sequence /// </summary> /// <param name="seqParam">List of parameters</param> /// <param name="xmlSeqParam">Parameters of the XML sequence</param> /// <returns>The list of parameters to used to process the sequence of APDU commands</returns> private SequenceParameter ProcessParams(SequenceParameter seqParam, XmlAttributeCollection xmlSeqParam) { //Dictionary<string, string> l_seqParam = new Dictionary<string, string>(); SequenceParameter l_seqParam = new SequenceParameter(); int nNbParam = xmlSeqParam.Count; for (int nI = 0; nI < nNbParam; nI++) { XmlNode xNode = xmlSeqParam.Item(nI); string name = xNode.Name; string val = xNode.Value; // Check if a val overrides the XML parameter of Sequence if (seqParam != null) { try { val = seqParam[name]; } catch { } } l_seqParam.Add(name, val); } return(l_seqParam); }
/// <summary> /// Process an APDU sequence and execute each of its commands in the sequence order /// </summary> /// <param name="apduSequenceName">Name of the sequence to play</param> /// <param name="seqParam">An array of SequenceParam object used as parameters for the sequence</param> /// <returns>APDUResponse object of the last command executed</returns> //public APDUResponse ProcessSequence(string apduSequenceName, Dictionary<string, string> seqParam) public APDUResponse ProcessSequence(string apduSequenceName, SequenceParameter seqParam) { APDUResponse apduResp = null; //Dictionary<string, string> l_seqParam = null; SequenceParameter l_seqParam = null; // Get the sequence XmlNode apduSeq = SequenceByName(apduSequenceName); if (apduSeq == null) { throw new ApduCommandException(ApduCommandException.NoSuchSequence); } // Process the params of the sequence l_seqParam = ProcessParams(seqParam, apduSeq.Attributes); // Get the list of commands to execute XmlNodeList xmlCmdList = apduSeq.ChildNodes; for (int nI = 0; nI < xmlCmdList.Count; nI++) { apduResp = ProcessSeqCmd(xmlCmdList.Item(nI), l_seqParam); } return(apduResp); }
public static void CreateTargets(SequenceParameter parameter) { targets = new GameObject[parameter.nbOfTarget]; CreateDetectionPlane(); for (int i = 0; i < parameter.nbOfTarget; i++) { targets[i] = CreateTarget(parameter, i); } SetInitialTarget(); }
private static GameObject CreateTarget(SequenceParameter parameter, int circleIndex) { GameObject target = Instantiate(Resources.Load(BLENDER_TARGET_PREFAB) as GameObject, initialCameraPosition + Vector3.forward * distanceToTarget, Quaternion.identity); target.transform.position += FindCircleCoordinate(circleIndex, parameter.amplitude, parameter.nbOfTarget); // Apply width chosen in the fitts test target.transform.localScale *= parameter.width; return(target); }
/// <summary> /// Process a command of a sequence of APDU /// </summary> /// <param name="xmlCmd">XML node representing the command</param> /// <param name="seqParam">List of parameters of the sequence</param> /// <returns>APDUResponse object of command executed</returns> // private APDUResponse ProcessSeqCmd(XmlNode xmlCmd, Dictionary<string, string> seqParam) private APDUResponse ProcessSeqCmd(XmlNode xmlCmd, SequenceParameter seqParam) { bool bApdu = false; bool bSeq = false; string sApduName = null; string sSeqName = null; APDUResponse apduResp = null; // Get the APDU or Sequence name try { // Get the Apdu name to run sApduName = xmlCmd.Attributes[xmlAttrApdu].Value; bApdu = true; } catch { } finally { try { sSeqName = xmlCmd.Attributes[xmlAttrSequence].Value; bSeq = true; } catch { } if ((bSeq | bApdu) == false) { throw new ApduCommandException(ApduCommandException.MissingApduOrCommand); } } if (bApdu) { APDUParam apduParams = BuildCommandParam(xmlCmd.Attributes, seqParam); apduResp = ProcessCommand(sApduName, apduParams); } if (bSeq) { // Process a sub sequence apduResp = ProcessSequence(sSeqName, seqParam); } return(apduResp); }
static void Main(string[] args) { try { int nbRecords = 10; string PIN = "31323334FFFFFFFF"; bool bPin = false; if (args.Length != 0) { for (int nI = 0; nI < args.Length; nI++) { if (args[nI] == "P") { bPin = true; PIN = FormatPIN(args[++nI]); } else { nbRecords = int.Parse(args[nI]); } } } APDUResponse apduResp = null; CardNative iCard = new CardNative(); string[] readers = iCard.ListReaders(); iCard.Connect(readers[0], SHARE.Shared, PROTOCOL.T0orT1); APDUPlayer player = new APDUPlayer(iCard); player.LoadAPDUFile(Properties.Settings.Default.DataPath + ApduFile); player.LoadSequenceFile(Properties.Settings.Default.DataPath + SequenceFile); SequenceParameter seqParam = new SequenceParameter(); // Process Apdu: VerifyCHV if (bPin) { Console.WriteLine("Sequence: Verify CHV1"); seqParam.Add("PIN", PIN); apduResp = player.ProcessSequence("Verify CHV1", seqParam); Console.WriteLine(apduResp.ToString()); } if (!bPin || (bPin && apduResp.Status == 0x9000)) { for (int nI = 1; nI <= nbRecords; nI++) { seqParam.Clear(); seqParam.Add("Record", nI.ToString()); //Console.WriteLine(string.Format("Read ADN, Record={0}", nI)); apduResp = player.ProcessSequence("Read ADN", seqParam); PhoneNumber phone = new PhoneNumber(apduResp.Data); Console.WriteLine("ADN n°" + nI.ToString()); Console.WriteLine(phone.ToString()); Console.WriteLine(); //Console.WriteLine(apduResp.ToString()); } } APDULogList log = player.Log; Console.WriteLine("Log:"); APDULog[] arrayLog = log.ToArray(); for (int nI = 0; nI < log.Count; nI++) { Console.WriteLine(arrayLog[nI].ToString()); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
static void Main(string[] args) { try { int nbRecords = 10; string PIN = "31323334FFFFFFFF"; bool bPin = false; if (args.Length != 0) { for (int nI = 0; nI < args.Length; nI++) { if (args[nI] == "P") { bPin = true; PIN = FormatPIN(args[++nI]); } else nbRecords = int.Parse(args[nI]); } } APDUResponse apduResp = null; CardNative iCard = new CardNative(); string[] readers = iCard.ListReaders(); iCard.Connect(readers[0], SHARE.Shared, PROTOCOL.T0orT1); APDUPlayer player = new APDUPlayer(iCard); player.LoadAPDUFile(Properties.Settings.Default.DataPath + ApduFile); player.LoadSequenceFile(Properties.Settings.Default.DataPath + SequenceFile); SequenceParameter seqParam = new SequenceParameter(); // Process Apdu: VerifyCHV if (bPin) { Console.WriteLine("Sequence: Verify CHV1"); seqParam.Add("PIN", PIN); apduResp = player.ProcessSequence("Verify CHV1", seqParam); Console.WriteLine(apduResp.ToString()); } if (!bPin || (bPin && apduResp.Status == 0x9000)) { for (int nI = 1; nI <= nbRecords; nI++) { seqParam.Clear(); seqParam.Add("Record", nI.ToString()); //Console.WriteLine(string.Format("Read ADN, Record={0}", nI)); apduResp = player.ProcessSequence("Read ADN", seqParam); PhoneNumber phone = new PhoneNumber(apduResp.Data); Console.WriteLine("ADN n°" + nI.ToString()); Console.WriteLine(phone.ToString()); Console.WriteLine(); //Console.WriteLine(apduResp.ToString()); } } APDULogList log = player.Log; Console.WriteLine("Log:"); APDULog[] arrayLog = log.ToArray(); for (int nI = 0; nI < log.Count; nI++) Console.WriteLine(arrayLog[nI].ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Builds an APDUParam object from the parameters of a command and a set of parameter for a sequence /// </summary> /// <param name="xmlAttrs">List of parameters of the APDU</param> /// <param name="seqParam">List of parameters of the sequence</param> /// <returns>APDUParam object</returns> private APDUParam BuildCommandParam(XmlAttributeCollection xmlAttrs, SequenceParameter seqParam) { APDUParam apduParam = null; string sVal = null; apduParam = new APDUParam(); for (int nI = 0; nI < xmlAttrs.Count; nI++) { XmlNode xmlParam = xmlAttrs.Item(nI); switch (xmlParam.Name) { case xmlAttrP1: { try { sVal = seqParam[xmlParam.Value]; } catch { sVal = xmlParam.Value; } finally { apduParam.P1 = byte.Parse(sVal, NumberStyles.AllowHexSpecifier); } break; } case xmlAttrP2: { try { sVal = seqParam[xmlParam.Value]; } catch { sVal = xmlParam.Value; } finally { apduParam.P2 = byte.Parse(sVal, NumberStyles.AllowHexSpecifier); } break; } case xmlAttrData: { try { sVal = seqParam[xmlParam.Value]; } catch { sVal = xmlParam.Value; } finally { apduParam.Data = ByteArray.Parse(sVal); } break; } } } return(apduParam); }