服务端Api
# 接口说明
服务端Api说明
# 概述
IotCenter提供了一套完整的Api通信服务以供客户端与服务端间进行通信和数据交互,该机制主要使用 gRPC 协议作为数据传输的接口,proto文件作为该协议机制的协议文档,可供不同语言的开发者进行调用。
# 协议文件结构图
设计的协议文件包括以下组成部分:
├─AlarmCenterGrpcService.Protos 协议文件类库
│ ├─account.proto 登录
│ ├─AlarmCenterCallback.proto 部分实时数据查询及回调
│ ├─AlarmCenterDatabase.proto 数据库访问
│ ├─common.proto 部分通用类型
│ ├─greet.proto 初始化握手
│ ├─serviceInstaceContract.proto 与服务管理有关的契约
│ ├─SystemManage.proto 系统管理有关的七月
│ ├─Tool.proto 部分工具类
# 客户端集成步骤
1、实现greet.proto所提供的客户端握手方法。
var clientMonitor = new GreetService();
await clientMonitor.GreetAsync();
2、实现account.proto所提供的登录方法。
3、集成上述方法后,可调用其他方法。
4、具体如何集成,可参见【如何使用gRPC 】获得完整使用步骤。
接下来就可以进行IotCenter服务的客户端集成了。
# 接口方法说明
# 1. AlarmCenterService 接口提供的登录方法
封装了一系列与用户登录相关的方法。
- 接口索引
代码
public class AlarmCenterService
{
/// <summary>
/// 登录
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
string Login(string userName, string password, ClientType clientType);
/// <summary>
/// 登录
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <param name="clientType"></param>
/// <returns></returns>
bool LoginRetry(string userName, string password, ClientType clientType);
/// <summary>
/// 登录并重试
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <returns></returns>
string Listen();
/// <summary>
/// 结束会话
/// </summary>
void CloseSession();
/// <summary>
/// 连接状态
/// </summary>
ConnectionStatus ConnectionStatus { get; set; }
}
- 示例代码
代码
var iconnectService = new AlarmCenterService();
iconnectService.Login("admin", "xxxx", AlarmCenterGrpc.Core.ClientType.Dll);//登录
iconnectService.CloseSession();//退出
# 2. AlarmCenterDatabaseService 契约
封装了一系列与数据库操作有关的方法。
- 接口索引
代码
public class AlarmCenterDatabaseService
{
/// <summary>
/// 获取设备表(equip表)的DataTable
/// </summary>
/// <returns>equip表的DataTable</returns>
DataTable GetDataTableOfEquip();
/// <summary>
/// 通过SQL语句获取一个对象
/// </summary>
/// <param name="strSQL">SQL语句</param>
/// <returns>对象</returns>
object GetObjectFromSQL(string strSQL);
/// <summary>
/// 获取YCP表的DataTable
/// </summary>
/// <param name="sta_no">站点好,填入1,当前无意义</param>
/// <param name="equip_no">设备号</param>
/// <returns>YCP表的DataTable</returns>
DataTable GetDataTableOfYCP(int sta_no, int equip_no);
/// <summary>
/// 获取YXP表的DataTable
/// </summary>
/// <param name="sta_no">站点好,填入1,当前无意义</param>
/// <param name="equip_no">设备号</param>
/// <returns>YXP表的DataTable</returns>
DataTable GetDataTableOfYXP(int sta_no, int equip_no);
/// <summary>
/// 获取SetParm表的DataTable
/// </summary>
/// <param name="sta_no">站点好,填入1,当前无意义</param>
/// <param name="equip_no">设备号</param>
/// <returns>SetParm表的DataTable</returns>
DataTable GetDataTableOfSetParm(int sta_no, int equip_no);
/// <summary>
/// 通过SQL语句获取一个DataTable
/// </summary>
/// <param name="strSQL"></param>
/// <returns></returns>
DataTable GetDataTableFromSQL(string strSQL);
/// <summary>
/// 执行一个SQL语句
/// </summary>
/// <param name="strSQL">SQL语句</param>
/// <returns>返回受影响的行数</returns>
int ExecuteSQL(string strSQL);
/// <summary>
/// 通过事务执行SQL语句(一条或者多条)
/// </summary>
/// <param name="cmdtext">SQL语句的数组</param>
void ExecuteSQLsWithTransaction(string[] cmdtext);
}
- 示例代码
代码
var dbOperate = new AlarmCenterDatabaseService();
var dt = dbOperate.GetDataTableOfYCP(1, 1);
var result = dbOperate.GetDataTableFromSQL("select * from gwuser");
# 3. AlarmCenterService
封装了与IotCenter操作相关的方法。
- 接口索引
代码
public class AlarmCenterService
{
/// <summary>
/// 监听
/// </summary>
void Listen(); /// <summary>
/// 监听
/// </summary>
/// <returns></returns>
string ListenEx();
/// <summary>
/// 登录
/// </summary>
/// <param name="User">用户名</param>
/// <param name="Pwd">密码</param>
/// <returns></returns>
bool Login(string User, string Pwd, ClientType CT, bool bRetry = false);
/// <summary>
/// 登录并返回令牌
/// </summary>
/// <param name="User"></param>
/// <param name="Pwd"></param>
/// <param name="CT"></param>
/// <returns></returns>
string LoginEx(string User, string Pwd, ClientType CT);
/// <summary>
/// 程序内部的站点链接登录
/// </summary>
/// <param name="bs">数字证书的内容</param>
/// <returns></returns>
DllLoginReturnInfo DllLogin(byte[] bs);
/// <summary>
/// 注册组件
/// </summary>
/// <param name="RegisterData"></param>
/// <returns></returns>
bool DllRegisterData(List<RemoteRegisterData> RegisterData);
/// <summary>
/// 获取客户端IP和端口
/// </summary>
/// <returns></returns>
string GetClientIPAndPort();
/// <summary>
/// 结束会话
/// </summary>
void CloseSession();
/// <summary>
/// 停止服务端数据采集
/// </summary>
void StopDataCenter();
string GetApplicationRootPath();
/// <summary>
/// 服务的数据采集是否在运行
/// </summary>
/// <returns></returns>
bool IsRun();
/// <summary>
/// 获取设备的运行状态
/// </summary>
/// <param name="iEquipNo">设备号</param>
/// <returns>状态</returns>
EquipState GetEquipStateFromEquipNo(int iEquipNo);
/// <summary>
/// 获取所有设备的状态
/// </summary>
/// <returns></returns>
Dictionary<int, EquipState> GetEquipStateDict();
/// <summary>
/// 获取模拟量测点的实时值
/// </summary>
/// <param name="iEquipNo">设备号</param>
/// <param name="iYcpNo">模拟量测点号</param>
/// <returns>返回值</returns>
object GetYCValue(int iEquipNo, int iYcpNo);
/// <summary>
/// 获取指定设备的所有YC实时值
/// </summary>
/// <returns></returns>
Dictionary<int, object> GetYCValueDictFromEquip(int iEquipNo);
/// <summary>
/// 获取模拟量测点的报警状态
/// </summary>
/// <param name="iEquipNo">设备号</param>
/// <param name="iYcpNo">测点号</param>
/// <returns>true:有报警; false:无报警</returns>
bool GetYCAlarmState(int iEquipNo, int iYcpNo);
/// <summary>
/// 获取指定设备的所有YC报警状态值
/// </summary>
/// <returns></returns>
Dictionary<int, bool> GetYCAlarmStateDictFromEquip(int iEquipNo);
/// <summary>
/// 获取状态量测点的实时值
/// </summary>
/// <param name="iEquipNo">设备号</param>
/// <param name="iYxpNo">状态量测点号</param>
/// <returns>返回值</returns>
object GetYXValue(int iEquipNo, int iYxpNo);
/// <summary>
/// 获取指定设备的所有YX状态值
/// </summary>
/// <returns></returns>
Dictionary<int, string> GetYXValueDictFromEquip(int iEquipNo);
/// <summary>
/// 获取状态量测点的报警状态
/// </summary>
/// <param name="iEquipNo">设备号</param>
/// <param name="iYxpNo">状态量测点号</param>
/// <returns>true:有报警; false:无报警</returns>
bool GetYXAlarmState(int iEquipNo, int iYxpNo);
string GetYXEvt01(int iEquipNo, int iYxpNo);
string GetYXEvt10(int iEquipNo, int iYxpNo);
/// <summary>
/// 获取指定设备的所有YX报警状态
/// </summary>
/// <returns></returns>
Dictionary<int, bool> GetYXAlarmStateDictFromEquip(int iEquipNo);
/// <summary>
/// 获得历史曲线的数据
/// </summary>
/// <param name="d">读取日期</param>
/// <param name="eqpno">设备号</param>
/// <param name="ycpno">模拟量测点号</param>
/// <returns></returns>
byte[] GetCurveData(DateTime d, int eqpno, int ycno);
/// <summary>
/// 获取数据曲线
/// </summary>
/// <param name="d"></param>
/// <param name="eqpno"></param>
/// <param name="ycyxno"></param>
/// <param name="type"></param>
/// <returns></returns>
byte[] GetCurveData1(DateTime d, int eqpno, int ycyxno, string type);
/// <summary>
/// 获取数据曲线
/// </summary>
/// <param name="DTList"></param>
/// <param name="stano"></param>
/// <param name="eqpno"></param>
/// <param name="ycyxno"></param>
/// <param name="type"></param>
/// <returns></returns>
Task<List<myCurveData>> GetDataFromCurve(List<DateTime> DTList, int stano, int eqpno, int ycyxno, string type);
Task<List<myCurveData>> GetChangedDataFromCurveAsync(DateTime bgn, DateTime end, int stano, int eqpno, int ycyxno, string type);
/// <summary>
/// 把设备设置成调试状态
/// </summary>
/// <param name="iEquipNo">设备号</param>
/// <param name="bFlag">true:调试状态; false:非调试状态</param>
void SetEquipDebug(int iEquipNo, bool bFlag);
/// <summary>
/// 获取设备的调试状态
/// </summary>
/// <param name="iEquipNo">设备号</param>
/// <returns></returns>
bool GetEquipDebugState(int iEquipNo);
/// <summary>
/// 向设备发送设置命令
/// </summary>
/// <param name="EquipNo">设备号</param>
/// <param name="strCMD1">命令字符串1</param>
/// <param name="strCMD2">命令字符串2</param>
/// <param name="strCMD3">命令字符串3</param>
/// <param name="strUser">用户名(当前登录用户)</param>
void SetParm(int EquipNo, string strCMD1, string strCMD2, string strCMD3, string strUser);
void SetParm_1(int EquipNo, string strCMD1, string strCMD2, string strCMD3, string strUser, bool bShowDlg);
void SetParm1(int EquipNo, int SetNo, string strUser);
void SetParm1_1(int EquipNo, int SetNo, string strValue, string strUser, bool bShowDlg);
void SetParm2(int EquipNo, string strCMD1, string strCMD2, string strCMD3, string strType, string strUser);
void SetParm2_1(int EquipNo, string strCMD1, string strCMD2, string strCMD3, string strType, string strUser, bool bShowDlg);
void DoSetParmFromString(string csParmStr);
/// <summary>
/// 设备是否有模拟量测点
/// </summary>
/// <param name="EquipNo">设备号</param>
/// <returns></returns>
bool HaveYCP(int EquipNo);
/// <summary>
/// 设备是否有状态量测点
/// </summary>
/// <param name="EquipNo">设备号</param>
/// <returns></returns>
bool HaveYXP(int EquipNo);
/// <summary>
/// 设备是否有控制命令
/// </summary>
/// <param name="EquipNo">设备号</param>
/// <returns></returns>
bool HaveSet(int EquipNo);
/// <summary>
/// 是否有历史曲线记录
/// </summary>
/// <param name="EquipNo">设备号</param>
/// <param name="YCPNo">模拟量测点号</param>
/// <returns></returns>
bool HaveHistoryCurve(int EquipNo, int YCPNo);
/// <summary>
/// 获取设备列表的字符串
/// </summary>
/// <returns>[设备号][设备名称];[设备号][设备名称]...</returns>
string GetEquipListStr();
/// <summary>
/// 获取模拟量列表的字符串
/// </summary>
/// <returns>[测点号][测点名称];[测点号][测点名称]...</returns>
string GetYCPListStr(int iEquipNo);
/// <summary>
/// 获取状态量列表的字符串
/// </summary>
/// <returns>[测点号][测点名称];[测点号][测点名称]...</returns>
string GetYXPListStr(int iEquipNo);
/// <summary>
/// 获取设置列表的字符串
/// </summary>
/// <returns>[设置名称][命令字符串1][命令字符串2][命令字符串3];[设置名称][命令字符串1][命令字符串2][命令字符串3]...</returns>
string GetSetListStr(int iEquipNo);
/// <summary>
/// 获取指定模拟量测点的“越限事件+处理意见”
/// </summary>
/// <param name="iEqpNo">设备号</param>
/// <param name="iYCPNo">测点号</param>
/// <returns></returns>
string GetYCAlarmComments(int iEqpNo, int iYCPNo);
/// <summary>
/// 获取指定状态量测点的“报警处理意见”
/// </summary>
/// <param name="iEqpNo">设备号</param>
/// <param name="iYXPNo">测点号</param>
/// <returns></returns>
string GetYXAlarmComments(int iEqpNo, int iYXPNo);
/// <summary>
/// 获取程序版本号
/// </summary>
/// <returns>程序版本号</returns>
string GetVersionInfo();
/// <summary>
/// 获取所有实时Proxy_YCItem值
/// </summary>
void GetTotalRTYCItemData1();
/// <summary>
/// 获取所有实时Proxy_YXItem值
/// </summary>
void GetTotalRTYXItemData1();
/// <summary>
/// 获取变化的实时Proxy_YCItem值
/// </summary>
void GetChangedRTYCItemData1();
/// <summary>
/// 获取变化的实时Proxy_YXItem值
/// </summary>
void GetChangedRTYXItemData1();
/// <summary>
///获取所有实时Proxy_EquipItem值
/// </summary>
void GetTotalRTEquipItemData1();
/// <summary>
///
/// </summary>
void GetChangedRTEquipItemData1();
/// <summary>
/// 获取动态添加的设备的Proxy_EquipItem值
/// </summary>
/// <returns></returns>
int[] GetAddRTEquipItemData();
/// <summary>
/// 获取动态删除的设备的设备号数组
/// </summary>
/// <returns></returns>
int[] GetDelRTEquipItemData();
/// <summary>
/// 获取动态删除的设备的设备号数组
/// </summary>
/// <returns></returns>
int[] GetEditRTEquipItemData();
/// <summary>
/// 获取设备树的XML文件
/// </summary>
/// <returns></returns>
byte[] GetEquipTreeXMLFile();
/// <summary>
/// 通过平台的短信模块向指定手机号码发送短信
/// </summary>
/// <param name="TelNumber">手机号码</param>
/// <param name="msg">短信内容</param>
/// <returns></returns>
bool SendSMS(string TelNumber, string msg);
/// <summary>
///
/// </summary>
/// <returns></returns>
bool ReadNextBuffer();
/// <summary>
///
/// </summary>
/// <returns></returns>
byte[] GetCurrentBuffer();
/// <summary>
/// 获取新增的实时事件
/// </summary>
void GetAddRealEventItem1();
/// <summary>
/// 获取删除后的实时事件
/// </summary>
void GetDelRealEventItem1();
/// <summary>
/// 删除调试信息
/// </summary>
/// <param name="iEquipNo"></param>
void DeleteDebugInfo(int iEquipNo);
/// <summary>
/// 确认设备状态
/// </summary>
/// <param name="item"></param>
void ConfirmedRealTimeEventItem(WcfRealTimeEventItem item);
/// <summary>
/// 消息预警
/// </summary>
/// <param name="level"></param>
/// <param name="msgstr"></param>
/// <param name="equipno"></param>
/// <param name="CanRepeat"></param>
void AddMessage(MessageLevel level, string msgstr, int equipno, bool CanRepeat = true);
/// <summary>
/// 数据库设备信息改变后(修改了equip、ycp、yxp表)进行重置
/// </summary>
void ResetEquips();
/// <summary>
/// 设备设置表的信息改变后(修改了SetParm表)进行重置
/// </summary>
void ResetSetParmTable();
/// <summary>
/// 修改了设备联动关系后进行程序重置
/// </summary>
void ResetEquipmentLinkage();
/// <summary>
/// 修改了定时任务的逻辑后进行程序重置
/// </summary>
void ResetProcTimeManage();
/// <summary>
/// 修改了定时抄表的逻辑后进行程序重置
/// </summary>
void ResetGWDataRecordItems();
/// <summary>
/// 修改了延时执行动作的列表后(修改了GWDelayAction表)进行程序重置
/// </summary>
void ResetDelayActionPlan();
/// <summary>
/// 资产管理:增加一个资产
/// </summary>
/// <param name="ZCID">资产号</param>
void ZCAddReset(string ZCID);
/// <summary>
/// 资产管理:修改一个资产
/// </summary>
/// <param name="ZCID"></param>
void ZCEditReset(string ZCID);
/// <summary>
/// 资产管理:删除一个资产
/// </summary>
/// <param name="ZCID"></param>
void ZCDelReset(string ZCID);
/// <summary>
/// 获取所有资产项目
/// </summary>
/// <returns></returns>
WcfZCItem[] FirstGetRealZCItem();
/// <summary>
/// 获取改变了的资产项目,包括增加项和修改项
/// </summary>
/// <returns></returns>
WcfZCItem[] GetChangedZCItem();
/// <summary>
/// 获取删除了的资产项目
/// </summary>
/// <returns></returns>
WcfZCItem[] GetDeleteZCItem();
/// <summary>
/// 把对应资产的图片传到服务端存储
/// </summary>
/// <param name="ZCID"></param>
/// <param name="bs">图片的二进制数组</param>
void SendImageToSvr(string ZCID, byte[] bs);
/// <summary>
/// 从服务端取回对应资产的图片
/// </summary>
/// <param name="ZCID">资产号</param>
/// <returns>图片的二进制数据数组</returns>
byte[] GetImageFromSvr(string ZCID);
/// <summary>
/// 加入资产维护记录
/// </summary>
/// <param name="ZCID">资产ID</param>
/// <param name="Name">维护人,通常就是App的登录用户名</param>
/// <param name="RecordStr">输入的维护记录</param>
/// <param name="Pictures">通过手机拍的照片,一张或多张</param>
/// <returns></returns>
bool AddWeihuRecord4ZC(string ZCID, string Name, string RecordStr, List<byte[]> Pictures);
/// <summary>
/// 删除一条维护记录
/// </summary>
/// <param name="ID">维护记录表中的唯一ID</param>
/// <returns></returns>
bool RemoveWeihuRecord4ZC(long ID/////////////////////////////////////////////
/// <summary>
/// 把预案的图片存到服务端
/// </summary>
/// <param name="ID">预案号</param>
/// <param name="bs">图片的二进制数组</param>
void SendPlanImageToSvr(string ID, byte[] bs);
/// <summary>
/// 从服务端获取预案的对应图片
/// </summary>
/// <param name="ID">预案ID</param>
/// <returns>图片数据的数组</returns>
byte[] GetPlanImageFromSvr(string ID);
/// <summary>
/// 获取所有预案的图片名称
/// </summary>
/// <returns>名称数组</returns>
List<string> GetAllPlanImageName();
bool IsPlanFileExist(string fileName);
/// <summary>
/// 获取软件的授权名称
/// </summary>
/// <returns></returns>
string GetName2SF();
/// <summary>
/// 获取授权用户名称
/// </summary>
/// <returns></returns>
string GetUserName2SF();
/// <summary>
/// 获取系统的唯一标识码
/// </summary>
/// <returns></returns>
string GetSystemGUID();
////////////
/// <summary>
/// 设置设备名称
/// </summary>
/// <param name="EquipNo">设备号</param>
/// <param name="Nm">新的设备名称</param>
void SetEquipNm(int EquipNo, string Nm);
/// <summary>
/// 设置某个模拟量测点的名称
/// </summary>
/// <param name="EquipNo">对应设备号</param>
/// <param name="YcpNo">对应测点号</param>
/// <param name="Nm">新的测点名称</param>
void SetYcpNm(int EquipNo, int YcpNo, string Nm);
/// <summary>
/// 设置某个状态量测点的名称
/// </summary>
/// <param name="EquipNo">对应设备号</param>
/// <param name="YxpNo">对应测点号</param>
/// <param name="Nm">新的测点名称</param>
void SetYxpNm(int EquipNo, int YxpNo, string Nm);
/// <summary>
/// 把某个测点设置成非手工复位状态
/// </summary>
/// <param name="EquipNo">设备号</param>
/// <param name="sType">"C"---模拟量;"X"---状态量</param>
/// <param name="YcYxNo">测点号</param>
void MResetYcYxNo(int EquipNo, string sType, int YcYxNo);
/// <summary>
/// 系统是否支持3D功能
/// </summary>
/// <returns></returns>
bool Support3D();//3D支持
/// <summary>
/// 系统是否支持数据分析与挖掘的功能
/// </summary>
/// <returns></returns>
bool SupportSJFX();
/// <summary>
/// 系统是否支持资产管理的功能
/// </summary>
/// <returns></returns>
bool SupportZCGL();
/// <summary>
/// 系统是否支持体感控制的功能
/// </summary>
/// <returns></returns>
bool SupportTGKZ();
/// <summary>
/// 系统是否支持多点触控的功能
/// </summary>
/// <returns></returns>
bool SupportDDCK();
/// <summary>
/// 系统是否支持在线升级功能
/// </summary>
/// <returns></returns>
bool SupportZXSJ();
/// <summary>
/// 系统是否支持能源管理的功能
/// </summary>
/// <returns></returns>
bool SupportNYGL();
/// <summary>
/// 系统是否支持预案管理的功能
/// </summary>
/// <returns></returns>
bool SupportYAGL();
/// <summary>
/// 系统是否支持多屏互动的功能
/// </summary>
/// <returns></returns>
bool SupportDPHD();
/// <summary>
/// 系统是否支持BIM的功能
/// </summary>
/// <returns></returns>
bool SupportBIM();
/// <summary>
/// 系统是否支持语音交互的功能
/// </summary>
/// <returns></returns>
bool SupportVOICE();
/// <summary>
/// 系统是否支持二维码的功能
/// </summary>
/// <returns></returns>
bool SupportQRCode();
/// <summary>
/// 是否采用中性版本的支持
/// </summary>
/// <returns></returns>
bool IsNeuTral();
////////////双机热备////////////////////////////
/// <summary>
/// 系统是否为双机热备的热备模式
/// </summary>
/// <returns></returns>
bool IsHotStandby();
/// <summary>
/// 获取双机热备备机的IP地址
/// </summary>
/// <returns></returns>
string GetHotStandbyIP();
/// <summary>
/// 是否处于双机热备的侦听状态中
/// </summary>
/// <returns></returns>
bool IsHotStandbyListenState();
//////////////////////////////////////////////////
////////////操作属性文件////////////////////////////
/// <summary>
/// 读取系统的配置文件
/// </summary>
/// <param name="PropertyName">配置文件中的属性名称</param>
/// <param name="NodeName">属性下面的节点名称</param>
/// <param name="DefaultValue">如果没有配置该属性,则返回默认值</param>
/// <returns>返回属性值</returns>
string GetPropertyFromPropertyService(string PropertyName, string NodeName, string DefaultValue);
/// <summary>
/// 修改系统的配置文件
/// </summary>
/// <param name="PropertyName">配置文件中的属性名称</param>
/// <param name="NodeName">属性下面的节点名称</param>
/// <param name="DefaultValue">属性或者节点的值</param>
void SetPropertyToPropertyService(string PropertyName, string NodeName, string Value);
void SetInterScreenID(int id);
void OpenPageInMultiScreens(string PageNm, string multiScreens, bool IsAutoOpen, bool DWAction, string infoConfig = null, bool? bStopPageCycle = null);
void SetGUID(string strGUID);
void AddChangedEquip(ChangedEquip EqpList);
bool GetSiBState();//获取当前服务器的授权状态
/// <summary>
/// 通过语音进行交互
/// </summary>
/// <param name="bVoices">语音流</param>
/// <param name="UserNm">登录用户名</param>
/// <returns></returns>
GrpcVoiceItem SetVCtrol(byte[] bVoices, string UserNm);
/// <summary>
/// 通过语音进行交互
/// </summary>
/// <param name="csVoice">语音字符</param>
/// <param name="UserNm">登录用户名</param>
/// <returns></returns>
GrpcVoiceItem SetVCtrol1(string csVoice, string UserNm);
string[] GetHFString();//获取语音设置的高频词
string GetXunfeiAPPID();
/// <summary>
/// 强制指定客户端下线,管理员才有此权限
/// </summary>
/// <param name="GUID"></param>
/// <returns>总是true</returns>
bool KickClient(string GUID);
/// <summary>
/// 通知指定登录用户下线,用于用户权限变更的情形
/// </summary>
void NotifyLoginUserOffLine(string msg, string UserNm);
/// <summary>
/// 通知指定角色的用户下线,用于用户权限变更的情形
/// </summary>
void NotifyRoleUserOffLine(string msg, string RoleNm);
/// <summary>
/// 向指定客户端弹出信息
/// </summary>
/// <param name="msg">消息</param>
/// <param name="GUID">客户端GUID</param>
void ShowMsg2GUID(string msg, string GUID);
/// <summary>
/// 从服务端获取指定图片文件
/// </summary>
/// <param name="path">文件路径</param>
/// <param name="ImageNm">文件名</param>
/// <returns></returns>
byte[] GetImageFromSvr1(string path, string ImageNm);
/// <summary>
/// 把某个测点设置成误报状态,适用于处理误报的情况
/// </summary>
/// <param name="eqpno">设备号</param>
/// <param name="type">类型 C-模拟量 X-状态量</param>
/// <param name="ycyxno">测点号</param>
/// <returns></returns>
bool SetWuBao(int eqpno, string type, int ycyxno);
/// <summary>
/// 把某个测点设置为非报警状态---适用于处理报警后无恢复信号的情况
/// </summary>
/// <param name="eqpno">设备号</param>
/// <param name="type">类型 C-模拟量 X-状态量</param>
/// <param name="ycyxno">测点号</param>
/// <returns></returns>
bool SetNoAlarm(int eqpno, string type, int ycyxno);
/// <summary>
/// 执行扩展模块中的一个命令
/// </summary>
/// <param name="ModuleNm">模块名称.GWExProc表中的Proc_Module</param>
/// <param name="cmd1">参数1.GWExProcCmd表中的main_instruction</param>
/// <param name="cmd2">参数2.GWExProcCmd表中的minor_instruction</param>
/// <param name="cmd3">参数3.GWExProcCmd表中的value</param>
void DoExProcSetParm(string ModuleNm, string cmd1, string cmd2, string cmd3);
/// <summary>
/// 报警确认后恢复到正常状态---需要在设备dll中重新定义基类的虚函数
/// public virtual bool Confirm2NormalState(string sYcYxType, int iYcYxNo)
/// 默认情况返回false
/// </summary>
/// <param name="iEqpNo">设备号</param>
/// <param name="sYcYxType">类型 C-模拟量 X-状态量</param>
/// <param name="iYcYxNo">测点号</param>
/// <returns>true可以执行, false不可以执行</returns>
bool Confirm2NormalState(int iEqpNo, string sYcYxType, int iYcYxNo);
/// <summary>
/// 用户针对某个设置项进行锁定
/// </summary>
/// <param name="UserNm">用户名</param>
/// <param name="iEquipNo">设备号</param>
/// <param name="iSetNo">设置号</param>
/// <param name="Client_Instance_GUID">客户端GUID标识</param>
/// <returns></returns>
bool LockSetItem(string UserNm, int iEquipNo, int iSetNo, string Client_Instance_GUID);
/// <summary>
/// 解除某个设置项的锁定
/// </summary>
/// <param name="UserNm">用户名</param>
/// <param name="iEquipNo">设备号</param>
/// <param name="iSetNo">设置号</param>
/// <param name="Client_Instance_GUID">客户端实例GUID</param>
/// <returns></returns>
bool UnLockSetItem(string UserNm, int iEquipNo, int iSetNo, string Client_Instance_GUID);
/// <summary>
/// 获取设置项的描述
/// </summary>
/// <param name="iEquipNo">设备号</param>
/// <param name="iSetNo">设置号</param>
/// <returns>描述内容</returns>
string GetSetItemDesc(int iEquipNo, int iSetNo);
/// <summary>
/// 生成二维码图片
/// </summary>
/// <param name="Content">二维码内容</param>
/// <returns>二维码图片字节流</returns>
byte[] CreateQrCode2Jpeg(string Content);
/// <summary>
/// 生成具有用户身份的二维码
/// </summary>
/// <param name="OwnerName">用户名</param>
/// <returns>二维码图片字节流</returns>
byte[] CreateQrCode4Owner(string OwnerName);
///// <summary>
///// 生成具有访客身份的二维码
///// </summary>
///// <param name="VisitorNm">访客姓名</param>
///// <param name="OwnerNm">邀请人姓名</param>
///// <param name="ListEquipSetInfo">允许的设置项</param>
///// <returns>二维码图片字节流</returns>
//byte[] CreateQrCode4Visitor(string VisitorNm, string OwnerNm, List<EquipSetInfo> ListEquipSetInfo);
///// <summary>
///// 生成具有设备身份的二维码
///// </summary>
///// <param name="ListEquipSetInfo">设备动作</param>
///// <param name="EqpNo">设备号</param>
///// <param name="ZhiChanNo">资产号</param>
///// <returns>二维码图片字节流</returns>
//
//byte[] CreateQrCode4Equip(List<EquipSetInfo> ListEquipSetInfo, string EqpNo, string ZhiChanNo);
/// <summary>
/// 移动端扫描设备二维码
/// </summary>
/// <param name="UserNm">用户名</param>
/// <param name="QRContent">二维码内容</param>
/// <returns>无意义</returns>
bool QRScan4Equip(string UserNm, string QRContent);
/// <summary>
/// 移动端扫描设备二维码,带返回值
/// </summary>
/// <param name="UserNm">用户名</param>
/// <param name="QRContent">二维码内容</param>
/// <param name="RtnStr">返回值:设备号+资产号</param>
/// <returns></returns>
bool QRScan4Equip1(string UserNm, string QRContent, out string RtnStr);
/// <summary>
/// 通过表达式获取相应的返回值 float or string
/// </summary>
/// <param name="csExpr"></param>
/// <returns></returns>
object GetValueFromExpression(string csExpr);
/// <summary>
/// 激发kinect 挥手事件
/// </summary>
/// <param name="Type"></param>
void ActiveHandWaveEvent(HandWaveType Type);
}
- 示例代码
代码
var alarmCenterApp =new AlarmCenterService();
alarmCenterApp.OpenPageInMultiScreens("123", "1234", true, true);
# 4. IAlarmCenterCallbackService 接口
封装了与回调方法相关的一系列操作类。
- 接口方法索引
代码
public interface IAlarmCenterCallbackService
{
/// <summary>
/// 打开指定的窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="action"></param>
void InterScreenOpenPage(object sender, EventArgs e, Action<string, bool, bool, string, bool?> action);
/// <summary>
/// 显示窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="action"></param>
void ShowPage(object sender, EventArgs e, Action<string, bool> action);
/// <summary>
/// 关闭窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <param name="action"></param>
void ClosePage(object sender, EventArgs e, Action<string, bool> action);
/// <summary>
/// 登录并回调
/// </summary>
/// <param name="action"></param>
void Login(Action<string, string> action);
/// <summary>
/// 监听
/// </summary>
void Listen();
/// <summary>
/// 设置屏幕id
/// </summary>
/// <param name="id"></param>
void SetInterScreenID(int id);
/// <summary>
/// 设置guid
/// </summary>
/// <param name="strGUID"></param>
void SetGUID(string strGUID);
/// <summary>
/// 设置用户名
/// </summary>
/// <param name="strNm"></param>
void SetUserNm(string strNm);
/// <summary>
/// 获取所有遥信点
/// </summary>
/// <param name="isDynamic"></param>
/// <returns></returns>
List<Proxy_YXItem> GetTotalYXDataEx(bool isDynamic);
/// <summary>
/// 获取所有设备数据
/// </summary>
/// <param name="isDynamic"></param>
/// <returns></returns>
IEnumerable<Proxy_EquipItem> GetTotalEquipData(bool isDynamic);
/// <summary>
/// 获取所有遥测点
/// </summary>
/// <param name="isDynamic"></param>
/// <returns></returns>
List<Proxy_YCItem> GetTotalYCData(bool isDynamic);
/// <summary>
/// 获取初始化数据
/// </summary>
/// <returns></returns>
List<RealTimeEventItem> FirstGetRealEventItemEx();
}
- 示例代码(代码不可执行,仅供参考)
代码
var alarmCenterServiceClient =new AlarmCenterService();
callBackService.InterScreenOpenPage("123", new InterScreenEventArgs("123", "123", false, false, "123", false) { }, (a, b, c, e, f) =>
{
Console.WriteLine($"{a}_{b}_{c}_{e}_{f}");
});
callBackService.Login((a, b) =>
{
Console.WriteLine($"{a}_{b}");
});
# 5. 消息接收,可通过NetMQ来接收消息
在登录方法中MqIdentity,该字段为netmq的消息推送密钥经过两次加密后的密文。 获取到此字段值后,使用nuget.ganweicloud.com里面的GWCrypto包的解密方法,进行解密后,可得到消息推送密钥了。
解密流程为:
代码
var cyptoServiceProvider = new CyptoServiceProvider();
input = cyptoServiceProvider.CreateDecryptor(”密文“, out string msg);
拿到密钥后,按这个方法来连接netmq发布端。
代码
using (var server = new SubscriberSocket())
{
var cert = NetMQ.NetMQCertificate.CreateFromSecretKey(UTF8Encoding.UTF8.GetBytes(”这里是密钥“));
var curveServerCertificate = serverPair;
var clientCertificate = new NetMQCertificate(); ---这里是客户端密钥,
server.Options.CurveServerCertificate = curveServerCertificate; ---这里是使用服务端密钥
server.Options.CurveCertificate = clientCertificate; ---这里是客户端密钥,
server.Connect(address);
server.SubscribeToAnyTopic();// ("Topic");
while (true)
{
var response = server.ReceiveMultipartMessage();
Console.WriteLine(response.Last.ConvertToString());
}
}
上次更新: 6/19/2023, 9:27:24 AM