项目简介
本项目是用于读取和处理uPMU(用户电力测量单元)数据的系统。uPMU设备常用于电力系统的数据采集,可收集并传输电压、电流等实时数据。借助C++和protobuf框架,项目实现了从Cassandra数据库读取uPMU数据,并对其进行处理、分析和归档的功能。
项目的主要特性和功能
- 数据读取:能连接Cassandra数据库,接收uPMU设备的原始数据。
- 数据处理:对接收的数据进行预处理、解析和格式转换,便于后续分析和存储。
- 数据归档:处理后的数据可通过RabbitMQ发送到其他系统,同时存储在Cassandra数据库中。
- 报告生成:可生成包含事件信息的报告文件,记录事件起始时间、结束时间、类型及标签。
- 错误处理和日志记录:在数据处理、发送和归档过程中,进行错误检查并记录日志。
- 服务管理:支持服务的启动、停止,能处理外部命令,如获取本地IP和MAC地址。
- 连接管理:检查RabbitMQ和Cassandra的连接状态,必要时重新连接。
安装使用步骤
环境准备
确保系统安装了必要的依赖库,如protobuf的C++库、Boost库、curl库等。在Centos系统下可按以下步骤安装: ```bash yum install cmake yum install gcc yum install autoconf yum install openssl-devel yum install boost yum install boost-devel yum install gcc-c++
cd rabbitmq-c mkdir build cd build cmake .. make make install
cd .. cd ..
cd SimpleAmqpClient mkdir build cd build cmake .. make make install
cd .. cd ..
yum install libuv-devel yum install clang
mkdir cpp-driver/build cd cpp-driver/build cmake .. b=$(uname -a| grep arm) [ -n "$b" ] && sed -i 's/ -1 / 255 /g' ../src/uuids.cpp && make -Wno-narrowing sudo make install
BBB
[ -n "$b" ] && echo "/usr/local/lib/arm-linux-gnueabihf/" >> /etc/ld.so.conf.d/usr_local.conf
Debian
[ -z "$b" ] && echo "/usr/local/lib/x86_64-linux-gnu/" >> /etc/ld.so.conf.d/usr_local.conf sudo ldconfig
yum install prostgesql yum install prostgesql-server postgresql-contrib sudo postgresql-setup initdb vi /var/lib/pgsql/data/pg_hba.conf #change all "ident" or "peer" to "trust" #we might wanna change this at some point. But access is restricted to the localhost anyway. sudo systemctl start postgresql sudo systemctl enable postgresql mkdir /var/lib/postgresql chown postgres:postgres /var/lib/postgresql/ sudo su postgres psql ALTER ROLE postgres WITH ENCRIPTED PASSWORD 'YOURPASSWORD'; CREATE USER uPMUgateway WITH PASSWORD 'YOURPASSWORD'; ALTER ROLE uPMUgateway WITH SUPERUSER; CREATE DATABASE upmugateway OWNER uPMUgateway; CREATE TABLESPACE upmu_datastore LOCATION '/var/lib/postgresql'; \q exit
yum install libpqxx yum install libpqxx-devel yum install curl-devel mkdir /usr/include/boost/dll cp /upmuGatewayInfo/dll/* /usr/include/boost/dll yum install bzip2 yum install wget wget https://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.bz2/download tar -xjfv download cd boost sh bootstrap ./b2 install cd .. yum install log4cpp
wget https://sourceforge.net/projects/log4cpp/files/log4cpp-1.1.x%20%28new%29/log4cpp-1.1/log4cpp-1.1.1.tar.gz/download tar -xvzf download cd log4cpp ./configure make make check make install cd ..
yum install libtool unzip tar -jxvf protobuf-2.6.1.tar.bz2 cd protobuf-2.6.1
./autogen.sh ./configure make make check sudo make install cd ..
echo "/usr/local/lib64" >> /etc/ld.so.conf echo "/usr/local/lib" >> /etc/ld.so.conf sudo ldconfig # refresh shared library cache.
edit the cassandrauser and cassandrapassword in the main.cpp file in the uPMUgateway directory to your credentials
change serviceDataDiscovery.h : Set starting month year and day to a day that exists in the upmu e.g today.
change upmuFtpAccess.cpp #define DIRECTORY_PREFIX "/upmu_data" //for new firmware or #define DIRECTORY_PREFIX "" //for old firmware
make all the projects
set postgres files add add them all with psql -f "filename"
mkdir /var/log/upmugateway chmod 777 /var/log/upmugateway cp uPMUgateway/upmugateway-devel /etc/init.d/usr_local ```
代码编译
使用合适的编译器(如g++)编译源代码。
运行程序
运行编译后的可执行文件,通过命令行参数提供必要的配置信息,如数据库连接信息、uPMU设备信息等。
数据分析和可视化
根据处理后的数据和生成的报告,进行进一步的数据分析和可视化。
注意事项
- 项目代码需与数据库、uPMU设备和可能的Cassandra数据库交互,确保这些组件正常运行和安全。
- 代码可能包含敏感信息,如数据库用户名和密码,应安全存储和传输。
- 对于复杂电力系统数据,可能需更详细的数据清洗和预处理,以确保数据准确可靠。
下载地址
点击下载 【提取码: 4003】【解压密码: www.makuang.net】