3 Star 4 Fork 2

zhigangli2020 / LIB319

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

WinCC OA通用低代码库LIB319(及中文包)

0. 前言

WinCC OA通用低代码库LIB的目的是可以通过简单的几步工作,实现如下的只有专业监控软件才能具备的功能:

当报警发生,右侧导航将能在导航按钮观察到“一级报警”、“二级报警”、“三级报警”不同位置的红色警示点。点击后追寻到报警设备,继续点击弹开设备面板,显示设备详细数据,读、写、报警三个栏是分离的。报警位置可以进行确认。同时,弹窗弹出报警信息,语音播报出来。10s后自动弹窗关闭。

支持被控设备的模型及模型面板

  • 点位信息导入(PLC地址、单位、权限、描述、上下限)
  • 画面拓扑、导航、导航菜单、导航框架的自动生成
  • 软件运行环境模板
  • 数值设定、操作的二次弹窗
  • PLC写数据过程的反读校验
  • 操作日志
  • 设备面板的历史数据曲线、历史操作记录、简单数据报表
  • 实时报警、历史报警、报警条
  • 历史事件查询
  • 动态趋势、固定趋势配置
  • 语音报警、报警弹窗、报警画面
  • 样式表
  • 支持中英文环境
  • 支持后期扩展到冗余、分布式、web客户端等架构
  • 支持最新的WinCC OA 3.19特性,如趋势图的动态采样
  • 自动历史归档配置

同时,支持数据看板功能,可实现对服务器、交换机网络、历史数据库(influxDB)等运行工况进行监视。

图:历史数据库influxDB运行监控

图:系统主机(Windows或Linux)进行监控

1. 准备

需要具有第三方免费代码托管网站 https://www.gitee.com 账号。请先注册。

不注册的情况,可以拷贝已经下载了的上述的两个zip,但不确保是最新版本。

基础库LIB319的下载同步

1. 新建工程文件夹

1.1 新建LIB319库文件夹

C:\WinCC_OA_Proj\LIB319

1.2 中文包CN319的下载同步

C:\WinCC_OA_Proj\CN319

https://gitee.com/zhigangli2020/wincc-oa-chinese/ 下载后解压3.19 中文包到该路径。如下图所示

config文件举例

host文件存储位置是:

[WINDOWS] C:\windows\system32\drivers\etc\hosts
[LINUX] /etc/hosts

如果没有此文件,需要手工创建。

服务器主机、备机、客户端、其他与WinCC OA之间相互通讯的主机(如远程驱动的主机等)均需要使用hosts文件,集中存储不易记住和识别的IP地址信息。

hosts 文件的规范:

127.0.0.1 localhost SVR01
::1 localhost SVR01

\# 以下为服务器的IP(举例)
192.168.100.219 SVR01 SVR01-1
192.168.101.219 SVR01-2

192.168.100.220 SVR02 SVR02-1
192.168.101.220 SVR02-2

192.168.100.221 Client01 Client01-1
192.168.101.221 Client01-2

第一行的 localhost之后,请追加填写当前的主机的名称。(注,每个主机都不一样,请自行修改)。

冗余网络的情况,请将SVR01当作主访问域名,第一个网卡命名SVR01-1当作别名1,第二个网卡SVR01-2当作别名2.

需要将客户端的IP地址也填入。格式如上的Client01

2. 新建项目

2.1 新建项目

勾选Legacy Standard project

使用经典项目。

  1. 输入项目名称。如PEX
  2. 按住Ctrl键,多选语言(2 selected)
  • en_US.utf8
  • zh_CN.utf8
  1. 项目路径(请选择固态硬盘所在的磁盘分区): C:/WinCC_OA_Proj/
  2. 勾选 Runnable、Use NGA

选择经典图标模式

不创建root项目管理密码。

注册CN319中文库

1的位置注册项目
2的位置打开路径
3的位置确认即可

注册LIB319基础库

1的位置选择注册项目。
2的位置打开文件夹选择按钮,选择基础库LIB319的文件夹。
3的位置选择文件夹。Runable应该是灰色。

注册完后的基础库,只有基本素材,不含有数据库,不能当作项目来运行。项目管理器应该看不到。

2.2 集成基础库

将基础库LIB319加入到子项目

打开项目管理器,

1的位置管理项目配置。
2的位置配置子项目集成
3的位置将CN319,LIB319选择到右侧。

注意:PEX项目的Gedi运行之后,项目管理器应当如下

运行项目后,可以在项目管理路径下,发现CN319, LIB319已经被集成当作子库。

项目的config文件应该是这样

2.3 初始化LIB参数

DP点清理

进入到Gedi开发环境,展开项目后,找到2的位置。

2的位置找到“删除DP.xml”的按钮

其功能为:将执行“清除全部DP” 将清除现有的所有DP。(不清除_为前缀的内部DP)。自动“创建DP” 创建_Ui,_Driver等内部需要的DP。

点击运行画面。执行上面的步骤。

2.4 创建S7驱动,

参数 -num 3

1的位置选择添加Manager
2的位置选择S7 Driver
3的位置输入 -num 3, 注意有空格
4的位置确认
5的位置应当看到运行起来状态是绿色的2.

注意:

若是危险品、重大资产的调试操作,应当先建立-num 3的simulation driver,不要直接在实际的驱动进行操作!

