#ifndef PROJECT_MODEL_H #define PROJECT_MODEL_H #include #include #include #include #include #include "tools.h" struct ProjectManagerStruct { int id = 0; QString name; // 工程模表名 QString tag; // 工程模名称 QString metaModel; // 元模名 QString groupName; // 属性组名 int linkType; // 图元链接类型 QJsonObject checkState; // 属性选择状态 }; struct ProjectModelSettingStruct //工程模设定类,如图标 { QString modelName; //工程模名 QMap mapSvg; //存放选择的svg图片 QMap mapUsedSvg; //存放使用的svg }; struct PropertyState { bool checkState = false; QString dataType; bool editable = true; }; struct PropertyPage { QMap checkState; bool isPublic = false; }; struct FormerName //曾用名,记录修改前名称 { QString sName; bool bChanged = false; //是否改变过 }; typedef QMap MapProperty; struct PropertyModel { MapProperty mapProperty; int nType = 0; //工程模类型,选择图标后确定 QStandardItemModel* pBase = nullptr; //基础属性 QStandardItemModel* pSelect = nullptr; //已选择属性 FormerName formerMeta; //曾用元模名 FormerName formerProject; //曾用工程模名 QMap dataInfo; //存放数据库内容 ProjectModelSettingStruct modelSetting; PropertyModel deepCopy() //深拷贝 { PropertyModel copy; copy.mapProperty = mapProperty; copy.nType = nType; copy.pBase = deepCloneModel(pBase); copy.pSelect = deepCloneModel(pSelect); copy.formerMeta = formerMeta; copy.formerProject = formerProject; copy.dataInfo = dataInfo; copy.modelSetting = modelSetting; return copy; } void release() { delete pBase; delete pSelect; pBase = nullptr; pSelect = nullptr; } }; typedef QMap MapProject; //str为工程名,PropertyModel为工程属性 typedef QMap MapMeta; //str为元模名,PropertyModel为工程模集 struct PropertyStateInfo { QString name; // 属性名 QString tagName; // 别名 QString type; // 属性类型 QVariant defaultValue; // 默认值 int lengthPrecision = 999; // 长度限制 int isVisible = 1; // 是否可见(0不可见,1可见,2特殊项) bool lock = false; // 值手动改变时置true,下次保存时恢复 }; Q_DECLARE_METATYPE(PropertyStateInfo) // 属性值信息映射 typedef QMap PropertyValueInfo; // 属性组状态信息 struct GroupStateInfo { QString groupName; // 组名 QString tableName; // 表名 bool isPublic = false; // 是否公共 PropertyValueInfo info; // 属性信息 }; // 属性组实时数据 struct GroupStateValue { QString groupName; // 组名 QString tableName; // 表名 QMap mapInfo; // 实时信息映射 }; struct ModelStateInfo //模型结构信息 { QString modelName; int modelType; QWidget* _PropertyDlg = NULL; //属性设置界面,每个模型维护一种界面 QMap groupInfo; //属性组信息 void release() { if(_PropertyDlg){ delete _PropertyDlg; _PropertyDlg = nullptr; } } }; struct ModelDataInfo //模型数据信息 { QString modelName; int modelType; QMap groupInfo; //属性组实时信息 }; struct PropertyGroupState { QString groupName; // 属性组名称 QString tableName; // 属性组表名 QJsonObject propertyState; // 属性状态信息 }; struct MeasureAttributeType //量测可用属性类型(从基模获取的占位符变量) { QString tag; QString name; }; // 属性内容信息 struct PropertyContentInfo { QString proTag; // 属性标签 QString proName; // 属性名称 QString proType; // 属性类型 QWidget* proEditor = nullptr; // 编辑窗口对象 bool isValid() const { return !proTag.isEmpty() && !proName.isEmpty(); } }; struct PtExtraInfo { int index = 0; QString scope; //变比标签 QString accuracy; //精度等级标签 QString volume; //二次负载容量标签 QString star; //线圈接法 double ratio; //变比 int polarity = 1; //极性 }; struct CtExtraInfo { int index = 0; QString scope; //变比标签 QString accuracy; //精度等级标签 QString volume; //二次负载容量标签 double ratio; //变比 int polarity = 1; //极性 }; struct MeasurementInfo //量测 { QString tag; //量测tag QString name; //量测名称 int type; //量测类型 0:遥测 1:遥信 2:遥控 int size; //量测size QUuid bayUuid; //所属间隔 QUuid componentUuid; //所属设备 //通讯 int nSource; //数据来源 1:cl3611 2:104 QString sStation; //子站名称 QString sDevice; //设备名称 QString sChannel; //通道名(cl3611) 遥测:TMx(1-8); P; Q; S; PF; F; deltaF; UAB; UBC; UCA; 遥信: TSxx(01-10); 遥控: TCx; int nPacket; //包号(104) int nOffset; //偏移量(104) //事件 bool bEnable = false; //"enable"开启标志 QMap mapTE; //遥测"cause" key:upup,up,down,downdown可选,val:0-100 QString sEdge; //遥信"cause:edge" raising, falling 字符串单选 QString sCommand; //"action:command" info, warning, error, critical, exception 字符串单选 QStringList lstParameter; //"action:parameters" 字符串数组 QString sWindType; //绕组类型 ctpt int nRatio; //变比 int nPolarity; //极性 int nIndex; //对应绕组序号 QString sSymmetry; //对称量测的name }; // 定义比较键的结构 struct MeasurementKey { int nSource; QString sStation; QString sDevice; QString sChannel; int nPacket; int nOffset; MeasurementKey(const MeasurementInfo& info) : nSource(info.nSource) , sStation(info.sStation) , sDevice(info.sDevice) , sChannel(info.sChannel) , nPacket(info.nPacket) , nOffset(info.nOffset) {} // 用于QMap排序 bool operator<(const MeasurementKey& other) const { if (nSource != other.nSource) return nSource < other.nSource; if (sStation != other.sStation) return sStation < other.sStation; if (sDevice != other.sDevice) return sDevice < other.sDevice; if (sChannel != other.sChannel) return sChannel < other.sChannel; if (nPacket != other.nPacket) return nPacket < other.nPacket; return nOffset < other.nOffset; } }; struct ComponentInfo //工程模图元数据 { QUuid uuid; QString modelName; QString nspath; QString tag; QString name; QString description; QString grid; QString zone; QString station; int type = 0; bool inService = true; int state = 0; QJsonObject connected_bus; QJsonObject label; QJsonObject context; int op = 0; }; struct ComponentTypeInfo //元件类型 { int id = 0; QString type; QString name; QJsonObject config; }; struct PageInfo { int id = -1; QString tag; QString name; QJsonObject label; QJsonObject context; QString description; int op; }; // 页面中保存的项信息 struct ItemPageInfo { QPointF pos; double dWidth = 0.0; double dHeight = 0.0; double dRotate = 0.0; }; #endif