@luischen/atlasdb
v1.0.0
Published
程序实现了从MySql数据源获取数据后通过HTTP API进行曲线上报的工作。主要工作流程如下:
Downloads
3
Readme
功能设计
程序实现了从MySql数据源获取数据后通过HTTP API进行曲线上报的工作。主要工作流程如下:
设计要点:
- 主流程通过定时器触发,依次实现连接数据库、处理单轴曲线、处理多轴曲线和数据上报
- 通过断路器实现服务容错和故障隔离,确保不会对中控服务器和产线造成影响
- 配置文件提供了灵活的配置
- fetch-interval, 数据拉取的频率,以秒为单位
- source, 源数据库配置信息
- target,目标服务地址,目前支持bearer token的认证实现
- sql, 单轴和多轴的抽取逻辑,包含了字段映射和单次抽取数量
如何使用
准备工作
- 确保安装node v16.20.2+
- 创建一个工作目录,如 /test/work
- 在工作目录下放置configure.yaml 文件,示例见附录
安装
npm install -g @luischen/atlasdb
运行
luischen-atlasdb --wd D:\\temp\\
参数说明
| 名称 | 说明 | | ---- | -------------------------------------------------- | | wd | 工作目录,包含配置文件、offset文件和输出结果的目录 |
附录
configure.yaml
fetch-interval: 10
source:
host: 'localhost'
user: 'root'
password: '123456'
database: 'test'
target:
url: 'http://main-service'
token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx'
sql:
single: |
SELECT result.id AS Id,
result.result_id AS ResultID,
UNIX_TIMESTAMP(curve.final_time) * 1000 AS FinalTime,
curve.program AS BoltProgram,
result.program_name AS ProgramName,
result.result_status AS ResultStatus,
curve.final_torque AS FinalTorque,
result.final_torque AS ResultFinalTorque,
curve.final_angle AS FinalAngle,
result.final_angle AS ResultFinalAngle,
curve.torque_limit_low AS TorqueLimitLow,
curve.torque_limit_high AS TorqueLimitHigh,
curve.angle_limit_low AS AngleLimitLow,
curve.angle_limit_high AS AngleLimitHigh,
curve.ip_address AS IPAddresss,
result.ip_address AS ResultIPAddress,
result.bolt AS BoltName,
result.screw_id AS BoltProcessID,
curve.torque AS TorqueValue,
curve.angle AS AngleValue
FROM ti_tightening_single_result_data result
INNER JOIN ti_tightening_single_curve_data curve
ON result.result_id = curve.result_id
WHERE result.id > ${offset} LIMIT 10
multi: >
SELECT result.id AS Id,
result.result_id AS ResultID,
UNIX_TIMESTAMP(curve.final_time) * 1000 AS FinalTime,
curve.program AS BoltProgram,
result.program_name AS ProgramName,
result.result_status AS ResultStatus,
curve.final_torque AS FinalTorque,
result.final_torque AS ResultFinalTorque,
curve.final_angle AS FinalAngle,
result.final_angle AS ResultFinalAngle,
curve.torque_limit_low AS TorqueLimitLow,
curve.torque_limit_high AS TorqueLimitHigh,
curve.angle_limit_low AS AngleLimitLow,
curve.angle_limit_high AS AngleLimitHigh,
curve.ip_address AS IPAddresss,
result.ip_address AS ResultIPAddress,
result.bolt_name AS BoltName,
result.bolt_number AS BoltProcessID,
curve.torque AS TorqueValue,
curve.angle AS AngleValue
FROM ti_tightening_multi_result_data result
INNER JOIN ti_tightening_multi_curve_data curve
ON result.result_id = curve.result_id
WHERE result.id > ${offset} LIMIT 10