手工创建占位连接SIEMENSPLC01

只是为了占位。不激活。

1的位置打开系统管理。
2的位置找到S7驱动
3的位置创建,输入SIEMENSPLC01此名称有重要的占位作用,不得起其他的名称。
4的位置确认 不要激活驱动,直接点击4,确认即可。

2.5 新建一个PLC连接

新建实际用的PLC

确保num 3号驱动是S7 Driver Manager,已经在运行

新建的某个PLC名称:F1_CUB_1_PEX_PLC01

1的位置找到S7驱动管理

2的位置点击新建,输入PLC名:F1_CUB_1_PEX_PLC01。

3的位置输入隶属的驱动的num号,本例为数字3。

4的位置激活“Set Invalid bit”激活无效位

5的位置如果是冗余PLC,S7-400H则勾选冗余设备(如400H). 如果是单机PLC,不需要勾选。

6的位置输入IP地址。可以是DNS名称或纯IP

7的位置选择“Other”。“其他”指的是S7 PLC具有更多的通讯的资源连接数量。

8的位置为冗余的备机PLC进行设置IP地址等参数。

9的位置激活PLC通讯,同时在State可以查看连接状态是否正常。

新建对应的模拟驱动

如上图所示:应当在控制台,在

1的位置S7 Driver 具有相同的-num 号-num 3

2的位置同时建立一个Simulation Driver

必读的重要提示: 导入点位的过程,应当使用Simulation Driver,测试和通讯PLC的过程及生产过程,应当使用S7 Driver;或者将PLC的激活勾选项设置为禁用。 这是因为导入点位的过程,很可能会将DO, AO等执行指令下发给PLC,导致PLC的设备动作,这是极其危险的,应当不能用真实的S7 Driver,而是替代Simulation Driver来实现。Simulation Driver将只是用于配置地址信息等数据,不会做出任何与PLC的读写通讯。

3 导入点位

3.1 导入 LIB.dpl 点表基础模型

将LIB319的C:\WinCC_OA_Proj\LIB319\dplist\LIB.dpl用notepad++打开,替换里面的DUMMY字段,本例替换为项目名称PEX

然后再导入LIB.dpl,

1的位置打开ASCII manager导入工具

2打开按钮,浏览文件。

3的位置,选择库LIB319的dplist文件夹

4选择修改了的LIB.dpl

5勾选自动更新DP 类型、导入报警属性。

3.2 拷贝点位模板

拷贝库点位原始模板的文件夹

LIB319\data\dp\DUMMY\

到项目文件夹的对应路径下。 应当有如下例子的文件路径:

C:\WinCC_OA_Proj\PEX\data\dp\PEX\F1_CUB_1_PEX_PLC01\01_VFD.txt

将其中文件夹路径、PLC命名、文本文件里面的DUMMY全部替换为PEX.

项目路径下,如1的位置、

2的位置,都把DUMMY换成了PEX

3.3 编辑点位

示例01_VFD.txt存储的是用于某个PEX项目的变频调节器(如变频泵等)模板。

用notepad++打开。

可以复制文本粘贴到Excel编辑。Excel必须在使用前,对全部单元格进行格式化成text纯文本格式。否则将自动进行格式化,再进行粘贴操作,否则会出现一些不可预知的错误。

项目 描述 单位 格式 量程L 量程H 报警死区 高高报警限值设定 高报警限值设定 低报警限值设定 低低报警限值设定 高高报警使能 高报警使能 低报警使能 低低报警使能 仪表下限 仪表上限 过程值 仪表故障 高高报警 高报警 低报警 低低报警 占位
字段1 CMD CMD CMD CMD CMD CMD CMD CMD CMD CMD CMD STATE ERROR ERROR ERROR ERROR ERROR 占位
字段2 DEADBAND HH_SP H_SP L_SP LL_SP HH_EN H_EN L_EN LL_EN LOW_SPAN HIGH_SPAN VAL_IN ALM HH_ALM H_ALM L_ALM LL_ALM 占位
数据类型 AO AO AO AO AO DO DO DO DO AO AO AI DI DI DI DI DI 占位
报警等级 二级报警 一级报警 二级报警 二级报警 一级报警 占位
操作权限 6 7 7 7 7 6 6 6 6 7 7 占位
F1_CUB_1_1_102_XF_TIT01 CUB_1_1_102_XF_TIT01消防泵房温度检测 %4.2f 0 100 DB2395.DBD68 DB2395.DBD72 DB2395.DBD76 DB2395.DBD80 DB2395.DBD84 DB2395.DBX96.0 DB2395.DBX96.1 DB2395.DBX96.2 DB2395.DBX96.3 DB2398.DBD8 DB2398.DBD4 DB2395.DBD142 DB2395.DBX114.0 DB2395.DBX156.0 DB2395.DBX156.1 DB2395.DBX156.2 DB2395.DBX156.3 占位
F1_CUB_1_CUB_RO_FQIT01 CUB西南侧纯水流量检测 m³/h %4.2f 0 100 DB1554.DBD68 DB1554.DBD72 DB1554.DBD76 DB1554.DBD80 DB1554.DBD84 DB1554.DBX96.0 DB1554.DBX96.1 DB1554.DBX96.2 DB1554.DBX96.3 DB1557.DBD8 DB1557.DBD4 DB1554.DBD142 DB1554.DBX114.0 DB1554.DBX156.0 DB1554.DBX156.1 DB1554.DBX156.2 DB1554.DBX156.3 占位
F1_CUB_1_WT_CW_FQIT01 CUB市政补水流量检测 m³/h %4.2f 0 100 DB1586.DBD68 DB1586.DBD72 DB1586.DBD76 DB1586.DBD80 DB1586.DBD84 DB1586.DBX96.0 DB1586.DBX96.1 DB1586.DBX96.2 DB1586.DBX96.3 DB1589.DBD8 DB1589.DBD4 DB1586.DBD142 DB1586.DBX114.0 DB1586.DBX156.0 DB1586.DBX156.1 DB1586.DBX156.2 DB1586.DBX156.3 占位
F1_CUB_1_WT_CWS_FQIT01 CUB冷却塔补水泵流量检测 m³/h %4.2f 0 100 DB1546.DBD68 DB1546.DBD72 DB1546.DBD76 DB1546.DBD80 DB1546.DBD84 DB1546.DBX96.0 DB1546.DBX96.1 DB1546.DBX96.2 DB1546.DBX96.3 DB1546.DBD142 DB1546.DBX114.0 DB1546.DBX156.0 DB1546.DBX156.1 DB1546.DBX156.2 DB1546.DBX156.3 占位

