import 'dart:async'; import 'dart:convert'; import 'dart:typed_data'; import 'package:fis_common/json_convert.dart'; import '../client_base.dart'; import 'platform.m.dart'; /// 平台服务 class PlatformService extends JsonRpcClientBase { PlatformService( String host, { String serviceName = "IPlatformService", Map? headers, int? timeout, }) : super( host, serviceName, headers: headers, timeout: timeout, ) { /// 注册响应实体反序列化处理器 FJsonConvert.setDecoder((map) => LoadVidResult.fromJson(map)); FJsonConvert.setDecoder((map) => GetVidFrameResult.fromJson(map)); } /// 加载主题 Future loadTheme(String name) async { var rpcRst = await call("LoadTheme", name); return rpcRst; } /// 保存配置 /// /// [jsonText] 配置json文本 Future saveConfig(String jsonText) async { var rpcRst = await call("SaveConfig", jsonText); return rpcRst; } /// 获取配置 Future getConfig() async { var rpcRst = await call("GetConfig"); return rpcRst; } Future continueExcute(int targetMethod, String content) async { var rpcRst = await call("ContinueExcute", [targetMethod, content]); return rpcRst; } /// 保存文本文件 /// /// [name] 文件名 /// /// [text] 文本 Future saveText(String name, String text) async { var rpcRst = await call("SaveText", [name, text]); return rpcRst; } /// 获取文件文本 /// /// [name] 文件名 Future getText(String name) async { var rpcRst = await call("GetText", name); return rpcRst; } /// 获取文件文本 /// /// [name] 文件名 Future searchvBox() async { var rpcRst = await call("SearchvBox"); return rpcRst; } /// 加载Vid文件 /// /// [url] Vid文件链接 Future loadVid(String url) async { var rpcRst = await call("LoadVid", url); var result = LoadVidResult.fromJson(rpcRst as Map); return result; } /// 获取Vid单针帧图 Future getVidFrame(GetVidFrameRequest request) async { var rpcRst = await call("GetVidFrame", request); var result = GetVidFrameResult.fromJson(rpcRst as Map); return result; } /// 释放Vid缓存资源 void releaseVid() => notify("ReleaseVid"); /// 获取单帧Vid文件图像 Future getSingleImage(String url) async { var rpcRst = await call("GetSingleImage", url); var result = GetVidFrameResult.fromJson(rpcRst as Map); return result; } /// 获取vid文件(base64) Future getVidFile(String url) async { var rpcRst = await call("GetVidFile", [url]); return rpcRst; } /// 导出文件 Future setBytesToExport(String data, String fileName) async { var rpcRst = await call("SetBytesToExport", [data, fileName]); return rpcRst; } ///缓存文件 Future setBinaryFileCache(String data, String fileName) async { var rpcRst = await call("SetBinaryFileCache", [data, fileName]); return rpcRst; } ///读取缓存文件 Future getBinaryFileCache(String fileName) async { var rpcRst = await call("GetBinaryFileCache", [fileName]); return rpcRst; } ///导出病例zip文件 Future exportPatientZipFile(String data, String fileName) async { var rpcRst = await call("ExportPatientZipFile", [data, fileName]); return rpcRst; } ///撤销病例导出 Future abortExportOperation() async { var rpcRst = await call("AbortExportOperation", []); return rpcRst; } ///Token失效通知 Future tokenExpired() async { var rpcRst = await call("TokenExpired", []); return rpcRst; } ///选择文件 Future selectFile(String path) async { var rpcResult = await call("SelectFile", [path]); return rpcResult; } ///开启RTMP服务器,并通知魔盒推流 Future startRtmpServer() async { var rpcResult = await call("StartRtmpServer", []); return rpcResult; } /// 开启魔盒RTMP推流 Future startRtmpPush() async { var rpcResult = await call("StartRtmpPush", []); return rpcResult; } /// 停用RTMP服务器,并停止魔盒的推流 Future stopRtmpServer() async { var rpcResult = await call("StopRtmpServer", []); return rpcResult; } ///打开文件夹选择器并通知Flutter路径 Future openFolderPicker(String path) async { var rpcResult = await call("OpenFolderPicker", [path]); return rpcResult; } /// 仅停止魔盒的推流,不关闭Rtmp Server Future stopRtmpPush() async { var rpcResult = await call("StopRtmpPush", []); return rpcResult; } Future getDesktopPath() async { var rpcResult = await call("GetDesktopPath", []); return rpcResult; } Future openSpecifiedPath(String path) async { var rpcResult = await call("OpenSpecifiedPath", [path]); return rpcResult; } ///读取打印驱动块 Future readPrintDriverChunk(int index) async { String rpcResult = await call("ReadPrintDriverChunk", [index]); Uint8List byteData = base64.decode(rpcResult); return byteData; } ///打开图像测量页(独立窗口) Future openImageMeasureAsync( String token, String patientCode, String remedicalCode, String recordCode, {String source = '0'}) async { var rpcRst = await call("OpenImageMeasure", [token, patientCode, remedicalCode, recordCode, source]); return rpcRst; } ///打开报告预览页(独立窗口) Future openReportPreviewAsync(String token, String reportCode, String recordCode, String isFormEditor) async { var rpcRst = await call( "OpenReportPreview", [token, reportCode, recordCode, isFormEditor]); return rpcRst; } ///打开图像测量页(独立窗口) Future openReportEditAsync( String token, String patientCode, String reportCode, String recordCode, String referralRecordCode, String consultationCode) async { var rpcRst = await call("OpenReportEdit", [ token, patientCode, reportCode, recordCode, referralRecordCode, consultationCode ]); return rpcRst; } ///打开报告设计器页面(独立窗口) ///templateType(机构模版/个人模版)机构=1,个人=2 Future openReportDesignerAsync( String templateId, String name, String type, String token, String json, bool isOrg, String openMode, ) async { var rpcRst = await call("OpenReportDesigner", [ templateId, name, type, token, json, isOrg, openMode, ]); return rpcRst; } ///第二窗口启动时调用 Future onSlaveWindowStart() async { await call('OnSlaveWindowStart'); } Future setTemplateJson(String templateId, String json) async { await call('SetTemplateJson', [templateId, json]); } ///打开在线会诊页面(独立窗口) Future openLiveConsultationAsync( String consultationCode, bool isJoin, int pageIndex, String token) async { await call( "OpenLiveConsultation", [consultationCode, isJoin, pageIndex, token]); } /// 打开设备直播 独立窗口 /// /// [deviceCode] 设备编码 /// /// [token] 登录令牌 /// /// [maxLiveCount] 最大直播数量 Future openDeviceLiveWindow( String deviceCode, String token, int maxLiveCount) { return call("OpenDeviceLiveWindow", [deviceCode, token, maxLiveCount]); } ///获取屏幕个数 Future getWindowsNum() async { var rpcRst = await call("GetWindowsNum"); return rpcRst; } ///关闭副窗口 Future closeSlaveWindow() async { var rpcRst = await call("CloseSlaveWindow"); return rpcRst; } ///关闭会诊窗口 Future closeLiveConsultation() async { var rpcRst = await call("CloseLiveConsultation"); return rpcRst; } ///开启拖拽窗口 Future beginWindowDrag(String windowName) async { var rpcRst = await call("BeginWindowDrag", [windowName]); return rpcRst; } ///关闭拖拽窗口 Future endWindowDrag(String windowName) async { var rpcRst = await call("EndWindowDrag", [windowName]); return rpcRst; } ///最小化窗口 Future minimizeWindow(String windowName) async { var rpcRst = await call("MinimizeWindow", [windowName]); return rpcRst; } ///最大化窗口 Future maximizeWindow(String windowName) async { var rpcRst = await call("MaximizeWindow", [windowName]); return rpcRst; } ///重置 Future restoreWindow(String windowName) async { var rpcRst = await call("RestoreWindow", [windowName]); return rpcRst; } ///获取Window状态 Future getWindowState(String windowName) async { var rpcRst = await call("GetWindowStateAsync", [windowName]); return rpcRst; } ///关闭窗口 Future closeWindow(String windowName) async { var rpcRst = await call("CloseWindow", [windowName]); return rpcRst; } ///设置语言Code Future setLanguageCodeAsync(String code) async { var rpcRst = await call("SetLanguageCode", [code]); return rpcRst; } //获取语言Code Future getLanguageCodeAsync() async { var rpcRst = await call("GetLanguageCode"); return rpcRst; } ///设置当前登录信息 Future setLoginUserInfoAsync(String userInfo) async { var rpcRst = await call("SetUserLoginInfo", [userInfo]); return rpcRst; } ///设置当前第二窗口状态 Future setSecondWindowStateInfoAsync(bool isSecondWindowMode) async { var rpcRst = await call("SetSecondWindowState", [isSecondWindowMode]); return rpcRst; } ///默认词条变更 Future thesaurusChange(String token) async { var rpcRst = await call("ThesaurusChange", [token]); return rpcRst; } ///提交报告通知 Future onSubmitReport(String patientId, String code) async { var rpcRst = await call("OnSubmitReport", [patientId, code]); return rpcRst; } ///刷新报告通知 Future refershReports() async { var rpcRst = await call("RefershReports", []); return rpcRst; } ///刷新报告通知 Future reloadConfig() async { var rpcRst = await call("ReloadConfig", []); return rpcRst; } ///重载配置 Future getIsUseSecondWindow() async { var rpcRst = await call("GetIsUseSecondWindow", []); return rpcRst; } ///重载配置 Future getIsWin7() async { var rpcRst = await call("GetIsWin7", []); return rpcRst; } ///打开控制台 Future openConsole() async { var rpcRst = await call("OpenConsole", []); return rpcRst; } ///主窗口关闭通知 Future onMainWindowLogout() async { var rpcRst = await call("OnMainWindowLogout", []); return rpcRst; } ///设置开启自启动 Future setAutoStartAsync(bool isAutoStart) async { var rpcRst = await call("SetAutoStart", [isAutoStart]); return rpcRst; } ///启用壳子录音 Future startShellRecord() async { var rpcRst = await call("StartShellRecord"); return rpcRst; } ///停止壳子录音 Future stopShellRecord() async { var rpcRst = await call("StopShellRecord"); return rpcRst; } ///导出日志 Future exportAppLogZipFile(int exportType, String fileName) async { var rpcRst = await call("ExportAppLogZipFile", [exportType, fileName]); return rpcRst; } ///开始录制 Future startRecording( String filePrefixTitle, String micDeviceId) async { var rpcRst = await call("StartRecording", [filePrefixTitle, micDeviceId]); return rpcRst; } ///暂停录制 Future pauseRecording(bool isPause) async { var rpcRst = await call("PauseRecording", [isPause]); return rpcRst; } ///结束录制 Future stopRecording() async { var rpcRst = await call("StopRecording"); return rpcRst; } ///导出会诊病例zip文件 Future exportConsultationZipFile(String data, String fileName) async { var rpcRst = await call("ExportConsultationZipFile", [data, fileName]); return rpcRst; } ///升级客户端 Future doUpgradClient(String upgradInfo) async { var rpcRst = await call("DoUpgradClient", [upgradInfo]); return rpcRst; } ///获得当前客户端版本 Future getCurrentAppVersion() async { var rpcRst = await call("GetCurrentAppVersion"); return rpcRst; } ///下载测量数据 Future downloadMeasureData(String url) async { var rpcRst = await call("DownloadMeasureData", [url]); return rpcRst; } ///下载大文件接口 Future downloadBigFile(String url, String fileName) async { var rpcRst = await call("DownloadBigFile", [url, fileName]); return rpcRst; } ///获取所有已安装的打印驱动 Future> getAllInstalledPrinterInfos() async { var rpcRst = await call("GetAllInstalledPrinterInfos"); List result = []; for (var i in rpcRst) { result.add(i.toString()); } return result; } ///打印测试(调用后会在指定的打印机打印一张测试页) Future printTestPage(String name) async { var rpcRst = await call("PrintTestPage", [name]); return rpcRst; } ///搜索未安装的打印驱动 Future> getUninstalledPrinters({String? ip}) async { var rpcRst = await call("GetUninstalledPrinters", [ip]); List result = []; for (var i in rpcRst) { result.add(i.toString()); } return result; } /// 安装打印驱动 Future installPrinterDriver(String printerDriveStr) async { var rpcRst = await call("InstallPrinterDriver", [printerDriveStr]); return rpcRst; } ///选择本地打印驱动 Future chooseLocalDrive() async { var rpcRst = await call("ChooseLocalDrive"); return rpcRst; } /// 关闭打印驱动工具 Future closePrinterDriverManager() async { var rpcRst = await call("ClosePrinterDriverManager"); return rpcRst; } /// 获取当前魔盒设备的UniqueId Future getUltrasoundUniqueId() async { var rpcRst = await call("GetUltrasoundUniqueIdAsync"); return rpcRst; } ///获取网卡信息 Future getNetworkCardsInfo() async { var rpcRst = await call("GetNetworkCardsInfo"); return rpcRst; } ///保存网卡信息 Future saveNetworkCardsInfo(String networkWireListModel) async { var rpcRst = await call("SaveNetworkCardsInfo", [networkWireListModel]); return rpcRst; } ///获取无线网卡信息 Future getWirelessCardInfo() async { var rpcRst = await call('GetWirelessCardInfo'); return rpcRst; } ///保存无线网卡信息 Future saveWifiNetworkCard(String networkInterface) async { var rpcRst = await call("SaveWifiNetworkCard", [networkInterface]); return rpcRst; } ///连接Wifi网络 Future connectWifi(String wifiInfo) async { var rpcRst = await call("ConnectWifi", [wifiInfo]); return rpcRst; } ///断开Wifi网络 Future disconnectWifi(String wifiInfo) async { var rpcRst = await call("DisconnectWifi", [wifiInfo]); return rpcRst; } ///忘记Wifi密码 Future forgetWifiPassword(String wifiInfo) async { var rpcRst = await call("ForgetWifiPassword", [wifiInfo]); return rpcRst; } ///刷新DNS Future flushDNS() async { var rpcRst = await call("FlushDNS"); return rpcRst; } ///Ping 测试Ip是否可以连通 Future ping(String ipInfo) async { var rpcRst = await call("Ping", [ipInfo]); return rpcRst; } ///开始培训推流 Future startTrainningPush(String pushURL, String micDeviceId, TranningPushEnum tranningPushEnum) async { var rpcRst = await call("StartTrainningPush", [ pushURL, micDeviceId, tranningPushEnum.index, ]); return rpcRst; } ///切换培训推流模式 Future switchPushMode(TranningPushEnum tranningPushEnum) async { var rpcRst = await call("SwitchPushMode", [ tranningPushEnum.index, ]); return rpcRst; } ///调整培训音频音量 Future adjustAudioVoice( AudioTypeEnum audioTypeEnum, double audioVolume) async { var rpcRst = await call("AdjustAudioVoice", [ audioTypeEnum.index, audioVolume, ]); return rpcRst; } ///停止培训直播推流 Future stopTrainningPush() async { var rpcRst = await call("StopTrainningPush"); return rpcRst; } ///开始培训直播录制 Future startTrainningRecord( String filePrefixTitle, String pullURL) async { var rpcRst = await call("StartTrainningRecord", [ filePrefixTitle, pullURL, ]); return rpcRst; } ///停止培训直播录制 Future stopTrainningRecord(String? path) async { var rpcRst = await call("StopTrainningRecord", [path]); return rpcRst; } ///打开直播课页面 Future openLiveCoursePage(String courseCode, String token) async { var rpcRst = await call("OpenLiveCoursePage", [courseCode, token]); return rpcRst; } ///取消文件下载 Future cancelDownloadBigFile() async { var rpcRst = await call('CancelDownloadBigFile'); return rpcRst; } ///复制到粘贴板 Future copyToClipboard(String txtToCopy) async { var rpcRst = await call('CopyToClipboard', [txtToCopy]); return rpcRst; } ///重载配置 Future reloadSettings(String jsonStr) async { var rpcRst = await call('ReloadSettings', [jsonStr]); return rpcRst; } ///第二窗口加载完毕 Future secondWindowInited() async { var rpcRst = await call('SecondWindowInited'); return rpcRst; } ///根据枚举获取对应枚举的音频设备的名称 Future> getAudioDevice(AudioTypeEnum audioTypeEnum) async { var rpcRst = await call('GetAudioDevice', [audioTypeEnum.index]); return rpcRst; } ///根据枚举获取当前活跃的音频输出或输入设备,并设置它的音量 Future setActiveDeviceVolume( AudioTypeEnum audioTypeEnum, double volume) async { var rpcRst = await call('SetActiveDeviceVolume', [ audioTypeEnum.index, volume, ]); return rpcRst; } ///根据枚举获取对应枚举默认音频设备的音量 Future getAudioDeviceVolume(AudioTypeEnum audioTypeEnum) async { var rpcRst = await call('GetAudioDeviceVolume', [audioTypeEnum.index]); return rpcRst; } ///根据音频设备名字设置对应设备为当前系统默认的扬声器 Future setSystemAudioDevice(String deviceName) async { var rpcRst = await call('SetSystemAudioDevice', [deviceName]); return rpcRst; } ///停止魔盒的设备预览 Future stopPreview() async { var rpcRst = await call('StopPreview'); return rpcRst; } } /// 一些platform 的数据结构定义 enum TranningPushEnum { /// /// 窗口 /// Window, /// /// 屏幕 /// Screen, } enum AudioTypeEnum { /// /// 麦克风 /// Mic, /// /// 扬声器 /// Speaker, }