Commit c51b00ee authored by zhangyibo's avatar zhangyibo

[0.9][zyb][第一版]

parent 142071c5
# pengli_iot
鹏力视觉系统数据采集到mysql
\ No newline at end of file
鹏力视觉系统数据采集到mysql
## 目录结构
main:主程序及配置文件
test:模拟机台的tcp服务器
## 安装
运行环境为python3,需要有pymysql包
### ubuntu下安装python3
```bash
sudo apt install python3 python3-pip
```
### centOS下安装python3
```bash
sudo yum install python38
```
### 安装pymysql包
```bash
pip3 install pymysql
```
## 配置
```JSON
{
"logLevel":"debug",//日志等级debug,info,warning,error
"dataBase":{
"host":"192.168.40.2",//数据库地址
"port":3306,//数据库端口号
"username":"usrname",//数据库用户名
"password":"password",//密码
"Database":"pengli_iot"//数据库
},
"machineList":[//机台列表
{
"host":"192.168.40.151",//机台IP
"port":7777,//机台端口号
"name":"machine1"//机台名称
},
{
"host":"127.0.0.1",
"port":8001,
"name":"machine1"
}
]
}
```
## 运行
```bash
/usr/bin/python3 main.py
```
\ No newline at end of file
This diff is collapsed.
{
"logLevel":"debug",
"dataBase":{
"host":"192.168.40.2",
"port":3306,
"username":"root",
"password":"nangao2019-",
"Database":"pengli_iot"
},
"machineList":[
{
"host":"192.168.40.151",
"port":7777,
"name":"machine1"
},
{
"host":"127.0.0.1",
"port":8001,
"name":"machine1"
}
]
}
\ No newline at end of file
This diff is collapsed.
import socket
import time
tcpserver = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcpserver.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
tcpserver.bind(("0.0.0.0", 8001))
tcpserver.listen(1)
# 打开文件
fo = open("test.json", "r",encoding="utf-8")
message = fo.read()
# message = message.encode('latin1').decode('utf-8')
print(message)
# 关闭文件
fo.close()
while True:
print("等待连接")
client, addr = tcpserver.accept()
print("Connected by", addr)
# data = client.recv(1024)
while True:
try:
time.sleep(5)
# input("发送JSON:")
client.send(message.encode('utf-8'))
print("sended")
except Exception as e:
print("断开连接:",e)
client.close()
break
# tcpserver.sendall("Hello World".encode('utf-8'))
\ No newline at end of file
{
"TotalOutPut": [{
"AllNum": 2,
"CameraIp": "1",
"NGNum": 1,
"OKNum": 1,
"ParentEquipNo": "GVDE3334",
"ProductName": "产品1",
"ProductNo": "200304",
"ShiftNum": 1,
"StatisticsDate": "2023-04-05"
}, {
"AllNum": 2,
"CameraIp": "1",
"NGNum": 1,
"OKNum": 1,
"ParentEquipNo": "GVDE3334",
"ProductName": "产品2",
"ProductNo": "200305",
"ShiftNum": 1,
"StatisticsDate": "2023-04-05"
}],
"NGDetails":[
{
"CameraIp": "1",
"EquipNo": "GSV102233",
"F_StatisticsDate": "2023-04-05",
"NGClassName": "异常类别1",
"NGClassNo": 10001,
"Num": 1,
"ParentEquipNo": "GVDE3334",
"ProductName": "产品1",
"ProductNo": "200304",
"ShiftNum": 1
},
{
"CameraIp": "1",
"EquipNo": "GSV102233",
"F_StatisticsDate": "2023-04-05",
"NGClassName": "异常类别1",
"NGClassNo": 10001,
"Num": 1,
"ParentEquipNo": "GVDE3334",
"ProductName": "产品2",
"ProductNo": "200305",
"ShiftNum": 1
}
],
"NGHourDetails":[
{
"CameraIp": "1",
"CreateDate": "2023-04-05 08:30:00.000",
"EquipNo": "GSV102233",
"F_StatisticsDate": "2023-04-05",
"NGClassName": "异常类别1",
"NGClassNo": 10001,
"Num": 1,
"ParentEquipNo": "GVDE3334",
"ProductName": "产品1",
"ProductNo": "200304",
"ShiftNum": 1
},
{
"CameraIp": "1",
"CreateDate": "2023-04-05 09:30:00.000",
"EquipNo": "GSV102233",
"F_StatisticsDate": "2023-04-05",
"NGClassName": "异常类别1",
"NGClassNo": 10001,
"Num": 1,
"ParentEquipNo": "GVDE3334",
"ProductName": "产品2",
"ProductNo": "200305",
"ShiftNum": 1
}
]
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment