private void button1_Click(object sender, EventArgs e) { //Connect as USB IBM HID mode m_pCoreScanner.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(M_pCoreScanner_BarcodeEvent); m_pCoreScanner.PNPEvent += new _ICoreScannerEvents_PNPEventEventHandler(M_pCoreScanner_PNPEvent); short[] m_arScannerTypes = new short[1]; bool[] m_arSelectedTypes = new bool[1]; for (int i = 0; i < 1; i++) { m_arSelectedTypes[i] = false; m_arScannerTypes[i] = 0; } m_arSelectedTypes[0] = true; m_arScannerTypes[0] = 1; //USB IBM HID int resultStatus = 1; //Fail Status short m_nNumberOfTypes = 1; m_pCoreScanner.Open(0, m_arScannerTypes, m_nNumberOfTypes, out resultStatus); if (resultStatus != 0) { Console.WriteLine("Scanner Open Failed"); return; } int nEvents = 2; string strEvtIDs = "1,16"; //subscribe_barcode, subscribe_pnp string inXml = "<inArgs>" + "<cmdArgs>" + "<arg-int>" + nEvents + "</arg-int>" + "<arg-int>" + strEvtIDs + "</arg-int>" + "</cmdArgs>" + "</inArgs>"; int opCode = 1001; //Register events string outXml = ""; resultStatus = 1; m_pCoreScanner.ExecCommand(opCode, ref inXml, out outXml, out resultStatus); //Call GetScanners Command again. short numOfScanners = 0; int[] scannerIdList = new int[1]; resultStatus = 1; m_pCoreScanner.GetScanners(out numOfScanners, scannerIdList, out outXml, out resultStatus); resultStatus = 1; inXml = "<inArgs>" + "<scannerID>" + 1 + "</scannerID>" + "</inArgs>"; opCode = 2019;// 5006; //Trigger On outXml = ""; m_pCoreScanner.ExecCommand(opCode, ref inXml, out outXml, out resultStatus); Console.WriteLine("result:{0}", resultStatus); Console.WriteLine(outXml); }
public void OpenScanner() { int opcode; string outXML; string inXML; //Instantiate CoreScanner Class cCoreScannerClass = new CCoreScannerClass(); //Call Open API short[] scannerTypes = new short[1]; //Scanner Types you are interested in scannerTypes[0] = 1; // 1 for all scanner types short numberOfScannerTypes = 1; // Size of the scannerTypes array int status; // Extended API return code cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status); opcode = 6000; // Method for Beep the beeper //outXML; // Output inXML = "<inArgs>" + "<scannerID>1</scannerID>" + // The scanner you need to beep "<cmdArgs>" + "<arg-int>43</arg-int>" + // 4 high short beep pattern "<arg-int>2</arg-int>" + "</cmdArgs>" + "</inArgs>"; cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status); opcode = 6000; // Method for Beep the beeper //outXML; // Output inXML = "<inArgs>" + "<scannerID>1</scannerID>" + // The scanner you need to beep "<cmdArgs>" + "<arg-int>7</arg-int>" + // 4 high short beep pattern "</cmdArgs>" + "</inArgs>"; cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status); opcode = 1001; // Method for Subscribe events //outXML; // XML Output inXML = "<inArgs>" + "<cmdArgs>" + "<arg-int>1</arg-int>" + // Number of events you want to subscribe "<arg-int>1</arg-int>" + // Comma separated event IDs "</cmdArgs>" + "</inArgs>"; cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status); cCoreScannerClass.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent); }
public BarcodeScanner(NetworkStream NSMain) { stream = NSMain; //Instantiate CoreScanner Class cCoreScannerClass = new CCoreScannerClass(); //Call Open API short[] scannerTypes = new short[1]; //Scanner Types you are interested in scannerTypes[0] = 1; // 1 for all scanner types short numberOfScannerTypes = 1; // Size of the scannerTypes array int status; // Extended API return code cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status); // Subscribe for barcode events in cCoreScannerClass cCoreScannerClass.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent); // Let's subscribe for events int opcode = 1001; // Method for Subscribe events string outXML; // XML Output string inXML = "<inArgs>" + "<cmdArgs>" + "<arg-int>1</arg-int>" + // Number of events you want to subscribe "<arg-int>1</arg-int>" + // Comma separated event IDs "</cmdArgs>" + "</inArgs>"; cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status); }
static void Main(string[] args) { /* Instatiate CoreScanner Class */ cCoreScannerClass = new CoreScanner.CCoreScannerClass(); //Call Open API short[] scannerTypes = new short[1]; // Scanner Types you are interested in scannerTypes[0] = 1; // 1 for all scanner types short numberOfScannerTypes = 1; // Size of the scannerTypes array int status; // Extended API return code cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status); /* Let's switch communication protocol */ int opcode = 6200; //Method for switch string outXML; //Output string inXml = "<inArgs>" + "<scannerID>1</scannerID>" + // The scanner you need "<cmdArgs>" + "<arg-string>XUA-45001-3</arg-string>" + //Target switch to SNAPI //Host Variant "<arg-bool>FALSE</arg-bool>" + //Silent Switch //Option "<arg-bool>FALSE</arg-bool>" + //Permanent //Change Option "</cmdArgs>" + "</inArgs>"; cCoreScannerClass.ExecCommand(opcode, ref inXml, out outXML, out status); }
private void button1_Click(object sender, EventArgs e) { try { cCoreScannerClass = new CCoreScannerClass(); //Call Open API short[] scannerTypes = new short[1]; //Scanner Types you are interested in scannerTypes[0] = 1; // 1 for all scanner types short numberOfScannerTypes = 1; // Size of the scannerTypes array int status; // Extended API return code cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status); // Subscribe for barcode events in cCoreScannerClass cCoreScannerClass.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent); // Let's subscribe for events int opcode = 6005; // Method for Subscribe events string outXML; // XML Output string inXML = "<inArgs>" + "<scannerID>1</scannerID>" + "<cmdArgs>" + "<arg-string>XUA-45001-11</arg-string>" + "<arg-int>1</arg-int>" + // Number of events you want to subscribe "<arg-int>0</arg-int>" + // Comma separated event IDs "</cmdArgs>" + "</inArgs>"; cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status); } catch (Exception exp) { Console.WriteLine("Something wrong please check... " + exp.Message); } }
public bool EnableBarcodeScanner() { int opCode = 2014; int status = 1; string inXml = "<inArgs>" + "<scannerID>1</scannerID>" + "</inArgs>"; string outXml = ""; cCoreScannerClass.ExecCommand(opCode, ref inXml, out outXml, out status); if (status == 1) { return(false); } else { return(true); } }
private void Form1_Load(object sender, EventArgs e) { try { cCoreScannerClass = new CoreScanner.CCoreScannerClass(); short[] scannerTypes = new short[1]; scannerTypes[0] = 1; short numberOfScannerTypes = 1; int status; cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status); cCoreScannerClass.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent); short numberOfScanners; int[] connectedScannerIDList = new int[10]; string outXML; cCoreScannerClass.GetScanners(out numberOfScanners, connectedScannerIDList, out outXML, out status); int opcode = 1001; string inXML = "<inArgs>" + "<cmdArgs>" + "<arg-int>1</arg-int>" + "<arg-int>1</arg-int>" + "</cmdArgs>" + "</inArgs>"; cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status); } catch (Exception exp) { msg.Text = exp.ToString(); } //cCoreScannerClass = new CoreScanner.CCoreScannerClass(); //short numberOfScanner; //int[] connectedScannerIDList = new int[10]; //string outXML; //cCoreScannerClass.GetScanners(out numberOfScanner, connectedScannerIDList, out outXML, out status); //msg.Text = outXML; //if (status == 0) //{ // msg.Text = "CoreScanner API: Open Successful"; // //Console.WriteLine("CoreScanner API: Open Successful"); //} //else //{ // msg.Text = "CoreScanner API: Open Failed"; // //Console.WriteLine("CoreScanner API: Open Failed"); //} }
private bool ExecCmd(int opCode, ref string inXml, out string outXml, out int status) { outXml = ""; status = STATUS_FALSE; if (m_bSuccessOpen) { try { m_pCoreScanner.ExecCommand(opCode, ref inXml, out outXml, out status); return(true); } catch (Exception ex) { DisplayResult(status, "EXEC_COMMAND"); UpdateResults("..." + ex.Message.ToString()); } } return(false); }
private static void beginListeningForEvents(CCoreScannerClass scannerInstance) { int status; int listenForEventsOpcode = 1001; string outXML; int numberOfEventsToListenFor = 2; string barcodeScanEvent = "1"; string plugAndPlayEvent = "16"; string inXML = "<inArgs>" + "<cmdArgs>" + "<arg-int>" + numberOfEventsToListenFor + "</arg-int>" + "<arg-int>" + barcodeScanEvent + "," + plugAndPlayEvent + "</arg-int>" + "</cmdArgs>" + "</inArgs>"; scannerInstance.ExecCommand(listenForEventsOpcode, ref inXML, out outXML, out status); }
public FormJobScanner() { InitializeComponent(); try { m_pCoreScanner = new CoreScanner.CCoreScannerClass(); } catch (Exception) { Thread.Sleep(1000); m_pCoreScanner = new CoreScanner.CCoreScannerClass(); } int status = 1; short[] m_arScannerTypes = new short[1]; m_arScannerTypes[0] = 1; short m_nNumberOfTypes = 1; m_pCoreScanner.Open(0, m_arScannerTypes, m_nNumberOfTypes, out status); m_pCoreScanner.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent); string inXml = "<inArgs>" + "<cmdArgs>" + "<arg-int>6</arg-int>" + "<arg-int>1,2,4,8,16,32</arg-int>" + "</cmdArgs>" + "</inArgs>"; string outXml = ""; status = 1; m_pCoreScanner.ExecCommand(1001, ref inXml, out outXml, out status); Debug.Print(" *** Status: " + status.ToString()); }
private void timer_Tick(object sender, EventArgs e) { cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status); }