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