Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue_django_test
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周田
vue_django_test
Commits
63366439
Commit
63366439
authored
Aug 23, 2023
by
周田
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:将参数添加的 devinfo 表上,供 device 子模块使用
parent
4d7c889b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
models.py
device_communication/models.py
+6
-0
views.py
device_communication/views.py
+46
-0
No files found.
device_communication/models.py
View file @
63366439
...
@@ -6,7 +6,10 @@ class SimulateDeviceCommunicationParameter(models.Model):
...
@@ -6,7 +6,10 @@ class SimulateDeviceCommunicationParameter(models.Model):
模拟设备通信参数
模拟设备通信参数
"""
"""
id
=
models
.
AutoField
(
primary_key
=
True
)
id
=
models
.
AutoField
(
primary_key
=
True
)
station_id
=
models
.
CharField
(
max_length
=
10
)
device_id
=
models
.
IntegerField
()
device_name
=
models
.
CharField
(
max_length
=
100
)
device_name
=
models
.
CharField
(
max_length
=
100
)
device_name_chn
=
models
.
CharField
(
max_length
=
100
)
protocol_name
=
models
.
CharField
(
max_length
=
100
)
protocol_name
=
models
.
CharField
(
max_length
=
100
)
communicate_mode
=
models
.
CharField
(
max_length
=
100
)
communicate_mode
=
models
.
CharField
(
max_length
=
100
)
tcp_ip
=
models
.
CharField
(
max_length
=
40
)
tcp_ip
=
models
.
CharField
(
max_length
=
40
)
...
@@ -26,7 +29,10 @@ class DeviceCommunicationParameter(models.Model):
...
@@ -26,7 +29,10 @@ class DeviceCommunicationParameter(models.Model):
设备通信参数
设备通信参数
"""
"""
id
=
models
.
AutoField
(
primary_key
=
True
)
id
=
models
.
AutoField
(
primary_key
=
True
)
station_id
=
models
.
CharField
(
max_length
=
10
)
device_id
=
models
.
IntegerField
()
device_name
=
models
.
CharField
(
max_length
=
100
)
device_name
=
models
.
CharField
(
max_length
=
100
)
device_name_chn
=
models
.
CharField
(
max_length
=
100
)
protocol_name
=
models
.
CharField
(
max_length
=
100
)
protocol_name
=
models
.
CharField
(
max_length
=
100
)
communicate_mode
=
models
.
CharField
(
max_length
=
100
)
communicate_mode
=
models
.
CharField
(
max_length
=
100
)
tcp_ip
=
models
.
CharField
(
max_length
=
40
)
tcp_ip
=
models
.
CharField
(
max_length
=
40
)
...
...
device_communication/views.py
View file @
63366439
...
@@ -2,8 +2,12 @@ from rest_framework.decorators import api_view
...
@@ -2,8 +2,12 @@ from rest_framework.decorators import api_view
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework
import
status
from
rest_framework
import
status
from
.models
import
(
SimulateDeviceCommunicationParameter
,
DeviceCommunicationParameter
)
from
protocol_version_manage.models
import
(
AllProtocolVersion
,
AllProtocolDefinAndVersion
,
from
protocol_version_manage.models
import
(
AllProtocolVersion
,
AllProtocolDefinAndVersion
,
AllDevCmdDefineAndVersion
)
AllDevCmdDefineAndVersion
)
from
device_data_op.models
import
TableXproAllDevinfo
@api_view
([
'GET'
])
@api_view
([
'GET'
])
def
get_protocol_names
(
request
):
def
get_protocol_names
(
request
):
...
@@ -36,3 +40,45 @@ def get_protocol_field_names(request):
...
@@ -36,3 +40,45 @@ def get_protocol_field_names(request):
res_data
=
([
field_name
for
field_name
in
field_name_set
])
res_data
=
([
field_name
for
field_name
in
field_name_set
])
return
Response
(
data
=
res_data
,
status
=
status
.
HTTP_200_OK
)
return
Response
(
data
=
res_data
,
status
=
status
.
HTTP_200_OK
)
@api_view
([
'POST'
])
def
set_communication_to_devinfo_table
(
request
):
"""
将设备通信参数或模拟设备通信参数设置到设备信息表
"""
type
=
request
.
data
.
get
(
'type'
)
if
type
is
None
or
type
==
''
:
return
Response
(
status
=
status
.
HTTP_400_BAD_REQUEST
)
if
type
==
'simulate'
:
communications
=
SimulateDeviceCommunicationParameter
.
objects
.
all
()
else
:
communications
=
DeviceCommunicationParameter
.
objects
.
all
()
# 清空设备信息表
# TableXproAllDevinfo.objects.all().delete()
TableXproAllDevinfo
.
objects
.
bulk_create
(
[
TableXproAllDevinfo
(
sta_id
=
communication
.
station_id
,
dev_id
=
communication
.
device_id
,
dev_name
=
communication
.
device_name
,
dev_name_chn
=
communication
.
device_name_chn
,
protocol_name
=
communication
.
protocol_name
,
cmd_excel_path
=
"null"
,
communitate_mode
=
communication
.
communitate_mode
,
tcp_ip
=
communication
.
tcp_ip
,
tcp_port
=
communication
.
tcp_port
,
udp_ip_src
=
communication
.
udp_ip_src
,
udp_port_src
=
communication
.
udp_port_src
,
udp_ip_dst
=
communication
.
udp_ip_dst
,
udp_port_dst
=
communication
.
udp_port_dst
,
udpmc_ip
=
"null"
,
udpmc_ip_tx
=
"null"
,
udpmc_port_tx
=
0
,
udpmc_ip_rx
=
"null"
,
udpmc_port_rx
=
0
,
remarks
=
"null"
)
for
communication
in
communications
])
return
Response
(
status
=
status
.
HTTP_200_OK
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment