首页 > 其他分享 >ssts-hospital-web-master项目实战记录三十三:项目迁移-核心模块实现(useDeviceDriver-银行卡读卡器)

ssts-hospital-web-master项目实战记录三十三:项目迁移-核心模块实现(useDeviceDriver-银行卡读卡器)

时间:2024-03-16 18:55:51浏览次数:16  
标签:web return string useDeviceDriver ssts EventFunction Promise invokeMethod para

一、设备驱动模块实现

service/device-driver/ezware/function-ws/idc-motor-device.ts

import { EventFunctionType, EventResultType } from '@/types' import { EZMessageType, EZWebSocket } from './ez-web-socket'
class IdcMotor {   client: EZWebSocket   ObjName: string = 'CardReader'   LogicalName: string = 'aCardReader'   Device: string = 'IdcMotor'   EventFunction: EventFunctionType   EventResult: EventResultType
  constructor(     ezWebSocket: EZWebSocket,     globalEventFunction: EventFunctionType,     globalEventResult: EventResultType   ) {     this.client = ezWebSocket     this.EventFunction = globalEventFunction     this.EventResult = globalEventResult   }
  async setParams(name?: string, logicalName?: string) {     if (name) {       this.ObjName = name     }     if (logicalName) {       this.LogicalName = logicalName     }     await this.SetAttribute('LogicalName', this.LogicalName)   }   invokeMethod(method: string, paras: any[]): Promise<any> {     return this.client.send({       LogicalName: this.LogicalName,       Device: this.Device,       Method: method,       type: EZMessageType.method,       Params: paras     })   }
  // 方法   OpenConnection(): Promise<any> {     return this.invokeMethod('OpenConnection', [])   }   CloseConnection(): Promise<any> {     return this.invokeMethod('CloseConnection', [])   }   SetAttribute(key: string, value: any): Promise<any> {     this[key] = value     if (key === 'LogicalName') {       this.client.initPool[this.LogicalName] = this     }     return this.invokeMethod('SetAttribute', [key, value])   }   GetAttribute(key: string): any {     return this[key]   }   OpenConnectionAsync(): Promise<any> {     return this.invokeMethod('OpenConnectionAsync', [])   }   CloseConnectionAsync(): Promise<any> {     return this.invokeMethod('CloseConnectionAsync', [])   }   GetStatus(): Promise<any> {     return this.invokeMethod('GetStatus', [])   }   GetCapabilities(): Promise<any> {     return this.invokeMethod('GetCapabilities', [])   }   Reset(action: string): Promise<any> {     return this.invokeMethod('Reset', [action])   }   ResetAsync(action: string): Promise<any> {     return this.invokeMethod('ResetAsync', [action])   }   ReadRawData(track: string, timeout: number): Promise<any> {     return this.invokeMethod('ReadRawData', [track, timeout])   }   ReadRawDataAsync(track: string, timeout: number): Promise<any> {     return this.invokeMethod('ReadRawDataAsync', [track, timeout])   }   CancelReadRawData(): Promise<any> {     return this.invokeMethod('CancelReadRawData', [])   }   GetLastXfsErr(): Promise<any> {     return this.invokeMethod('GetLastXfsErr', [])   }   EjectCard(): Promise<any> {     return this.invokeMethod('EjectCard', [])   }   EjectCardAsync(): Promise<any> {     return this.invokeMethod('EjectCardAsync', [])   }   RetainCard(): Promise<any> {     return this.invokeMethod('RetainCard', [])   }   RetainCardAsync(): Promise<any> {     return this.invokeMethod('RetainCardAsync', [])   }   ResetCount(): Promise<any> {     return this.invokeMethod('ResetCount', [])   }   WriteRawData(trackinfo: string): Promise<any> {     return this.invokeMethod('WriteRawData', [trackinfo])   }   WriteRawDataAsync(trackinfo: string, timeout: null): Promise<any> {     return this.invokeMethod('WriteRawDataAsync', [trackinfo, timeout])   }   ChipIO(jsonChipIO: string): Promise<any> {     return this.invokeMethod('ChipIO', [jsonChipIO])   }   ChipIOAsync(jsonChipIO: string): Promise<any> {     return this.invokeMethod('ChipIOAsync', [jsonChipIO])   }   ChipPower(powerType: string): Promise<any> {     return this.invokeMethod('ChipPower', [powerType])   }   ChipPowerAsync(powerType: string): Promise<any> {     return this.invokeMethod('ChipPowerAsync', [powerType])   }
  // 事件   OpenConnectionComplete() {     this.EventFunction(this.ObjName + '_' + 'OpenConnectionComplete', null)   }   CloseConnectionComplete() {     this.EventFunction(this.ObjName + '_' + 'CloseConnectionComplete', null)   }   HWError(para: string) {     this.EventFunction(this.ObjName + '_' + 'HWError', para)   }   FatalError() {     this.EventFunction(this.ObjName + '_' + 'FatalError', null)   }   ReadRawDataComplete(para: string) {     this.EventFunction(this.ObjName + '_' + 'ReadRawDataComplete', para)   }   WriteRawDataComplete(para: string) {     this.EventFunction(this.ObjName + '_' + 'WriteRawDataComplete', para)   }   RetainCardComplete(para: string) {     this.EventFunction(this.ObjName + '_' + 'RetainCardComplete', para)   }   EjectCardComplete(para: string) {     this.EventFunction(this.ObjName + '_' + 'EjectCardComplete', para)   }   ChipPowerComplete(para: string) {     this.EventFunction(this.ObjName + '_' + 'ChipPowerComplete', para)   }   CardInserted() {     this.EventFunction(this.ObjName + '_' + 'CardInserted', null)   }   CardTaken() {     this.EventFunction(this.ObjName + '_' + 'CardTaken', null)   }   ResetComplete(para: string) {     this.EventFunction(this.ObjName + '_' + 'ResetComplete', para)   } }
export default IdcMotor    

二、调用示例

详见前文
ssts-hospital-web-master项目实战记录三十一:项目迁移-核心模块实现(useDeviceDriver&DeviceDriver)  

二、运行测试

翻译

搜索

复制

<iframe></iframe>

标签:web,return,string,useDeviceDriver,ssts,EventFunction,Promise,invokeMethod,para
From: https://www.cnblogs.com/lizhigang/p/18077428

相关文章