按上述格式,填写数据,修改地址等。参见导入dp点的标准格式.xlsx

  • 蓝色部分是手工填入的点位汉字描述。

  • 橙色部分是手工填入的PLC地址。允许为空。

Excel编辑点位设计规范:

  • 字段1的规范:只允许 CMD,STATE,ERROR这三种
  • 字段2的规范:只允许大写字母与下划线
  • 数据类型的规范:只允许AI,AO,DI,DO,WORD,DWORD,PULSE_OPEN,PULSE_CLOSE这几种。
  • 报警等级规范:只允许一级报警、二级报警、三级报警这三种
  • 操作权限:只允许填写6,7 这两个;6代表一般操作启停控制;7代表参数修改。
  • 最后一列必须是“占位”单元格。
  • 地址不希望存在、无效、都可用将地址单元格留空。
  • 模拟量的格式:%4.2f 代表4个整数,2个小数。
  • DP设备点命名只允许有大写,下划线。
  • 暂不支持“AI报警”点位的快速导入。需要手工建立。

修改完后,将字段拷贝重新贴回到01.VFD.txt

3.4 导入S7点位

在GEDI环境修改基础库LIB319路径下的panels/tools/导入点位工具.xml的源码,适配这个01.VFD.txt

打开“自动创建 DP TYPE”按钮,修改main函数之前的几行,如VFD的设备,改完之后如下:

string path = getPath( DATA_REL_PATH ) + "dp/PEX/F1_CUB_1_PEX_PLC01/01_VFD.txt"; // !!! 读取文件路径
string dpType = "FMCS_PEX_VFD";  // !!! 改DP类型的名称 
string  SubSystemPrefix = "PEX"; // ATOM 点位的前缀,组合后应当为:LIB_ATOM_MEP_AI_S7, LIB_ATOM_MEP_DI_S7
string PLCType= "S7"; // 可能选项: S7, MODBUS, AB,OMRON...

主要是文件路径,DP类型,子系统前缀名称(MEP,CR,UPW,WWT…), PLC类型(S7,MODBUS,AB…)

复制两个按钮出来,进行修改代码。分别执行两个按钮,将会在日志有所提示。

  1. 自动创建DPTYPE.
  2. 自动创建DP

注意:按钮一旦修改代码完成并导入数据,最好不要删除,以便将来再次复查修改和追踪原因。

1的位置点击右键,编辑类型,

2的位置查看结构是否与TXT文本文件定义的结构完全一致。

3的位置检查是否正确引用了ATOM的类型。

如果DP TYPE创建正常,则执行

4,5。。。自动创建该类型的DP点位。

若提示导入的点位是“OK”,则证明导入的点位、地址和txt文本文件的校验是基本上没有问题的,但也必须要辅助进行人工复查多次检验,进行最后的确认。

3.5 导入Modbus点位

示例表格:

C:\WinCC_OA_Proj_319\LIB319\data\dp\DUMMY\Mod_Plc_1\06_AI.txt

拷贝到项目路径,示例:<项目路径>\data\dp\PEX\Mod_Plc_3\06_AI.txt, 用Notepad++打开,拷贝全部字符,到Excel粘贴。Excel表格在使用前,需将全部单元格格式化为字符,否则地址信息带有.0后缀的会出错。

按前文所述,编辑字段1,字段2,地址表。地址表的格式:

M.3.3.68.0

M.PLCId.FunctionCode.ReferenceAddress.Offset

PLCId: 在WinCC OA中建立的modbus驱动的ID号。一般一个driver可以带若干个Modbus PLC(PLCId), 用不同的PLCId进行区分。

PLCId: Modbus PLC的ID号,一般是1开始的数字,在配置Modbus PLC IP地址的界面来获得。

FunctionCode:功能码,如3代表读4x0000区的寄存器地址。

ReferenceAddress:基准地址。

Offset:偏移的bit位,仅对只读的bool量有意义。其他类型都写0

上述地址不得缺失信息,必须包含四个”.”。

LIB319/dplist/LIB_MODBUS.dpl通过ASCII manager导入到系统。

