public static CashUnit convertToCashUnit(WFSCDMCASHUNIT item) { CashUnit unit = new CashUnit(); unit.bAppLock = item.bAppLock; unit.cCurrencyID = item.cCurrencyID; unit.cUnitID = item.cUnitID; unit.szCashUnitName = item.szCashUnitName; unit.ulCount = item.ulCount; unit.ulInitialCount = item.ulInitialCount; unit.ulMaximum = item.ulMaximum; unit.ulMinimum = item.ulMinimum; unit.ulRejectCount = item.ulRejectCount; unit.ulValues = item.ulValues; unit.usNumber = item.usNumber; unit.usNumPhysicalCUs = item.usNumPhysicalCUs; unit.usStatus = item.usStatus; unit.usType = item.usType; if (item.usNumPhysicalCUs > 0) { unit.PhysicalCashUnits = XFSUtil.XFSPtrToArray <WFSCDMPHCU>(item.lppPhysical, item.usNumPhysicalCUs); } else { unit.PhysicalCashUnits = new WFSCDMPHCU[0]; } return(unit); }
public void Fill(object result) { var data = (WFSCIMSTATUS)result; this.fwDevice = data.fwDevice; this.fwIntermediateStacker = data.fwIntermediateStacker; this.fwSafeDoor = data.fwSafeDoor; this.lpszExtra = data.lpszExtra; this.fwAcceptor = data.fwAcceptor; this.fwStackerItems = data.fwStackerItems; this.fwBanknoteReader = data.fwBanknoteReader; this.bDropBox = data.bDropBox; var tmp = Activator.CreateInstance(typeof(WFSCIMOUTPOS)); XFSUtil.PtrToStructure(data.lppPositions, typeof(WFSCIMOUTPOS), ref tmp); try { this.lppPositions = new WFSCIMOUTPOS { fwPosition = ((WFSCIMOUTPOS)tmp).fwPosition, fwPositionStatus = ((WFSCIMOUTPOS)tmp).fwPositionStatus, fwShutter = ((WFSCIMOUTPOS)tmp).fwShutter, fwTransport = ((WFSCIMOUTPOS)tmp).fwTransport, fwTransportStatus = ((WFSCIMOUTPOS)tmp).fwTransportStatus }; } catch (Exception ex) { L4Logger.Error(ex); L4Logger.Info(string.Format("Device Result => {0} And PositionXfs {1} )", Newtonsoft.Json.JsonConvert.SerializeObject(tmp), data.lppPositions)); this.lppPositions = new WFSCIMOUTPOS(); } }
public void Fill(object result) { var data = (WFS_CDM_STATUS)result; this.dwGuidLights = data.dwGuidLights; this.fwDevice = data.fwDevice; this.fwDispenser = data.fwDispenser; this.fwIntermediateStacker = data.fwIntermediateStacker; this.fwSafeDoor = data.fwSafeDoor; this.lpszExtra = data.lpszExtra; this.usPowerSaveRecoveryTime = data.usPowerSaveRecoveryTime; this.wDevicePosition = data.wDevicePosition; var tmp = Activator.CreateInstance(typeof(WFS_CDM_OUTPOS)); XFSUtil.PtrToStructure(data.lppPositions, typeof(WFS_CDM_OUTPOS), ref tmp); try { this.lppPositions = new WFS_CDM_OUTPOS { fwPosition = ((WFS_CDM_OUTPOS)tmp).fwPosition, fwPositionStatus = ((WFS_CDM_OUTPOS)tmp).fwPositionStatus, fwShutter = ((WFS_CDM_OUTPOS)tmp).fwShutter, fwTransport = ((WFS_CDM_OUTPOS)tmp).fwTransport, fwTransportStatus = ((WFS_CDM_OUTPOS)tmp).fwTransportStatus }; } catch (Exception ex) { L4Logger.Error(ex); L4Logger.Info(string.Format("Device Result => {0} And PositionXfs {1} )", Newtonsoft.Json.JsonConvert.SerializeObject(tmp), data.lppPositions)); this.lppPositions = new WFS_CDM_OUTPOS(); } }
public static CashIn convertToCashIn(WFSCIMCASHIN item) { CashIn unit = new CashIn(); unit.usNumber = item.usNumber; unit.fwType = item.fwType; unit.cUnitID = item.cUnitID; unit.cCurrencyID = item.cCurrencyID; unit.ulValues = item.ulValues; unit.ulCashInCount = item.ulCashInCount; unit.ulCount = item.ulCount; unit.ulMaximum = item.ulMaximum; unit.usStatus = item.usStatus; unit.bAppLock = item.bAppLock; unit.usNumPhysicalCUs = item.usNumPhysicalCUs; if (item.usNumPhysicalCUs > 0) { unit.lppPhysical = XFSUtil.XFSPtrToArray <WFSCIMPHCU>(item.lppPhysical, item.usNumPhysicalCUs); } else { unit.lppPhysical = new WFSCIMPHCU[0]; } var notnumberList = new WFSCIMNOTENUMBERLIST(); XFSUtil.PtrToStructure <WFSCIMNOTENUMBERLIST>(item.lpNoteNumberList, ref notnumberList); unit.lpNoteNumberList = convertToNoteNumberList(notnumberList); unit.lpszExtra = item.lpszExtra; return(unit); }
protected override void OnExecuteEvent(ref WFSRESULT result) { switch (result.dwCommandCodeOrEventID) { case PINDefinition.WFS_EXEE_PIN_KEY: WFSPINKEY key = new XFSNet.PIN.WFSPINKEY(); XFSUtil.PtrToStructure(result.lpBuffer, ref key); OnPINKey(ref key); break; } }
public void Fill(object result) { var ptr = XFSUtil.StructureToPtr(result, typeof(WFSCIMCASHINFO)); var data = (CimCashInfoObject)this.UnMarshal(ptr); this.TerminalCode = data.TerminalCode; this.CashIns = data.CashIns; this.Checksum = data.Checksum; this.TransactionCode = data.TransactionCode; this.usCount = data.usCount; }
public IntPtr ToPopinter() { WFSCDMDENOMINATION param = new WFSCDMDENOMINATION { cCurrencyID = this.cCurrencyID, lpulValues = IntPtr.Zero, ulAmount = ulAmount, ulCashBox = this.ulCashBox, usCount = this.usCount }; return(XFSUtil.StructureToPtr(param, typeof(WFSCDMDENOMINATION))); }
public IntPtr ToPopinter() { WFSCDMDISPENSE param = new WFSCDMDISPENSE { bPresent = this.bPresent, fwPosition = this.fwPosition, lpDenomination = this.lpDenomination.ToPopinter(), usMixNumber = this.usMixNumber, usTellerID = this.usTellerID }; return(XFSUtil.StructureToPtr(param, typeof(WFSCDMDISPENSE))); }
public IntPtr Marshal(CimCashInfoObject cashInfo) { WFSCIMCASHINFO dto = new WFSCIMCASHINFO(); dto.usCount = cashInfo.usCount; WFSCIMCASHIN[] cashunitstructs = new WFSCIMCASHIN[cashInfo.CashIns.Length]; for (int i = 0; i < cashInfo.CashIns.Length; i++) { cashunitstructs[i] = CashIn.convertToWFSCIMCASHIN(cashInfo.CashIns[i]); } dto.lppCashIn = XFSUtil.XFSArrayToPTR <WFSCIMCASHIN>(cashunitstructs); return(XFSUtil.StructureToPtr <WFSCIMCASHINFO>(dto)); }
public IntPtr Marshal(CashInfoObject cashInfo) { WFS_CDM_CashUnit_INFO dto = new WFS_CDM_CashUnit_INFO(); dto.usCount = cashInfo.usCount; dto.usTellerID = cashInfo.TellerID; WFSCDMCASHUNIT[] cashunitstructs = new WFSCDMCASHUNIT[cashInfo.CashUnits.Length]; for (int i = 0; i < cashInfo.CashUnits.Length; i++) { cashunitstructs[i] = CashUnit.convertToWFSCDMCASHUNIT(cashInfo.CashUnits[i]); } dto.lppList = XFSUtil.XFSArrayToPTR <WFSCDMCASHUNIT>(cashunitstructs); return(XFSUtil.StructureToPtr <WFS_CDM_CashUnit_INFO>(dto)); }
public void ExcuteSiuCommand(int cmd, ServiceTypes serviceType) { WFSSIUSETGUIDLIGHT guidLight = new WFSSIUSETGUIDLIGHT(); var XFSDevice = XFS_DevicesCollection.Instance.GetValue(ServiceTypes.SIU); var GuidLightCtrl = GetGuidLights(serviceType); if (GuidLightCtrl != null) { guidLight.fwCommand = (LightControl)(ushort)cmd; guidLight.wGuidLight = (ushort)GetGuidLights(serviceType).Value; IntPtr ptr = XFSUtil.StructureToPtr(guidLight, typeof(WFSSIUSETGUIDLIGHT)); XFSDevice.ExecuteCommand(SIUDefinition.WFS_CMD_SIU_SET_GUIDLIGHT, ptr); Marshal.FreeHGlobal(ptr); } }
public void Fill(object result) { var data = (WFSBCRREADOUTPUT)result; WFSBCRPHEXDATA tmp = new WFSBCRPHEXDATA(); XFSUtil.PtrToStructure <WFSBCRPHEXDATA>(data.lpxBarcodeData, ref tmp); try { if (tmp.lpbData != null) { this.Value = XFSUtil.GetSeratedStringFromPointer(tmp.lpbData)[0]; } } catch { this.Value = string.Empty; } }
public Form1() { int p = XFSUtil.ParseVersionString("3.16", "3.20"); string s = p.ToString("X"); InitializeComponent(); Controls.Add(device); device.RegisterComplete += Device_RegisterComplete; device.RegisterError += Device_RegisterError; device.OpenError += Device_OpenError; //device.Open("IDCARDUNIT1"); pin.PINKey += Pin_PINKey; // pin.Open("PINPAD1"); cdm.DispenComplete += Cdm_DispenComplete; //cdm.Open("CURRENCYDISPENSER1"); siu.Open("SIU"); }
public static NoteNumberList convertToNoteNumberList(WFSCIMNOTENUMBERLIST item) { NoteNumberList noteNumberList = new NoteNumberList(); noteNumberList.usNumOfNoteNumbers = item.usNumOfNoteNumbers; if (item.usNumOfNoteNumbers > 0) { noteNumberList.lppNoteNumber = XFSUtil.XFSPtrToArray <WFSCIMNOTENUMBER>(item.lppNoteNumber, item.usNumOfNoteNumbers); } else { noteNumberList.lppNoteNumber = new WFSCIMNOTENUMBER[0]; } return(noteNumberList); }
protected override void OnExecuteComplete(ref WFSRESULT result) { switch (result.dwCommandCodeOrEventID) { case IDCDefinition.WFS_CMD_IDC_READ_RAW_DATA: if (result.hResult == XFSDefinition.WFS_SUCCESS) { WFSIDCCardData[] data = XFSUtil.XFSPtrToArray <WFSIDCCardData>(result.lpBuffer); IDCCardData[] outerData = new IDCCardData[data.Length]; for (int i = 0; i < data.Length; ++i) { outerData[i] = new IDCCardData(); outerData[i].DataSource = data[i].wDataSource; outerData[i].WriteMethod = data[i].fwWriteMethod; outerData[i].Status = data[i].wStatus; if (data[i].ulDataLength > 0) { outerData[i].Data = new byte[data[i].ulDataLength]; for (int j = 0; j < data[i].ulDataLength; ++j) { outerData[i].Data[j] = Marshal.ReadByte(data[i].lpbData, j); } } } OnReadRawDataComplete(outerData); } else { OnReadRawDataError(result.hResult); } break; case IDCDefinition.WFS_CMD_IDC_EJECT_CARD: if (result.hResult == XFSDefinition.WFS_SUCCESS) { OnEjectComplete(); } else { OnEjectError(result.hResult); } break; } }
public static WFSCIMCASHIN convertToWFSCIMCASHIN(CashIn cashUnit) { WFSCIMCASHIN dtoCashUnit = new WFSCIMCASHIN(); dtoCashUnit.usNumber = cashUnit.usNumber; dtoCashUnit.fwType = cashUnit.fwType; dtoCashUnit.fwItemType = cashUnit.fwItemType; dtoCashUnit.cUnitID = cashUnit.cUnitID; dtoCashUnit.cCurrencyID = cashUnit.cCurrencyID; dtoCashUnit.ulValues = cashUnit.ulValues; dtoCashUnit.ulCashInCount = cashUnit.ulCashInCount; dtoCashUnit.ulCount = cashUnit.ulCount; dtoCashUnit.ulMaximum = cashUnit.ulMaximum; dtoCashUnit.usStatus = cashUnit.usStatus; dtoCashUnit.bAppLock = cashUnit.bAppLock; dtoCashUnit.usNumPhysicalCUs = cashUnit.usNumPhysicalCUs; dtoCashUnit.lppPhysical = XFSUtil.XFSArrayToPTR <WFSCIMPHCU>(cashUnit.lppPhysical); return(dtoCashUnit); }
public ISTATUS UnMarshal(IntPtr pointer) { var cashinfoObj = new CimCashInfoObject(); var cashunitInfo = new WFSCIMCASHINFO(); XFSUtil.PtrToStructure <WFSCIMCASHINFO>(pointer, ref cashunitInfo); cashinfoObj.usCount = cashunitInfo.usCount; var cashUnits = XFSUtil.XFSPtrToArray <WFSCIMCASHIN>(cashunitInfo.lppCashIn, cashunitInfo.usCount); cashinfoObj.CashIns = new CashIn[cashUnits.Length]; for (int i = 0; i < cashUnits.Length; i++) { cashinfoObj.CashIns[i] = CashIn.convertToCashIn(cashUnits[i]); } return(cashinfoObj); }
protected IDCCardData[] OnReadRawDataComplete(IntPtr ptr) { WFSIDCCardData[] data = XFSUtil.XFSPtrToArray <WFSIDCCardData>(ptr); IDCCardData[] outerData = new IDCCardData[data.Length]; for (int i = 0; i < data.Length; ++i) { outerData[i] = new IDCCardData(); outerData[i].DataSource = data[i].wDataSource; outerData[i].WriteMethod = data[i].fwWriteMethod; outerData[i].Status = data[i].wStatus; if (data[i].ulDataLength > 0) { outerData[i].Data = new byte[data[i].ulDataLength]; for (int j = 0; j < data[i].ulDataLength; ++j) { outerData[i].Data[j] = Marshal.ReadByte(data[i].lpbData, j); } } } return(outerData); }
public static WFSCDMCASHUNIT convertToWFSCDMCASHUNIT(CashUnit cashUnit) { WFSCDMCASHUNIT dtoCashUnit = new WFSCDMCASHUNIT(); dtoCashUnit.bAppLock = cashUnit.bAppLock; dtoCashUnit.cCurrencyID = cashUnit.cCurrencyID; dtoCashUnit.cUnitID = cashUnit.cUnitID; dtoCashUnit.szCashUnitName = cashUnit.szCashUnitName; dtoCashUnit.ulCount = cashUnit.ulCount; dtoCashUnit.ulInitialCount = cashUnit.ulInitialCount; dtoCashUnit.ulMaximum = cashUnit.ulMaximum; dtoCashUnit.ulMinimum = cashUnit.ulMinimum; dtoCashUnit.ulRejectCount = cashUnit.ulRejectCount; dtoCashUnit.ulValues = cashUnit.ulValues; dtoCashUnit.usNumber = cashUnit.usNumber; dtoCashUnit.usNumPhysicalCUs = cashUnit.usNumPhysicalCUs; dtoCashUnit.usStatus = cashUnit.usStatus; dtoCashUnit.usType = cashUnit.usType; dtoCashUnit.lppPhysical = XFSUtil.XFSArrayToPTR <WFSCDMPHCU>(cashUnit.PhysicalCashUnits); return(dtoCashUnit); }
public ISTATUS UnMarshal(IntPtr pointer) { var cashinfoObj = new CashInfoObject(); var cashunitInfo = new WFS_CDM_CashUnit_INFO(); XFSUtil.PtrToStructure <WFS_CDM_CashUnit_INFO>(pointer, ref cashunitInfo); cashinfoObj.TellerID = cashunitInfo.usTellerID; cashinfoObj.usCount = cashunitInfo.usCount; var cashUnits = XFSUtil.XFSPtrToArray <WFSCDMCASHUNIT>(cashunitInfo.lppList, cashunitInfo.usCount); cashinfoObj.CashUnits = new CashUnit[cashUnits.Length]; for (int i = 0; i < cashUnits.Length; i++) { cashinfoObj.CashUnits[i] = CashUnit.convertToCashUnit(cashUnits[i]); } return(cashinfoObj); }
private void XFSDevice_ExecuteComplete(ServiceTypes serviceType, IntPtr obj, int EventID) { try { lock (syncObject) { if (obj == IntPtr.Zero) { XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.IsExecuteSuccessfully = true; XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.Detail = "XFSDevice_ExecuteComplete"; var XfsCommand = (XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.XfsCommand as ExecuteCommand); if (XfsCommand != null && XfsCommand.LightControlCommand != null) { ExcuteSiuCommand(XfsCommand.LightControlCommand.CompleteSIU, serviceType); } SendResponse(XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand); return; } else { XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.IsExecuteSuccessfully = true; #region old //switch (EventID) //{ // case IDCDefinition.WFS_CMD_IDC_READ_RAW_DATA: // { // //(CurrentCommand.XfsCommand as ExecuteCommand).Result = Activator.CreateInstance((CurrentCommand.XfsCommand as ExecuteCommand).ResultType); // var resobj = OnReadRawDataComplete(obj); // if(resobj.Length==0) // { // XFSDevice_ExecuteError(serviceType, "", -500, "-500"); // return; // } // (XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.XfsCommand as ExecuteCommand).ResultModel = resobj; // break; // } // default: // { // break; // } //} #endregion XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.Detail = "XFSDevice_ExecuteComplete"; var XfsCommand = (XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.XfsCommand as ExecuteCommand); if ((XfsCommand.ResultXfs.GetType().Name.Equals("JArray"))) { int len = 0; var data = XFSUtil.XFSPtrToArray(obj, XfsCommand.ResultXfsType, ref len); var model = Array.CreateInstance(XfsCommand.ResultModelType, len); for (int i = 0; i < len; ++i) { var tmp = (IXfsResultModel)Activator.CreateInstance(XfsCommand.ResultModelType); tmp.Fill(data.GetValue(i)); model.SetValue(tmp, i); } XfsCommand.ResultModel = model; } else { object data = null; XFSUtil.PtrToStructure(obj, XfsCommand.ResultXfsType, ref data); var model = (IXfsResultModel)Activator.CreateInstance(XfsCommand.ResultModelType); model.Fill(data); XfsCommand.ResultModel = model; } if (XfsCommand != null && XfsCommand.LightControlCommand != null) { ExcuteSiuCommand(XfsCommand.LightControlCommand.CompleteSIU, serviceType); } SendResponse(XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand); } } } catch (Exception ex) { L4Logger.Error(ex); } }
protected override void OnMessage(MessageEventArgs e) { lock (syncObject) { try { L4Logger.Info("XfsCommandBehavior WebSocket_OnMessage => " + e.Data); JObject Parametrs = JObject.Parse(e.Data); var CommandType = (CommandType)Enum.ToObject(typeof(CommandType), int.Parse((string)Parametrs["CommandType"])); switch (CommandType) { case CommandType.Init: { //var Command = JsonConvert.DeserializeObject<XfsCommandBase<i>>(e.Data); //CurrentCommand = new XfsCommandBase<IXfsCommand> //{ // CommandType = Command.CommandType, // XfsCommand = Command.XfsCommand, // IsExecuteSuccessfully = Command.IsExecuteSuccessfully, // ServiceType = Command.ServiceType //}; //var XFSDevice = AddOrGetServiceBase(Command); //XFSDevice.OpenComplete += XFSDevice_OpenComplete; //XFSDevice.OpenError += XFSDevice_OpenError; //XFSDevice.RegisterComplete += XFSDevice_RegisterComplete; //XFSDevice.RegisterError += XFSDevice_RegisterError; break; } case CommandType.Open: { var Command = JsonConvert.DeserializeObject <XfsCommandBase <OpenCommand> >(e.Data); var XFSDevice = XFS_DevicesCollection.Instance.GetValue(Command.ServiceType); XFSDevice.ResetEvents(); XFSDevice.CurrentCommand = new XfsCommandBase <XfsCommand> { CommandType = CommandType.Open, XfsCommand = Command.XfsCommand, IsExecuteSuccessfully = Command.IsExecuteSuccessfully, ServiceType = Command.ServiceType }; XFSDevice.OpenComplete -= XFSDevice_OpenComplete; XFSDevice.OpenError -= XFSDevice_OpenError; XFSDevice.RegisterComplete -= XFSDevice_RegisterComplete; XFSDevice.RegisterError -= XFSDevice_RegisterError; XFSDevice.CancelComplete -= XFSDevice_CancelComplete; XFSDevice.CancelError -= XFSDevice_CancelError; XFSDevice.ExecuteComplete -= XFSDevice_ExecuteComplete; XFSDevice.ExecuteCompleteError -= XFSDevice_ExecuteCompleteError; XFSDevice.ExecuteEvent -= XFSDevice_ExecuteEvent; XFSDevice.OpenComplete += XFSDevice_OpenComplete; XFSDevice.OpenError += XFSDevice_OpenError; XFSDevice.RegisterComplete += XFSDevice_RegisterComplete; XFSDevice.RegisterError += XFSDevice_RegisterError; XFSDevice.CancelComplete += XFSDevice_CancelComplete; XFSDevice.CancelError += XFSDevice_CancelError; XFSDevice.ExecuteComplete += XFSDevice_ExecuteComplete; XFSDevice.ExecuteCompleteError += XFSDevice_ExecuteCompleteError; XFSDevice.ExecuteEvent += XFSDevice_ExecuteEvent; if (Command.XfsCommand.AcceptEvents != null) { XFSDevice.eventHandlers.Clear(); XFSDevice.eventHandlers.AddRange(Command.XfsCommand.AcceptEvents); } XFSDevice.Open(Command.XfsCommand.ServiceName); break; } case CommandType.Cancel: { XfsCommandBase <CancellCommand> Command = JsonConvert.DeserializeObject <XfsCommandBase <CancellCommand> >(e.Data); var XFSDevice = XFS_DevicesCollection.Instance.GetValue(Command.ServiceType); XFSDevice.CurrentCommand = new XfsCommandBase <XfsCommand> { CommandType = CommandType.Cancel, XfsCommand = Command.XfsCommand, IsExecuteSuccessfully = Command.IsExecuteSuccessfully, ServiceType = Command.ServiceType }; XFSDevice.Cancel(); break; } case CommandType.Getinfo: { try { XfsCommandBase <GetInfoCommand> Command = JsonConvert.DeserializeObject <XfsCommandBase <GetInfoCommand> >(e.Data); var XFSDevice = XFS_DevicesCollection.Instance.GetValue(Command.ServiceType); L4Logger.Info("Start get info for " + Command.ServiceType); XFSDevice.CurrentCommand = new XfsCommandBase <XfsCommand> { CommandType = CommandType.Getinfo, XfsCommand = Command.XfsCommand, IsExecuteSuccessfully = Command.IsExecuteSuccessfully, ServiceType = Command.ServiceType }; L4Logger.Info("call GetStatus"); var obj = (ISTATUS)Activator.CreateInstance(Command.XfsCommand.StatusType); XFSDevice.GetStatus(out obj, Command.XfsCommand.CommandCode, Command.XfsCommand.StatusType); L4Logger.Info(" Fill info data"); Command.XfsCommand.Status = obj; if (Command.XfsCommand.StatusTypeModel != null) { var model = (IXfsResultModel)Activator.CreateInstance(Command.XfsCommand.StatusTypeModel); model.Fill(obj); Command.XfsCommand.StatusModel = model; } L4Logger.Info("Call to send"); Command.IsExecuteSuccessfully = true; SendResponse(Command); } catch (Exception ex) { L4Logger.Error(ex); } break; } case CommandType.Execute: { XfsCommandBase <ExecuteCommand> Command = JsonConvert.DeserializeObject <XfsCommandBase <ExecuteCommand> >(e.Data); var XFSDevice = XFS_DevicesCollection.Instance.GetValue(Command.ServiceType); XFSDevice.CurrentCommand = new XfsCommandBase <XfsCommand> { CommandType = CommandType.Execute, XfsCommand = Command.XfsCommand, IsExecuteSuccessfully = Command.IsExecuteSuccessfully, ServiceType = Command.ServiceType }; if (Command.XfsCommand.CancelLastCommand) { XFSDevice.Cancel(false); } //unsafe { List <int> AcceptEvents = new List <int>(); if (Command.XfsCommand.AcceptEvents != null) { AcceptEvents.AddRange(Command.XfsCommand.AcceptEvents); } if (Command.XfsCommand.Events != null) { XFSDevice.eventHandlers.Clear(); XFSDevice.GlobalEvents.Clear(); XFSDevice.eventHandlers.AddRange(AcceptEvents); Command.XfsCommand.Events.ForEach(Event => { XFSDevice.eventHandlers.Add(Event.EventId); if (Event.IsGlobalEvent) { XFSDevice.GlobalEvents.Add(new Wrapper.Common.XFSDeviceBase.GlobalEvent { EventId = Event.EventId, EventParam = Event.EventParam, EventParamType = Event.EventParamType }); } }); } else { XFSDevice.eventHandlers.Clear(); XFSDevice.GlobalEvents.Clear(); XFSDevice.eventHandlers.AddRange(AcceptEvents); } XFSDevice.commandHandlers.Add(Command.XfsCommand.CommandCode); IntPtr cmdPtr = IntPtr.Zero; if (Command.XfsCommand.ParamModel != null) { //var objModel = Activator.CreateInstance(Command.XfsCommand.ParamModelType); var param = XFSUtil.Cast(Command.XfsCommand.ParamModel, Command.XfsCommand.ParamModelType); cmdPtr = (param as IXfsModel).ToPopinter(); } else { cmdPtr = XFSUtil.StructureToPtr(Command.XfsCommand.Param, Command.XfsCommand.PramType); } int hResult = XFSDevice.ExecuteCommand( Command.XfsCommand.CommandCode, cmdPtr, XFSDevice_ExecuteError); Marshal.FreeHGlobal(cmdPtr); if (hResult == XFS4NET.Model.Common.XFSDefinition.WFS_SUCCESS) { if (Command.XfsCommand.LightControlCommand != null) { ExcuteSiuCommand(Command.XfsCommand.LightControlCommand.ExecuteSIU, Command.ServiceType); } else { } } } break; } } } catch (Exception ex) { L4Logger.Error(ex); } } }
private void XFSDevice_ExecuteEvent(ServiceTypes serviceType, int EventID, IntPtr obj) { L4Logger.Info("XFSDevice_ExecuteEvent"); lock (syncObject) { try { var math = XFS_DevicesCollection.Instance.GetValue(serviceType).GlobalEvents.FirstOrDefault(c => c.EventId == EventID); if (math != null) { L4Logger.Info("Global Event Reaised"); object res = null; res = Activator.CreateInstance(math.EventParamType); XFSUtil.PtrToStructure(obj, math.EventParamType, ref res); ExecuteEventBase eventBase = new ExecuteEventBase { EventID = EventID, EventParam = res, EventParamType = math.EventParamType }; SendResponse(eventBase); } else if (XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.XfsCommand is ExecuteCommand) { L4Logger.Info("Command Event Reaised"); var cmnd = (XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.XfsCommand as ExecuteCommand); object res = null; if (cmnd != null && cmnd.EventParamType != null) { L4Logger.Info("Event hass response model"); res = Activator.CreateInstance(cmnd.EventParamType); XFSUtil.PtrToStructure(obj, cmnd.EventParamType, ref res); ExecuteEventBase eventBase = new ExecuteEventBase { EventID = EventID, EventParam = res, EventParamType = cmnd.EventParamType }; SendResponse(eventBase); } else if (cmnd.EventParamType == null) { L4Logger.Info("Event not model"); ExecuteEventBase eventBase = new ExecuteEventBase { EventID = EventID, EventParam = null, EventParamType = null }; SendResponse(eventBase); } } else { L4Logger.Info("Un categoriezd Event"); ExecuteEventBase eventBase = new ExecuteEventBase { EventID = EventID, EventParam = null, EventParamType = null }; SendResponse(eventBase); } } catch (Exception ex) { } } }
private void ParsCommand(XfsCommandBase <object> commandBase) { switch (commandBase.CommandType) { case CommandType.Execute: { blockingQueue.Clear(); var cmnd = JsonConvert.DeserializeObject <ExecuteCommand>(JsonConvert.SerializeObject(commandBase.XfsCommand)); if (commandBase.IsExecuteSuccessfully) { if (cmnd.CommandCode == BCRDefinition.WFS_CMD_BCR_READ) { blockingQueue.Clear(); try { var data = XFSUtil.Cast <BarcodeData[]>(cmnd.ResultModel)[0].Value; ReadDataCompleted?.Invoke(data); } catch (Exception ex) { L4Logger.Error(ex); //MediaError.Invoke(); } } } else { if (commandBase.ErrorCode == XFSDefinition.WFS_ERR_CANCELED) { return; } if (cmnd.CommandCode == BCRDefinition.WFS_CMD_BCR_READ) { ReadDataError?.Invoke("BCR", commandBase.ErrorCode, commandBase.ErrorCode.ToString()); //if (workingMode == WorkingMode.None || workingMode == WorkingMode.EjectCard) // return; //else // ReadRawDataError?.Invoke("IDC", commandBase.ErrorCode, commandBase.ErrorCode.ToString()); //workingMode = WorkingMode.None; } } break; } case CommandType.Open: { var cmnd = JsonConvert.DeserializeObject <OpenCommand>(JsonConvert.SerializeObject(commandBase.XfsCommand)); if (commandBase.IsExecuteSuccessfully) { if (commandBase.Detail.Equals("XFSDevice_OpenComplete")) { IsOpenned = true; OpenCompleted?.Invoke(); } if (commandBase.Detail.Equals("XFSDevice_RegisterComplete")) { RegisterCompleted?.Invoke(); } } else { if (commandBase.Detail.Equals("XFSDevice_OpenError")) { IsOpenned = false; OpenError?.Invoke(commandBase.ErrorCode); } if (commandBase.Detail.Equals("XFSDevice_RegisterError")) { RegisterError?.Invoke(commandBase.ErrorCode); } } break; } case CommandType.Getinfo: { var cmnd = JsonConvert.DeserializeObject <GetInfoCommand>(JsonConvert.SerializeObject(commandBase.XfsCommand)); GetInfoResponse?.Invoke(XFSUtil.Cast <WFSBCRSTATUS>(cmnd.Status), null); break; } } }