  • Python之Web开发中级教程----配置数据库
    Python之Web开发中级教程----配置数据库在settings.py中保存了数据库的连接配置信息,Django默认初始配置使用sqlite数据库。DATABASES={   'default':{       'ENGINE':'django.db.backends.sqlite3',       'NAME':os.path.join(BASE_DIR,'db.s......
  • 访问JavaWeb项目报405错误
     一、问题由来一位朋友最近在学习JavaWeb开发,做测试时出现问题,页面报了405错误,HTTPStatus405?MethodNotAllowed如果是只出现一次,那也还好。主要是这个错误他遇到过多次,第一次就是刚开始学习Servlet的时候,还有一次是在学习文件上传的时候出现的。因此就特意写一篇博......
  • 访问Webapp目录下面的html文件变为代码
    一、问题由来一位朋友最近在学习JavaWeb开发,使用Servlet做练习的时候,突然出现一个问题。他去访问自己创建的html文件时,发现返回的数据是html代码,而不是解析后的页面。很是疑惑,自己尝试着解决这个问题,很久都没有解决问题,然后就找到我。问题复现情况如下,正常来说,访问html页......
  • .Net WebApi中实现自动依赖注入的三种方法
    前言该文仅供学习参考,如有问题请指正。依赖关系注入(DI),是一种软件设计模式,这是一种在类及其依赖项之间实现控制反转(IoC)的技术。.NET中的依赖关系注入是框架的内置部分,与配置、日志记录和选项模式一样。生命周期依赖注入有以下三种生命周期瞬时(Transient):每次......
  • PHP解释器和Web服务器有什么关系?
    PHP解释器和Web服务器是非常好的朋友,它们经常一起工作来给我们展示网页上的内容。我们可以把它们的关系想象成一个餐厅里的厨师和服务员。PHP解释器是厨师在这个比喻里,PHP解释器就像是餐厅里的厨师。它的工作是准备食物,也就是处理PHP代码。当你访问一个用PHP编写的网页时,PHP......
  • PhpStudy让电脑秒变多站点Web服务器
    一直使用PhpStudy作为本地PHP开发环境,PhpStudy使配置服务器环境变得异常简单,彻底解放运维。确实和官网说的一样:“让天下没有难配的服务器环境”。1PhpStudy简介PhpStudy是一套专门为服务器环境提供极佳配置的解决方案。具有强大的功能和诸多优点:支持Windows、......
  • WEB三大组件之Filter
    在很多项目中通常需要用到filter来实现用户身份识别,并将识别出来的用户信息,保存到ThreadLocal对应的上下文,这样在后续的请求链路中,在任何地方都可以直接获取当前的登录用户了。来看一下JavaWEB三大组件之一的过滤器Filter,是如何在技术派中发挥作用的使用场景实现类路径:com/......
  • 深入了解WebAssembly:编译与测试指南
    在当今的Web开发中,WebAssembly(简称Wasm)作为一种新型的低级字节码格式,正在逐渐流行。它提供了一种高效的方式,使得在Web浏览器中运行性能密集型应用程序成为可能。这里我们将深入探讨如何编译和测试Wasm文件,以及相关的最佳实践和工具。1.WebAssembly简介: WebAssembly(Wasm)是一......
  • RestController:Spring Framework 中用于创建 RESTful Web 服务的注解
    RestController 是SpringFramework中用于创建RESTfulWeb服务的注解。它简化了构建RESTfulWeb服务的过程,使得开发者能够更专注于业务逻辑的实现,而不是底层的HTTP请求和响应处理。一、RestController的基本概念RestController 是SpringWeb模块中的一个核心注......
  • webrtc
    一、什么是WebRTCWebRTC(WebReal-TimeCommunication)是一个由Google、Mozilla、Opera等公司发起的开源项目,它支持网页浏览器进行实时音视频对话。它允许网络应用或者站点,在不借助中间媒介的情况下,建立浏览器之间点对点(Peer-to-Peer)的连接,实现视频流和音频流或者其他任意数据的传......