1,2的位置选择LIB_MODBUS.dpl

3的位置勾选自动更新类型和导入报警属性。

然后观察是否已经导入了ATOM类型的Modbus基础类型点位:

然后,编辑完点位清单,打开LIB319/tools/LIB_DPImportTool_Modbus.xml,对DPTYPE, DP导入的按钮进行适配。

如上图,DP TYPE按钮的修改,将路径、dpType名称,SubSystemPrefix,PLCType进行匹配。执行后即可得到

FMCS_PEX_AI_MODBUS的类型。继续下一步导入点位。

1的位置调整路径。

2的位置调整位PEX对应的dpType

3的位置调整PLC的PLCId的序号。

4的位置输入驱动 -num 的号码。通常Modbus从13开始比较好。(1,2预留。3~10预留给S7 驱动,11,12,是Modbus仿真和测试的驱动号)。

5的位置如果是true,则完全重新建立DP,进行地址覆盖(会丢失历史数据)。如果是false,将不对现有的dp进行覆盖。

4 编辑开发画面对象

4.1 设备建模概述

以这个设备对象FMCS_CR_PUMP为例

点位点表:

将点表转换为设备数据模型:

配置各个点位的参数、属性。

将模型进行实例化。相同的属性,设置为继承自设备模型的配置,无需再次编辑。不同的属性,如地址,配置成可修改的模式,后期进行批量修改。

上图描述了实例化和自动继承的关系。

画面建模

panels 文件夹下,一级文件夹必须为

MEP_SYS

其中MEP是子系统的名称。MEP_SYS文件夹存储全部的PEX的项目画面。将LIB 319的示例面板、示例设备对象(AI,PUMP…)等拷贝到项目的panels路径下,更改文件夹名称为XXX_SYS,XXX为项目名称,如PEX_SYS

使用Notepad++对MEP_SYS的整个文件夹进行文本替换

选择文件查找替换的窗口,输入项目文件夹路径,对字符串MEP,全部替换为PEX.然后对文件夹结构进行编辑。

文件夹结构规范:

PEX项目的panels/PEX_SYS文件夹下,CUB_1.xml, CUB_2.xml是同名的文件夹CUB_1, CUB_2的索引。里面只摆放导航画面。

CUB_1、CUB_2文件夹下,需要具体存放一些设备、工艺的画面。用规范化的命名进行文件命名。如上图。

1的位置是PEX_SYS

2的位置是CUB_1.xml 及同名的CUB_1文件夹。同名的索引文件将会在PT.xml自动生成。

3的位置是CUB_1文件夹内部的设备。

支持多层文件夹嵌套,但一定要在每个层面的文件夹用上面的规范(文件夹及同名.xml的索引文件)进行设计文件夹结构。不得使用中文、异形字符、空格。只允许下划线、首字母。

4.2 拓扑文件夹编辑

打开LIB319/tools/PT.xml,

将源码中出现MEP_SYS的地方,替换成PEX_SYS,保存点击运行。(可以在Notepad++打开PT.xml批量将MEP替换为PEX)。

在第141行左右,需要过滤掉的文件夹的列表。这里要改一下文件夹名称字符串进行过滤。改造后:

打开拓扑编辑。

1的位置打开

2的位置查看展开后和文件夹是否完全一致。每个画面节点和xml文件有无准确匹配。

1的位置点击报警等级范围

2的位置分别点击LIB_Alert_Level1,LIB_Alert_Level2,LIB_Alert_Level3,确认

此时会更新下面的内部点_SumAlertPanel的DP结构。

4.3 拓扑模板

1的位置编辑默认的模板。

2选择LIB

3选择高级配置

4选择手动,1920x1080

5 确认。

修改模型的REFERENCE

如果前面步骤尚未使用Notepad++批量对PEX_SYS文件夹里面的文件出现MEP的地方进行替换成PEX,可以手动进行如下的步骤:

拷贝库的LIB319/MEP_SYS/MEP_M文件夹到项目的PEX_SYS路径下。

1打开icon_AI/REFERENCE.xml, 双机3的位置,

修改为这个点位的DPTYPE Name:FMCS_PEX_AI

1的位置打开AI.xml

2的位置空白位置点击后,找到属性“参考文件”,打开,找到项目路径下的REFERENCE.xml,上个小节已经修改过该文件。

保存。

其他的PUMP,VALVE,FAN, PID, VFD….等所有的设备画面,都照此方法调整和保存。

4.4 编辑开发画面

1的位置找到AI.xml, 代表模拟量仪表监控的设备对象。

拖放到2的位置。

3观察是否为设定的FMCS_PEX_AI的设备模型

4自动拆分字段,快速找到分组

5选择DP点位。

6确定保存画面

4.5 导航配置及拓扑自动报警汇总

1的位置打开CUB_1.xml,

2的位置若没有导航按钮,就复制一个。

双机后,3的位置选择被索引的画面节点。

然后:

当每次将画面、拓扑文件夹自动创建之后,都需要按步骤生成自动汇总报警

1的位置打开拓扑编辑

2的位置点击全部树节点

3,4的位置保存和检查

4.6 配置右侧导航栏

1的位置搜索1920,找到naviPanel

2 的位置找到打开

3的位置双机导航按钮,选择被导航的索引的位置。保存画面。

5 客户端、冗余、分布式系统及工程项目配置

5.1 冗余服务器系统配置

冗余主机、备机文件夹路径、项目文件名通常完全100%的一致。首次部署冗余备机时候可以手动复制项目文件。

config文件添加:

data = "SVR01-1,SVR01-2$SVR02-1,SVR02-2"
event = "SVR01-1,SVR01-2$SVR02-1,SVR02-2"

console控制台添加:

Redundancy Manager
Split Mode Manager

5.2 冗余客户机的配置:

前提条件:配置好客户端hosts、计算机名、IP地址,搭建好SVN的库版本管理客户端。

与服务器一样,将CN319,LIB319拷贝或同步到客户端的项目文件夹。不建议合并此两个文件夹。

建议将项目的其他的项目的静态的画面、颜色、图片、程序脚本、建成一个SVN的库,使用SVN同步来完成,实现版本管理。

通过拷贝文件方式

<LIB319>/source/客户端项目模板文件夹改名(如 OS1),拷贝到客户端的项目文件夹下。

注册到WinCC OA,并配置CN319,LIB319库,项目库的依赖,注意顺序不要反。

修改<客户端项目>/config/config文件,配置

data = "SVR01-1,SVR01-2$SVR02-1,SVR02-2"
event = "SVR01-1,SVR01-2$SVR02-1,SVR02-2"

使得能够通过网络连接到服务器。此时即可启动 如果客户机有contrl 脚本用ctrl Manager运行,需要在config文件添加

[ctrl_2]
connectToRedundantHosts=1

其中ctrl_2代表-num 2 的contrl manager。

5.3 分布式系统配置

在子节点(或分布式中央节点)修改项目config文件


[dist]

maxSystemsToInitialize = 0 # 0,unlimit

maxUpdateMsgCount = 400000

requestIdDelay = 100

distPeer = "SVR01-1,SVR01-2\$SVR02-1,SVR02-2" 3

修改红色字体适配到实际项目。

在console添加Distribution Manager

LIB319/SYSTEM_ID.bat,用记事本打开里面的代码行,

C:\Siemens\Automation\WinCC_OA\3.19\bin\WCCOAtoolSyncTypesSQLite.exe -system 1 MEP -proj "FMCS_MEP_319"

修改上面的变量参数适配到实际项目。

5.4 重新设定报警筛选条件

实时报警、历史报警的筛选

1的位置打开报警、事件、画面配置与编辑

2的位置选择预配好的,如LIB_OnlineAlert

3的位置选择设定

在弹窗中,找到过滤系统,找到要显示的分布式系统,点击“显示”,激活此系统的显示。或者点击“所有可用的系统”。

5.5 报警条的筛选

1的位置点击“编辑报警条”,在设定页面与上文相同进行参数设定。

6 版本管理SVN

通常是运行在版本管理服务器上做版本管理服务的软件。

主机、备机、OS客户端、工程师站都与版本管理服务器做版本同步。

地址格式举例:https://SVR01:10443/svn/MEP/

集成到Gedi

<LIB319>/config/config.level 用文本工具打开,拷贝下面这段

[ui]
versionControl = "SVN" \# 默认使用SVN进行版本管理
versionControlDiff = "C:/Program Files/TortoiseSVN/bin/TortoiseUDiff.exe" \# 默认使用SVN进行版本管理,客户端的默认路径

到项目的config 文件,以便于Gedi可以使用SVN的环境。否则只能在Windows文件夹进行SVN管理。

集成到运行系统

使用LIB的库模板,会在下方的工具栏多一个“自动版本更新”的切换开关。鼠标悬停后,可以弹出窗口显示当前的项目(支持多个层级)的库的版本信息。当切换到自动更新模式,将会在后台以10s为周期自动更新SVN服务器的项目版本到本地硬盘。

备份与恢复influxDB数据库

7 influxDB的备份与恢复

7.1 备份

C:\Siemens\Automation\WinCC_OA\3.19\data\NGA\InfluxDB\sql>backupInfluxDB.cmd --help

Usage: backupInfluxDB.cmd [\<command\> \<argument\>] \<InfluxDB-backup-path\>

The commands are:

\--database The name of the database (default is "winccoa")

\--host Host and port of the database (default is "127.0.0.1:8088")

\--max-backup-count Number of backups kept (default is 3)

示例:

C:\Siemens\Automation\WinCC_OA\3.19\data\NGA\InfluxDB\sql>backupInfluxDB.cmd --database winccoa --host localhost:8088 d:\influxdb_backup

2023/07/15 00:33:37 backing up metastore to d:\influxdb_backup\20230715-003337\meta.00

2023/07/15 00:33:38 backing up db=winccoa

2023/07/15 00:33:38 backing up db=winccoa rp=ALERT shard=3 to d:\influxdb_backup\20230715-003337\winccoa.ALERT.00003.00 since 0001-01-01T00:00:00Z

7.2 恢复

C:\Siemens\Automation\WinCC_OA\3.19\data\NGA\InfluxDB\sql>restoreInfluxDB.cmd --help

Usage: restoreInfluxDb.cmd [\<command\> \<argument\>] \<WinCC-OA-project-name\> \<InfluxDB-backup-path\>

The commands are:

\--database The name of the database (default is "winccoa")

\--host Host and port of the database (default is "127.0.0.1:8088")

\--backup The backup folder name (e.g. 20211021-133236) inside \<InfluxDB-backup-path\> (default is the newest backup)

\--password The password for the InfluxDB authentication, no further password prompt is shown

(only ASCII characters are allowed in passwords when using this command)

\--username The username for the InfluxDB authentication, no further username input prompt is shown

(only ASCII characters are allowed in username when using this command)

\--silent The user will not be asked to confirm that the current database will be overwritten

(This command is a switch and needs no argument)

\--timeout The timeout after the influxd restore operation (default is 10 seconds)

举例:

C:\Siemens\Automation\WinCC_OA\3.19\data\NGA\InfluxDB\sql>restoreInfluxDB.cmd FMCS_MEP_DEMO d:\influxdb_backup

The database "winccoa" has to be dropped from InfluxDB before restoring from d:\influxdb_backup. All data in "winccoa" will be lost!

Do you want to continue [y/n]? y

Username: etm

Password: *******(密码etm#123)

Starting up influxd -config C:\WinCC_OA_Proj\FMCS_MEP_DEMO\config\influxdb.conf

Dropped database "winccoa" from InfluxDB

Restoring database "winccoa" from backup 20230715-003337

2023/07/15 00:39:30 Restoring shard 44 live from backup 20230714T163337Z.s44.tar.gz

2023/07/15 00:39:30 Restoring shard 8 live from backup 20230714T163337Z.s8.tar.gz

7.3 数据库界面管理

1的位置,找到DB,DB_2,DB_R,DB_R_2,四个本机历史库的参数,

2的位置,填写

Database wincc_oa

backupPath 空(空的意思是默认存储到<projdir>/db/wincc_oa/influx/backup)

backupHostConnectionString 127.0.0.1:8088

backupHostConnectionString是influxdb的config文件中全局参数bind-address=":8088"定义的。

中央历史库的参数界面

在1 的位置,找到中央历史库HIS,HIS_2,HIS_R,HIS_R_2,

在2的位置,填写如下参数:

database winccoa

backupPath C:/influx/db2/backup

influxBinPath C:/Siemens/Automation/WinCC_OA/3.17/bin

dpNameFilterSplitSize 100

backupHostConnectionString H5:9088

databaseStartupTimeout 2

其中,backupPath指的是将中央历史库的数据,存储到本地硬盘的路径。

InfluxBinPath指向本地的influxd程序

backupHostConnectionString是中央历史库的连接符。本例中的中央库的influx的conf配置文件中应当为:bind-address=":9088"

7.4 历史归档操作界面

1的位置选择本地(或中央)的历史归档组。

2 的位置选择时间段

3 的位置点击备份按钮,即可自动调用备份程序进行备份。

同时,在备份路径下,可以观察自动生成的一系列备份历史库的文件。

1的位置观察,已经变化为状态“在线和备份”

在备份路径下,已经生成了对应的归档组的备份文件。

备注:备份文件夹的内容可以直接手工删除,此时,归档组的状态又会变化为“在线”。

如果点击删除按钮,将会删除中央历史库实时在线的历史库。

点击offline and backed-up(离线并已经备份),可以对备份的历史再次恢复

8 系统运维与诊断(Windows系统、influxDB数据库)

针对主机(或备机)安装influxDB(8086)历史库运行influxDB的情况。

下载三件套:

例如版本:

  • chronograf-1.10.1_windows_amd64.zip
  • influxdb-1.8.10_windows_amd64.zip
  • telegraf-1.28.2_windows_amd64.zip

8.1 安装telegraf

[windows]

生成telegraf config配置文件

telegraf --input-filter system:mem:swap:disk:diskio:nstat:cpu:processes:kernel:filesystem:influxdb --output-filter influxdb config > telegraf.conf

修改生成的配置文件。

或者直接用附件的配置文件:telegraf.conf

测试

telegraf -config "C:\software\telegraf\telegraf.conf"

安装windows开机服务

telegraf --service install --config "C:\software\telegraf\telegraf.conf"

telegraf.exe --service install #安装服务

telegraf.exe --service uninstall #删除服务

telegraf.exe --service start #启动服务

telegraf.exe --service stop

安装 chronograf

nssm install chronograf

填写必要的参数,注册成功名为chronograf的windows服务。

在服务中,找到chronograf,启动。

用浏览器http://<INFLUXDB_SVR>:8888 进行访问

配置chronograf 的 dashboard

配置influxdb的连接

  • 1. 新建数据源,填写LOCAL8086, 代表主机INFLUXDB_SVR,开放端口8086的influxDB,诊断(主)服务器信息。
  • 2. 》仪表盘》导入dashboard》导入json文件》 Windows系统.json,实现对CPU , 内存,网络等基本信息诊断;
  • 3. 》仪表盘》导入dashboard》导入json文件》 InfluxDB.json,实现对influxDB运行参数基本信息诊断;

局域网使用http://<INFLUXDB_SVR>:8888 进行访问。

9 系统运维与诊断(Linux系统、influxDB历史数据库)

针对同一个主机安装两个端口(8086,9086)两台历史库同时运行influxDB的情况。

下载三件套:

https://github.com/influxdata/influxdb/releases

https://github.com/influxdata/telegraf/releases

https://github.com/influxdata/chronograf/releases

例如版本:

  • influxdb-1.8.10.x86_64.rpm
  • telegraf-1.28.1-1.x86_64.rpm
  • chronograf-1.10.1.x86_64.rpm

安装telegraf

[windows]

scp telegraf\*.rpm chronograf\*.rpm chronograf\*.rpm root@\<INFLUXDB_SVR\>:/opt
[Linux]

su - root

# 修改执行权限:

chmod 755 /etc/rc.d/rc.local

# 安装telegraf

dnf install /opt/telegraf\*.rpm

# 生成config配置文件

telegraf --input-filter system:mem:swap:disk:diskio:nstat:snmp:cpu:processes:kernel:interrupts:linux_sysctl_fs:filesystem:influxdb --output-filter influxdb config \> telegraf.conf

# 修改生成的配置文件。

# 或者直接用附件的配置文件:telegraf.conf

# 将配置文件拷贝到/etc/telegraf/telegraf.conf

# 生成服务telegraf.service

rm -rf /lib/systemd/system/telegraf.service

touch /lib/systemd/system/telegraf.service

echo [Unit] \>\> /lib/systemd/system/telegraf.service

echo Description=Telegraf Service \>\> /lib/systemd/system/telegraf.service

echo After=multi-user.target \>\> /lib/systemd/system/telegraf.service

echo [Service] \>\> /lib/systemd/system/telegraf.service

echo WorkingDirectory=/opt \>\> /lib/systemd/system/telegraf.service

echo User=root \>\> /lib/systemd/system/telegraf.service

echo Type=idle \>\> /lib/systemd/system/telegraf.service

echo ExecStart=/usr/bin/telegraf -config /etc/telegraf/telegraf.conf \>\> /lib/systemd/system/telegraf.service

echo Restart=always \>\> /lib/systemd/system/telegraf.service

echo [Install] \>\> /lib/systemd/system/telegraf.service

echo WantedBy=multi-user.target \>\> /lib/systemd/system/telegraf.service

# 启动telegraf

systemctl daemon-reload

systemctl enable telegraf.service

systemctl start telegraf.service

systemctl status telegraf.service

# 重启

systemctl restart telegraf.service

systemctl status telegraf.service

# 创建用户与数据库

influx -host localhost -port 8086 -execute "CREATE DATABASE telegraf"

influx -host localhost -port 8086 -execute "CREATE USER "telegraf" WITH PASSWORD 'telegraf' WITH ALL PRIVILEGES"

influx -host localhost -port 9086 -execute "CREATE DATABASE telegraf"

influx -host localhost -port 9086 -execute "CREATE USER "telegraf" WITH PASSWORD 'telegraf' WITH ALL PRIVILEGES"

influx -host localhost -port 8086 -execute "CREATE DATABASE winccoa"

influx -host localhost -port 8086 -execute "CREATE USER "etm" WITH PASSWORD 'etm\#123' WITH ALL PRIVILEGES"

influx -host localhost -port 9086 -execute "CREATE DATABASE winccoa"

influx -host localhost -port 9086 -execute "CREATE USER "etm" WITH PASSWORD 'etm\#123' WITH ALL PRIVILEGES"

# 安装 chronograf

dnf install /opt/chronograf\*.x86_64.rpm

chronograf

systemctl daemon-reload

systemctl enable chronograf.service

systemctl start chronograf.service

systemctl status chronograf.service

# 重启

systemctl restart chronograf.service

systemctl status chronograf.service

用浏览器http://<INFLUXDB_SVR>:8888 进行访问

配置chronograf 的 dashboard

配置influxdb的连接

1. 新建数据源,填写LOCAL8086, 代表主机INFLUXDB_SVR,开放端口8086的influxDB,诊断(主)服务器信息。

2. 仪表盘导入dashboard》导入json文件》 Linux系统.json,实现对CPU , 内存,网络等基本信息诊断;

3.仪表盘导入dashboard》导入json文件》 InfluxDB.json,实现对influxDB运行参数基本信息诊断;

局域网使用http://<INFLUXDB_SVR>:8888 进行访问。

10 influxDB Rest API直接访问历史数据库

sql语句格式


SELECT 语法:

SELECT \<field_key\>[,\<field_key\>,\<tag_key\>]

FROM \<database_name\>.\<retention_policy_name\>.\<measurement_name\>

WHERE \<conditional_expression\> [(AND\|OR) \<conditional_expression\> [...]]

GROUP BY time(\<time_interval\>),[tag_key] [fill(\<fill_option\>)]

ORDER BY time [asc \| desc]

fill()

LIMIT number

SLIMIT N

OFFSET number

tz('\<time_zone\>')

解释:

SELECT后面查询显示字段必须至少有一个field key,否则会抛异常ERR: at least 1 non-time field must be queried。还可显示tag keys、time,或者*显示所有字段。支持类型转换算符::,如:::float

FROM 返回完全合格测量的数据。通过指定度量的数据库和保留策略来完全限定度量。

WHERE 查询条件可为tag keys和time,field keys 也可作为查询条件但是不常用,因为不是索引,查询效率比较低。tag keys条件操作符支持=、!=、<>、正则,field keys支持=、!=、<>、>、>=、<、<=、正则。Tag key 用双引号,字符串用单引号。

GROUP BY只能对tag keys和time进行合分组,可以多字段排序,如group by tag1,tag2,time,也可一个*对所有的tag进行分组聚合,支持time时间分组聚合(前提是对SELECT 使用统计函数进行检索)。time(0 函数支持的单位:"ns" | "u" | "µ" | "ms" | "s" | "m" | "h" | "d" | "w"。

Fill() 如果values结果集中有null的情况,可在查询语句中加fill(0),遇到null用0来填充。fill()中只能填数字和previous(用前值替代)。

ORDER BY只能对time进行排序,asc升序,desc降序。

LIMIT分页,LIMIT后面的数字是查询显示多少条,

SLIMIT <N> , SLIMIT <N>返回指定测量值中 <N> 系列中的每个点。

OFFSET后面数字代表偏移量(从0开始代表第一条),如limit 10 offset 10意思为从第11条开始往后10条。

tz('<time_zone>') 指定时区(仅Linux)

举例:


SELECT original_value_float 
FROM AI_FAST.AI_FAST 
WHERE "name" = 'MEP:F1_CUB_1_1_102_XF_TIT01.STATE.VAL_IN.VALUE' 
AND time \> '2023-07-14T15:00:00Z' 
AND time\<'2023-07-14T20:00:00Z'

python访问历史库

import requests  
  
# 定义InfluxDB的主机和端口  
influx_host = 'aigowifi'  
influx_port = '8086'  
  
# 定义数据库名称和测量名称  
database_name = 'winccoa'  
measurement_name = 'AI_FAST.AI_FAST'  
field = 'original_value_float'
# 定义用户名和密码  
username = 'etm'  
password = 'etm#123'  
dpe='MEP:F1_CUB_1_1_102_XF_TIT01.STATE.VAL_IN.VALUE'
t0='2023-07-14T15:00:00Z'
t1='2023-07-14T20:00:00Z'
# 构建查询语句  
url = f"http://{influx_host}:{influx_port}/query"  
query = f"SELECT {field} FROM {measurement_name} WHERE \"name\" = '{dpe}' AND time > '{t0}' AND time<'{t1}'"  
# 发送HTTP请求并获取响应  
response = requests.get(url, params={'q': query, 'db': database_name}, auth=(username, password))  
  
# 检查响应状态码并解析JSON数据  
if response.status_code == 200:
    data = response.json()  
    # 打印结果  
    print(data) 
    print(query)  
else:
    print(f"Error: {query},{response.text}")

示例程序在<LIB319>/data/webservice/winccoa.py

curl命令访问

curl -G  
"localhost:8086/query?db=winccoa" 
--user etm:etm#123 
--data-urlencode 
"q= SELECT original_value_float 
	FROM AI_FAST.AI_FAST 
	WHERE \"name\" = 'MEP:F1_CUB_1_1_102_XF_TIT01.STATE.VAL_IN.VALUE' 
	AND time > '2023-07-14T15:00:00Z' 
	AND time<'2023-07-14T20:00:00Z' 
	LIMIT 10"

Javascript访问

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>WinCC OA influxDB RestAPI For jQuery</title> 
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
</head>
<script>
$(document).ready(function() {  
  // 指定 InfluxDB 的 RestAPI 地址  
  var influxdbUrl = 'http://localhost:8086/query';  
  // 用户名和密码  
  var username = 'etm';  
  var password = 'etm#123';  
  
  // 构建查询语句,注意每行最后有个空格!
  // 注意:读出的数据都是UTC时间,请自行转换成LOCAL的时间(+8)
  var query = `SELECT time AS \"时间\", 
		first(\"original_value_float\") AS \"CUB_1_1_102_XF_TIT01消防泵房温度检测\" 
		FROM AI_FAST.AI_FAST 
		WHERE \"name\" = 'MEP:F1_CUB_1_1_102_XF_TIT01.STATE.VAL_IN.VALUE' 
		AND time >= '2023-07-15T02:00:00Z' 
		AND time <= now() - 1h
		GROUP BY time(1m) 
		FILL(previous) 
		ORDER BY time DESC 
		LIMIT 1000 
		SLIMIT 1`; 
  
   // 发送 GET 请求进行验证  
  $.ajax({  
    url: influxdbUrl,
    type: 'GET',  
    data: {  
      q: query,  
	  db:'winccoa',
      u: username,  
      p: password 
    },  
    success: function(response) {  
      // 处理成功返回的数据  
      console.log(response);  
    },  
    error: function(xhr, status, error) {  
      // 处理请求失败的情况  
      console.log('Error: ' + error);  
      console.log('query: ' + query);  
    }  
  });  
});
</script>
</html>

执行结果:

示例程序在<LIB319>/data/webservice/index.html

11 其他

11.1 报警声音

在运行后的画面点击语音管理。

1的位置激活Cortana语音助理(支持LTSC版本Windows).

6的位置输入系统名称的汉字。如洁净室系统。

2的位置激活报警弹窗功能。

3的位置选择报警条。

4的位置选择三级报警(40)及以上。

5的位置选择播放的声音文件。

应用并关闭。

不显示内部报警

去除1,2,3的勾选。保存。

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

基于WinCC OA 3.19版本的轻量低代码SCADA模板库 展开 收起
Apache-2.0
取消

发行版 (3)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
C
1
https://gitee.com/zhigangli2020/lib319.git
git@gitee.com:zhigangli2020/lib319.git
zhigangli2020
lib319
LIB319
master

搜索帮助