Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
GC_Branch
Project
Project
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
周磊
GC_Branch
Commits
99c6abe7
Commit
99c6abe7
authored
May 28, 2018
by
wangjunqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add WTD424X Test
parent
cef76502
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1026 additions
and
24 deletions
+1026
-24
424XTest.Designer.cs
GcDevicePc/424XTest.Designer.cs
+87
-0
424XTest.cs
GcDevicePc/424XTest.cs
+48
-0
424XTest.resx
GcDevicePc/424XTest.resx
+120
-0
GCModbus.cs
GcDevicePc/Common/GCModbus.cs
+18
-0
GCModbus485.cs
GcDevicePc/Common/GCModbus485.cs
+247
-0
GCModbusSlave485.cs
GcDevicePc/Common/GCModbusSlave485.cs
+10
-3
PCBuffer.cs
GcDevicePc/GCBuffer/PCBuffer.cs
+48
-11
GcDevicePc.csproj
GcDevicePc/GcDevicePc.csproj
+13
-0
MDIBase.Designer.cs
GcDevicePc/MDIBase.Designer.cs
+8
-8
MDIBase.cs
GcDevicePc/MDIBase.cs
+13
-0
WTD424XOutput.cs
GcDevicePc/Module/WTD424XOutput.cs
+90
-0
WTD624X.cs
GcDevicePc/Module/WTD624X.cs
+137
-0
DataOutput.cs
GcDevicePc/ProThread/DataOutput.cs
+185
-0
HMISearch.cs
GcDevicePc/ProThread/HMISearch.cs
+2
-2
No files found.
GcDevicePc/424XTest.Designer.cs
0 → 100644
View file @
99c6abe7
namespace
GcDevicePc
{
partial
class
_424XTest
{
/// <summary>
/// Required designer variable.
/// </summary>
private
System
.
ComponentModel
.
IContainer
components
=
null
;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected
override
void
Dispose
(
bool
disposing
)
{
if
(
disposing
&&
(
components
!=
null
))
{
components
.
Dispose
();
}
base
.
Dispose
(
disposing
);
}
#
region
Windows
Form
Designer
generated
code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private
void
InitializeComponent
()
{
this
.
button1
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
button2
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
button3
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
SuspendLayout
();
//
// button1
//
this
.
button1
.
Location
=
new
System
.
Drawing
.
Point
(
24
,
46
);
this
.
button1
.
Name
=
"button1"
;
this
.
button1
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
23
);
this
.
button1
.
TabIndex
=
0
;
this
.
button1
.
Text
=
"测试1"
;
this
.
button1
.
UseVisualStyleBackColor
=
true
;
this
.
button1
.
Click
+=
new
System
.
EventHandler
(
this
.
button1_Click
);
//
// button2
//
this
.
button2
.
Location
=
new
System
.
Drawing
.
Point
(
141
,
46
);
this
.
button2
.
Name
=
"button2"
;
this
.
button2
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
23
);
this
.
button2
.
TabIndex
=
1
;
this
.
button2
.
Text
=
"测试2"
;
this
.
button2
.
UseVisualStyleBackColor
=
true
;
this
.
button2
.
Click
+=
new
System
.
EventHandler
(
this
.
button2_Click
);
//
// button3
//
this
.
button3
.
Location
=
new
System
.
Drawing
.
Point
(
83
,
86
);
this
.
button3
.
Name
=
"button3"
;
this
.
button3
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
23
);
this
.
button3
.
TabIndex
=
2
;
this
.
button3
.
Text
=
"button3"
;
this
.
button3
.
UseVisualStyleBackColor
=
true
;
this
.
button3
.
Click
+=
new
System
.
EventHandler
(
this
.
button3_Click
);
//
// _424XTest
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
269
,
121
);
this
.
Controls
.
Add
(
this
.
button3
);
this
.
Controls
.
Add
(
this
.
button2
);
this
.
Controls
.
Add
(
this
.
button1
);
this
.
Name
=
"_424XTest"
;
this
.
Text
=
"WTD424XTest"
;
this
.
Load
+=
new
System
.
EventHandler
(
this
.
_424XTest_Load
);
this
.
ResumeLayout
(
false
);
}
#
endregion
private
System
.
Windows
.
Forms
.
Button
button1
;
private
System
.
Windows
.
Forms
.
Button
button2
;
private
System
.
Windows
.
Forms
.
Button
button3
;
}
}
\ No newline at end of file
GcDevicePc/424XTest.cs
0 → 100644
View file @
99c6abe7
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Data
;
using
System.Drawing
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
using
GcDevicePc.Module
;
namespace
GcDevicePc
{
public
partial
class
_424XTest
:
Form
{
private
WTD424XOutput
my424
=
new
WTD424XOutput
();
private
WTD624X
my624
=
new
WTD624X
(
"192.168.1.57"
,
502
);
public
_424XTest
()
{
InitializeComponent
();
}
private
void
_424XTest_Load
(
object
sender
,
EventArgs
e
)
{
my424
.
WTD424X_Open
();
my624
.
WTD624X_Open
();
}
private
void
button1_Click
(
object
sender
,
EventArgs
e
)
{
float
[]
data
=
new
float
[]
{
10.0f
,
8.8f
,
13.3f
,
14.4f
};
my624
.
UpdateData
(
data
);
}
private
void
button2_Click
(
object
sender
,
EventArgs
e
)
{
float
[]
data
=
new
float
[]
{
10.0f
,
8.8f
,
13.3f
,
14.4f
};
my424
.
UpdateData2
(
data
);
}
private
void
button3_Click
(
object
sender
,
EventArgs
e
)
{
my624
.
UpdateIP
(
"192.168.1.54"
,
"255.255.255.0"
,
"192.168.1.1"
);
}
}
}
GcDevicePc/424XTest.resx
0 → 100644
View file @
99c6abe7
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema
id=
"root"
xmlns=
""
xmlns:xsd=
"http://www.w3.org/2001/XMLSchema"
xmlns:msdata=
"urn:schemas-microsoft-com:xml-msdata"
>
<xsd:import
namespace=
"http://www.w3.org/XML/1998/namespace"
/>
<xsd:element
name=
"root"
msdata:IsDataSet=
"true"
>
<xsd:complexType>
<xsd:choice
maxOccurs=
"unbounded"
>
<xsd:element
name=
"metadata"
>
<xsd:complexType>
<xsd:sequence>
<xsd:element
name=
"value"
type=
"xsd:string"
minOccurs=
"0"
/>
</xsd:sequence>
<xsd:attribute
name=
"name"
use=
"required"
type=
"xsd:string"
/>
<xsd:attribute
name=
"type"
type=
"xsd:string"
/>
<xsd:attribute
name=
"mimetype"
type=
"xsd:string"
/>
<xsd:attribute
ref=
"xml:space"
/>
</xsd:complexType>
</xsd:element>
<xsd:element
name=
"assembly"
>
<xsd:complexType>
<xsd:attribute
name=
"alias"
type=
"xsd:string"
/>
<xsd:attribute
name=
"name"
type=
"xsd:string"
/>
</xsd:complexType>
</xsd:element>
<xsd:element
name=
"data"
>
<xsd:complexType>
<xsd:sequence>
<xsd:element
name=
"value"
type=
"xsd:string"
minOccurs=
"0"
msdata:Ordinal=
"1"
/>
<xsd:element
name=
"comment"
type=
"xsd:string"
minOccurs=
"0"
msdata:Ordinal=
"2"
/>
</xsd:sequence>
<xsd:attribute
name=
"name"
type=
"xsd:string"
use=
"required"
msdata:Ordinal=
"1"
/>
<xsd:attribute
name=
"type"
type=
"xsd:string"
msdata:Ordinal=
"3"
/>
<xsd:attribute
name=
"mimetype"
type=
"xsd:string"
msdata:Ordinal=
"4"
/>
<xsd:attribute
ref=
"xml:space"
/>
</xsd:complexType>
</xsd:element>
<xsd:element
name=
"resheader"
>
<xsd:complexType>
<xsd:sequence>
<xsd:element
name=
"value"
type=
"xsd:string"
minOccurs=
"0"
msdata:Ordinal=
"1"
/>
</xsd:sequence>
<xsd:attribute
name=
"name"
type=
"xsd:string"
use=
"required"
/>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader
name=
"resmimetype"
>
<value>
text/microsoft-resx
</value>
</resheader>
<resheader
name=
"version"
>
<value>
2.0
</value>
</resheader>
<resheader
name=
"reader"
>
<value>
System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
</value>
</resheader>
<resheader
name=
"writer"
>
<value>
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
</value>
</resheader>
</root>
\ No newline at end of file
GcDevicePc/Common/GCModbus.cs
View file @
99c6abe7
...
...
@@ -52,6 +52,24 @@ namespace GcDevicePc.Common
}
public
int
GCModbusClose
()
{
try
{
fnLibModbusClose
(
hModbusHandle
);
return
0
;
}
catch
(
Exception
e
)
{
Console
.
WriteLine
(
e
.
Message
);
return
-
1
;
}
}
~
GCModbus
()
{
try
...
...
GcDevicePc/Common/GCModbus485.cs
0 → 100644
View file @
99c6abe7
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Runtime.InteropServices
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
GcDevicePc.Common
{
class
GCModbus485
{
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnLibModbus485"
,
CharSet
=
CharSet
.
Unicode
)]
private
static
extern
int
fnLibModbus485
(
byte
ucPort
,
int
ulBaudRate
,
int
timeout
,
ref
UInt32
handle
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnReadCoilStatus"
)]
private
static
extern
int
fnReadCoilStatus
(
UInt32
handle
,
byte
slaveaddress
,
UInt16
address
,
UInt16
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
Byte
[]
dest
,
[
MarshalAs
(
UnmanagedType
.
LPTStr
)]
string
ip
,
UInt16
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnReadInputStatus"
)]
private
static
extern
int
fnReadInputStatus
(
UInt32
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
Byte
[]
dest
,
[
MarshalAs
(
UnmanagedType
.
LPTStr
)]
string
ipp
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnReadHoldingReg"
)]
private
static
extern
int
fnReadHoldingReg
(
UInt32
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
UInt16
[]
dest
,
[
MarshalAs
(
UnmanagedType
.
LPTStr
)]
string
ipp
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnReadInputReg"
)]
private
static
extern
int
fnReadInputReg
(
UInt32
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
UInt16
[]
dest
,
[
MarshalAs
(
UnmanagedType
.
LPTStr
)]
string
ipp
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnWriteSingleCoil"
)]
private
static
extern
int
fnWriteSingleCoil
(
UInt32
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
state
,
[
MarshalAs
(
UnmanagedType
.
LPTStr
)]
string
ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnWriteHoldingReg"
)]
private
static
extern
int
fnWriteHoldingReg
(
UInt32
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
state
,
[
MarshalAs
(
UnmanagedType
.
LPTStr
)]
string
ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnWriteMultipleCoils"
)]
private
static
extern
int
fnWriteMultipleCoils
(
UInt32
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
Byte
[]
src
,
[
MarshalAs
(
UnmanagedType
.
LPTStr
)]
string
ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnWriteMultipleRegs"
)]
private
static
extern
int
fnWriteMultipleRegs
(
UInt32
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
UInt16
[]
src
,
[
MarshalAs
(
UnmanagedType
.
LPTStr
)]
string
ipp
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnReportSlaveID"
)]
private
static
extern
int
fnReportSlaveID
(
UInt32
handle
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
Byte
[]
src
,
[
MarshalAs
(
UnmanagedType
.
LPTStr
)]
string
ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnMaskWriteReg"
)]
private
static
extern
int
fnMaskWriteReg
(
UInt32
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
amask
,
ushort
omask
,
[
MarshalAs
(
UnmanagedType
.
LPTStr
)]
string
ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnReadWriteMultipleRegs"
)]
private
static
extern
int
fnReadWriteMultipleRegs
(
UInt32
handle
,
byte
slaveaddress
,
ushort
waddress
,
ushort
wnum
,
ushort
raddress
,
ushort
rnum
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
UInt16
[]
dest
,
[
MarshalAs
(
UnmanagedType
.
LPTStr
)]
string
ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnLibModbusClose"
)]
private
static
extern
void
fnLibModbusClose
(
UInt32
handle
);
private
UInt32
hModbusHandle
;
private
byte
Port
=
1
;
private
int
BaudRate
=
9600
;
private
int
timeout
=
2000
;
private
string
ip
=
""
;
private
ushort
wport
=
502
;
public
GCModbus485
(
byte
uPort
,
int
uBaudRate
,
int
utimeout
)
{
this
.
Port
=
uPort
;
this
.
BaudRate
=
uBaudRate
;
this
.
timeout
=
utimeout
;
}
public
int
ModbusOpen
()
{
int
ret
=
0
;
try
{
ret
=
fnLibModbus485
(
Port
,
BaudRate
,
timeout
,
ref
hModbusHandle
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
e
.
Message
);
}
return
ret
;
}
public
int
ModbusClose
()
{
try
{
fnLibModbusClose
(
hModbusHandle
);
hModbusHandle
=
0
;
return
0
;
}
catch
(
Exception
e
)
{
Console
.
WriteLine
(
e
.
Message
);
return
-
1
;
}
}
~
GCModbus485
()
{
this
.
Port
=
1
;
this
.
BaudRate
=
9600
;
this
.
timeout
=
2000
;
}
public
int
ReadCoilStatus
(
byte
slaveaddress
,
ushort
addr
,
ushort
num
,
ref
byte
[]
buf
)
{
int
ret
=
0
;
try
{
if
(
hModbusHandle
!=
0
)
ret
=
fnReadCoilStatus
(
hModbusHandle
,
slaveaddress
,
(
ushort
)(
addr
-
1
),
num
,
buf
,
ip
,
wport
);
}
catch
{
ret
=
-
1
;
}
return
ret
;
}
public
int
ReadInputStatus
(
byte
slaveaddress
,
ushort
addr
,
ushort
num
,
ref
byte
[]
buf
)
{
int
ret
=
0
;
try
{
if
(
hModbusHandle
!=
0
)
ret
=
fnReadInputStatus
(
hModbusHandle
,
slaveaddress
,
addr
,
num
,
buf
,
ip
,
wport
);
}
catch
{
ret
=
-
1
;
}
return
ret
;
}
public
int
ReadHoldingReg
(
byte
slaveaddress
,
ushort
addr
,
ushort
num
,
ref
UInt16
[]
buf
)
{
int
ret
=
0
;
try
{
if
(
hModbusHandle
!=
0
)
ret
=
fnReadHoldingReg
(
hModbusHandle
,
slaveaddress
,
(
ushort
)(
addr
-
1
),
num
,
buf
,
ip
,
wport
);
}
catch
{
ret
=
-
1
;
}
return
ret
;
}
public
int
ReadInputReg
(
byte
slaveaddress
,
ushort
addr
,
ushort
num
,
ref
UInt16
[]
buf
)
{
int
ret
=
0
;
try
{
if
(
hModbusHandle
!=
0
)
ret
=
fnReadInputReg
(
hModbusHandle
,
slaveaddress
,
addr
,
num
,
buf
,
ip
,
wport
);
}
catch
{
ret
=
-
1
;
}
return
ret
;
}
public
int
WriteSingleCoil
(
byte
slaveaddress
,
ushort
addr
,
ushort
state
)
{
int
ret
=
0
;
try
{
if
(
hModbusHandle
!=
0
)
ret
=
fnWriteSingleCoil
(
hModbusHandle
,
slaveaddress
,
(
ushort
)(
addr
-
1
),
state
,
ip
,
wport
);
}
catch
{
ret
=
-
1
;
}
return
ret
;
}
public
int
WriteHoldingReg
(
byte
slaveaddress
,
ushort
addr
,
ushort
state
)
{
int
ret
=
0
;
try
{
if
(
hModbusHandle
!=
0
)
ret
=
fnWriteHoldingReg
(
hModbusHandle
,
slaveaddress
,
(
ushort
)(
addr
-
1
),
state
,
ip
,
wport
);
}
catch
{
ret
=
-
1
;
}
return
ret
;
}
public
int
WriteMultipleRegs
(
byte
slaveaddress
,
ushort
addr
,
ushort
num
,
ref
ushort
[]
buf
)
{
int
ret
=
0
;
try
{
if
(
hModbusHandle
!=
0
)
ret
=
fnWriteMultipleRegs
(
hModbusHandle
,
slaveaddress
,
(
ushort
)(
addr
-
1
),
num
,
buf
,
ip
,
wport
);
}
catch
{
ret
=
-
1
;
}
return
ret
;
}
public
int
ReportSlaveID
(
ref
byte
[]
buf
)
{
int
ret
=
0
;
try
{
if
(
hModbusHandle
!=
0
)
ret
=
fnReportSlaveID
(
hModbusHandle
,
buf
,
ip
,
wport
);
}
catch
{
ret
=
-
1
;
}
return
ret
;
}
public
int
MaskWriteReg
(
byte
slaveaddress
,
ushort
addr
,
ushort
amask
,
ushort
omask
)
{
int
ret
=
0
;
try
{
if
(
hModbusHandle
!=
0
)
ret
=
fnMaskWriteReg
(
hModbusHandle
,
slaveaddress
,
addr
,
amask
,
omask
,
ip
,
wport
);
}
catch
{
ret
=
-
1
;
}
return
ret
;
}
public
int
ReadWriteMultipleRegs
(
byte
slaveaddress
,
ushort
waddr
,
ushort
wnum
,
ushort
raddr
,
ushort
rnum
,
ref
UInt16
[]
buf
)
{
int
ret
=
0
;
try
{
if
(
hModbusHandle
!=
0
)
ret
=
fnReadWriteMultipleRegs
(
hModbusHandle
,
slaveaddress
,
waddr
,
wnum
,
raddr
,
rnum
,
buf
,
ip
,
wport
);
}
catch
{
ret
=
-
1
;
}
return
ret
;
}
}
}
GcDevicePc/Common/GCModbusSlave485.cs
View file @
99c6abe7
...
...
@@ -31,7 +31,14 @@ namespace GcDevicePc.Common
public
GCModbusSlave485
(
Byte
port
,
int
baudrate
)
{
this
.
hModbusHandle
=
fnLibModbusSlave485Init
(
port
,
baudrate
);
try
{
this
.
hModbusHandle
=
fnLibModbusSlave485Init
(
port
,
baudrate
);
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
ex
.
Message
);
}
}
~
GCModbusSlave485
()
...
...
@@ -40,9 +47,9 @@ namespace GcDevicePc.Common
{
fnLibModbusSlaveClose
(
hModbusHandle
);
}
catch
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
ex
.
Message
);
}
}
...
...
GcDevicePc/GCBuffer/PCBuffer.cs
View file @
99c6abe7
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -41,6 +42,14 @@ namespace GcDevicePc.GCBuffer
// public bool sendtohw;
}
public
struct
ModuleInfo
{
public
string
ip
;
public
string
mask
;
public
string
gw
;
}
public
struct
ThreadInfo
{
public
ushort
HMI_Monitor_TH
;
// 0 --线程结束 1--线程运行中
...
...
@@ -48,10 +57,11 @@ namespace GcDevicePc.GCBuffer
public
struct
PCInfo
{
public
FolderInfo
pcfolderinfo
;
public
GCFileInfo
pcfileinfo
;
public
WorkInfo
pcworkinfo
;
public
ThreadInfo
pcthreadinfo
;
public
FolderInfo
pcfolderinfo
;
public
GCFileInfo
pcfileinfo
;
public
WorkInfo
pcworkinfo
;
public
ModuleInfo
moduleinfo
;
public
ThreadInfo
pcthreadinfo
;
}
public
PCInfo
gcpcinfo
=
new
PCInfo
();
...
...
@@ -81,17 +91,44 @@ namespace GcDevicePc.GCBuffer
gcpcinfo
.
pcworkinfo
.
system_Statue
=
false
;
gcpcinfo
.
pcworkinfo
.
work_Statue
=
0
;
gcpcinfo
.
moduleinfo
.
ip
=
"192.168.1.54"
;
string
file
=
System
.
Windows
.
Forms
.
Application
.
StartupPath
+
"\\startup.ini"
;
INIOperation
test
=
new
INIOperation
(
file
);
string
opensys
=
test
.
INIGetStringValue
(
"StartUp"
,
"打开系统"
,
null
);
string
runtype
=
test
.
INIGetStringValue
(
"StartUp"
,
"运行类型"
,
null
);
//string senddata = test.INIGetStringValue("StartUp", "SendData", null);
if
(
Convert
.
ToInt32
(
opensys
)
==
1
)
if
(
File
.
Exists
(
file
))
{
gcpcinfo
.
pcworkinfo
.
RunType
=
Convert
.
ToUInt16
(
runtype
);
}
INIOperation
test
=
new
INIOperation
(
file
);
string
opensys
=
test
.
INIGetStringValue
(
"StartUp"
,
"打开系统"
,
null
);
string
runtype
=
test
.
INIGetStringValue
(
"StartUp"
,
"运行类型"
,
null
);
string
wtd624x_ip
=
test
.
INIGetStringValue
(
"WTD624X"
,
"IP"
,
null
);
string
wtd624x_mask
=
test
.
INIGetStringValue
(
"WTD624X"
,
"MASK"
,
null
);
string
wtd624x_gw
=
test
.
INIGetStringValue
(
"WTD624X"
,
"GW"
,
null
);
//string senddata = test.INIGetStringValue("StartUp", "SendData", null);
if
(
Convert
.
ToInt32
(
opensys
)
==
1
)
{
gcpcinfo
.
pcworkinfo
.
RunType
=
Convert
.
ToUInt16
(
runtype
);
}
if
(!
String
.
IsNullOrEmpty
(
wtd624x_ip
))
{
gcpcinfo
.
moduleinfo
.
ip
=
wtd624x_ip
;
}
if
(!
String
.
IsNullOrEmpty
(
wtd624x_mask
))
{
gcpcinfo
.
moduleinfo
.
mask
=
wtd624x_mask
;
}
if
(!
String
.
IsNullOrEmpty
(
wtd624x_gw
))
{
gcpcinfo
.
moduleinfo
.
gw
=
wtd624x_gw
;
}
}
// gcpcinfo.pcworkinfo.RunType = 0; //运行类型 0 打开运行 1 智能运行 2 批处理
}
...
...
GcDevicePc/GcDevicePc.csproj
View file @
99c6abe7
...
...
@@ -146,6 +146,12 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"424XTest.cs"
>
<SubType>
Form
</SubType>
</Compile>
<Compile
Include=
"424XTest.Designer.cs"
>
<DependentUpon>
424XTest.cs
</DependentUpon>
</Compile>
<Compile
Include=
"AboutForm.cs"
>
<SubType>
Form
</SubType>
</Compile>
...
...
@@ -198,6 +204,7 @@
<Compile
Include=
"Common\FileTools.cs"
/>
<Compile
Include=
"Common\FileTransfer.cs"
/>
<Compile
Include=
"Common\GCModbus.cs"
/>
<Compile
Include=
"Common\GCModbus485.cs"
/>
<Compile
Include=
"Common\GCModbusSlave.cs"
/>
<Compile
Include=
"Common\FileHelper.cs"
/>
<Compile
Include=
"Common\GCModbusSlave485.cs"
/>
...
...
@@ -413,10 +420,13 @@
<DependentUpon>
MethodNameInputForm.cs
</DependentUpon>
</Compile>
<Compile
Include=
"Modbus.cs"
/>
<Compile
Include=
"Module\WTD424XOutput.cs"
/>
<Compile
Include=
"Module\WTD624X.cs"
/>
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"ProThread\ChannelDataSave.cs"
/>
<Compile
Include=
"ProThread\CKvocUpdata.cs"
/>
<Compile
Include=
"ProThread\DataOutput.cs"
/>
<Compile
Include=
"ProThread\DataRcv.cs"
/>
<Compile
Include=
"ProThread\GcDataTh.cs"
/>
<Compile
Include=
"ProThread\HMIControl.cs"
/>
...
...
@@ -499,6 +509,9 @@
<Compile
Include=
"WaitForm.Designer.cs"
>
<DependentUpon>
WaitForm.cs
</DependentUpon>
</Compile>
<EmbeddedResource
Include=
"424XTest.resx"
>
<DependentUpon>
424XTest.cs
</DependentUpon>
</EmbeddedResource>
<EmbeddedResource
Include=
"AboutForm.resx"
>
<DependentUpon>
AboutForm.cs
</DependentUpon>
</EmbeddedResource>
...
...
GcDevicePc/MDIBase.Designer.cs
View file @
99c6abe7
...
...
@@ -250,21 +250,21 @@
// HistoryDataMenu
//
this
.
HistoryDataMenu
.
Name
=
"HistoryDataMenu"
;
this
.
HistoryDataMenu
.
Size
=
new
System
.
Drawing
.
Size
(
1
52
,
22
);
this
.
HistoryDataMenu
.
Size
=
new
System
.
Drawing
.
Size
(
1
48
,
22
);
this
.
HistoryDataMenu
.
Text
=
"历史数据查询"
;
this
.
HistoryDataMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
HistoryDataMenu_Click
);
//
// CalibrationMenu
//
this
.
CalibrationMenu
.
Name
=
"CalibrationMenu"
;
this
.
CalibrationMenu
.
Size
=
new
System
.
Drawing
.
Size
(
1
52
,
22
);
this
.
CalibrationMenu
.
Size
=
new
System
.
Drawing
.
Size
(
1
48
,
22
);
this
.
CalibrationMenu
.
Text
=
"校准查看"
;
this
.
CalibrationMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
CalibrationMenu_Click
);
//
// HistoryPicMenu
//
this
.
HistoryPicMenu
.
Name
=
"HistoryPicMenu"
;
this
.
HistoryPicMenu
.
Size
=
new
System
.
Drawing
.
Size
(
1
52
,
22
);
this
.
HistoryPicMenu
.
Size
=
new
System
.
Drawing
.
Size
(
1
48
,
22
);
this
.
HistoryPicMenu
.
Text
=
"历史谱图"
;
this
.
HistoryPicMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
HistoryPicMenu_Click
);
//
...
...
@@ -283,27 +283,27 @@
this
.
SingleStop
,
this
.
SingleCancel
});
this
.
SingleControlMenu
.
Name
=
"SingleControlMenu"
;
this
.
SingleControlMenu
.
Size
=
new
System
.
Drawing
.
Size
(
1
52
,
22
);
this
.
SingleControlMenu
.
Size
=
new
System
.
Drawing
.
Size
(
1
48
,
22
);
this
.
SingleControlMenu
.
Text
=
"单次流程控制"
;
//
// SingleStart
//
this
.
SingleStart
.
Name
=
"SingleStart"
;
this
.
SingleStart
.
Size
=
new
System
.
Drawing
.
Size
(
1
52
,
22
);
this
.
SingleStart
.
Size
=
new
System
.
Drawing
.
Size
(
1
00
,
22
);
this
.
SingleStart
.
Text
=
"开始"
;
this
.
SingleStart
.
Click
+=
new
System
.
EventHandler
(
this
.
SingleStart_Click
);
//
// SingleStop
//
this
.
SingleStop
.
Name
=
"SingleStop"
;
this
.
SingleStop
.
Size
=
new
System
.
Drawing
.
Size
(
1
52
,
22
);
this
.
SingleStop
.
Size
=
new
System
.
Drawing
.
Size
(
1
00
,
22
);
this
.
SingleStop
.
Text
=
"停止"
;
this
.
SingleStop
.
Click
+=
new
System
.
EventHandler
(
this
.
SingleStop_Click
);
//
// SingleCancel
//
this
.
SingleCancel
.
Name
=
"SingleCancel"
;
this
.
SingleCancel
.
Size
=
new
System
.
Drawing
.
Size
(
1
52
,
22
);
this
.
SingleCancel
.
Size
=
new
System
.
Drawing
.
Size
(
1
00
,
22
);
this
.
SingleCancel
.
Text
=
"取消"
;
this
.
SingleCancel
.
Click
+=
new
System
.
EventHandler
(
this
.
SingleCancel_Click
);
//
...
...
@@ -318,7 +318,7 @@
// AboutMenu
//
this
.
AboutMenu
.
Name
=
"AboutMenu"
;
this
.
AboutMenu
.
Size
=
new
System
.
Drawing
.
Size
(
1
0
0
,
22
);
this
.
AboutMenu
.
Size
=
new
System
.
Drawing
.
Size
(
1
8
0
,
22
);
this
.
AboutMenu
.
Text
=
"关于"
;
this
.
AboutMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
AboutMenu_Click
);
//
...
...
GcDevicePc/MDIBase.cs
View file @
99c6abe7
...
...
@@ -1754,5 +1754,18 @@ namespace GcDevicePc
Trace
.
Write
(
ex
);
}
}
//private void debugSubMenu_Click(object sender, EventArgs e)
//{
// try
// {
// _424XTest test = new _424XTest();
// test.Show();
// }
// catch (Exception ex)
// {
// Log.Error(ex.Message);
// }
//}
}
}
GcDevicePc/Module/WTD424XOutput.cs
0 → 100644
View file @
99c6abe7
using
System
;
using
GcDevicePc.Common
;
namespace
GcDevicePc.Module
{
class
WTD424XOutput
{
private
GCModbus485
rtumodbus
=
new
GCModbus485
(
6
,
9600
,
2000
);
private
bool
workflag
=
false
;
public
WTD424XOutput
()
{
}
public
int
WTD424X_Open
()
{
int
ret
=
0
;
int
count
=
3
;
try
{
ret
=
rtumodbus
.
ModbusOpen
();
if
(
ret
==
0
)
{
workflag
=
true
;
UInt16
[]
buf
=
new
UInt16
[
4
]
{
1
,
1
,
1
,
1
};
ret
=
rtumodbus
.
WriteMultipleRegs
(
1
,
11
,
4
,
ref
buf
);
while
(
ret
!=
0
&&
count
>
0
)
{
ret
=
rtumodbus
.
WriteMultipleRegs
(
1
,
11
,
4
,
ref
buf
);
count
--;
}
}
}
catch
(
Exception
ex
)
{
Log
.
Error
(
ex
.
Message
);
}
return
ret
;
}
public
int
WTD424X_Close
()
{
int
ret
=
0
;
try
{
ret
=
rtumodbus
.
ModbusClose
();
if
(
ret
==
0
)
workflag
=
false
;
}
catch
(
Exception
ex
)
{
Log
.
Error
(
ex
.
Message
);
}
return
ret
;
}
private
void
GetMaVal
(
float
[]
data
,
ref
UInt16
[]
buf
)
{
if
(
data
[
0
]
>=
0
&&
data
[
0
]
<=
150.0f
)
buf
[
0
]
=
(
UInt16
)
(
data
[
0
]
*
20.0f
/
150.0f
*
4095
/
20.0f
);
if
(
data
[
1
]
>=
0
&&
data
[
1
]
<=
10.0f
)
buf
[
1
]
=
(
UInt16
)
(
data
[
1
]
*
20.0f
/
10.0f
*
4095
/
20.0f
);
if
(
data
[
2
]
>=
0
&&
data
[
2
]
<=
20.0f
)
buf
[
2
]
=
(
UInt16
)
(
data
[
2
]
*
20.0f
/
20.0f
*
4095
/
20.0f
);
if
(
data
[
3
]
>=
0
&&
data
[
3
]
<=
30.0f
)
buf
[
3
]
=
(
UInt16
)
(
data
[
3
]
*
20.0f
/
30.0f
*
4095
/
20.0f
);
}
public
int
UpdateData
(
float
[]
data
)
{
UInt16
[]
buf
=
new
UInt16
[
4
]
{
0
,
4095
,
2047
,
1024
};
int
ret
=
rtumodbus
.
WriteMultipleRegs
(
1
,
1
,
4
,
ref
buf
);
return
ret
;
}
public
int
UpdateData2
(
float
[]
data
)
{
UInt16
[]
buf
=
new
UInt16
[
4
]
{
0
,
0
,
0
,
0
};
GetMaVal
(
data
,
ref
buf
);
int
ret
=
rtumodbus
.
WriteMultipleRegs
(
1
,
1
,
4
,
ref
buf
);
return
ret
;
}
}
}
GcDevicePc/Module/WTD624X.cs
0 → 100644
View file @
99c6abe7
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
GcDevicePc.Common
;
namespace
GcDevicePc.Module
{
class
WTD624X
{
private
GCModbus
tcpmodbus
=
null
;
private
bool
workflag
=
false
;
private
string
ip
=
""
;
private
ushort
port
=
502
;
public
WTD624X
(
String
module_ip
,
ushort
module_port
)
{
ip
=
module_ip
;
port
=
module_port
;
}
public
bool
GetWorkFlag
()
{
return
workflag
;
}
public
int
WTD624X_Open
()
{
int
ret
=
0
;
int
count
=
3
;
try
{
tcpmodbus
=
new
GCModbus
();
if
(
tcpmodbus
!=
null
)
{
workflag
=
true
;
UInt16
[]
buf
=
new
UInt16
[
4
]
{
1
,
1
,
1
,
1
};
ret
=
tcpmodbus
.
WriteMultipleRegs
(
11
,
4
,
ip
,
port
,
ref
buf
);
while
(
ret
!=
0
&&
count
>
0
)
{
ret
=
tcpmodbus
.
WriteMultipleRegs
(
11
,
4
,
ip
,
port
,
ref
buf
);
count
--;
}
}
}
catch
(
Exception
ex
)
{
Log
.
Error
(
ex
.
Message
);
}
return
ret
;
}
public
int
WTD624X_Close
()
{
int
ret
=
0
;
try
{
ret
=
tcpmodbus
.
GCModbusClose
();
if
(
ret
==
0
)
workflag
=
false
;
}
catch
(
Exception
ex
)
{
Log
.
Error
(
ex
.
Message
);
}
return
ret
;
}
private
void
GetMaVal
(
float
[]
data
,
ref
UInt16
[]
buf
)
{
if
(
data
[
0
]
>=
0
&&
data
[
0
]
<=
150.0f
)
buf
[
0
]
=
(
UInt16
)(
data
[
0
]
*
20.0f
/
150.0f
*
4095
/
20.0f
);
if
(
data
[
1
]
>=
0
&&
data
[
1
]
<=
10.0f
)
buf
[
1
]
=
(
UInt16
)(
data
[
1
]
*
20.0f
/
10.0f
*
4095
/
20.0f
);
if
(
data
[
2
]
>=
0
&&
data
[
2
]
<=
20.0f
)
buf
[
2
]
=
(
UInt16
)(
data
[
2
]
*
20.0f
/
20.0f
*
4095
/
20.0f
);
if
(
data
[
3
]
>=
0
&&
data
[
3
]
<=
30.0f
)
buf
[
3
]
=
(
UInt16
)(
data
[
3
]
*
20.0f
/
30.0f
*
4095
/
20.0f
);
}
public
int
UpdateData
(
float
[]
data
)
{
UInt16
[]
buf
=
new
UInt16
[
4
]
{
0
,
0
,
0
,
0
};
GetMaVal
(
data
,
ref
buf
);
int
ret
=
tcpmodbus
.
WriteMultipleRegs
(
1
,
4
,
ip
,
port
,
ref
buf
);
return
ret
;
}
public
int
UpdateIP
(
String
IP
,
String
Mask
,
String
GW
)
{
int
ret
=
0
;
string
[]
slocal_ip
=
IP
.
Split
(
'.'
);
string
[]
slocal_mask
=
Mask
.
Split
(
'.'
);
string
[]
slocal_gw
=
GW
.
Split
(
'.'
);
try
{
byte
[]
local_ip
=
new
byte
[
4
];
byte
[]
local_mask
=
new
byte
[
4
];
byte
[]
local_gw
=
new
byte
[
4
];
UInt16
[]
localdata
=
new
UInt16
[
6
];
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
local_ip
[
i
]
=
Convert
.
ToByte
(
slocal_ip
[
i
]);
local_mask
[
i
]
=
Convert
.
ToByte
(
slocal_mask
[
i
]);
local_gw
[
i
]
=
Convert
.
ToByte
(
slocal_gw
[
i
]);
}
localdata
[
0
]
=
(
ushort
)((
local_ip
[
1
]
&
0x00FF
)
|
((
local_ip
[
0
]
<<
8
)
&
0xFF00
));
localdata
[
1
]
=
(
ushort
)((
local_ip
[
3
]
&
0xFF
)
|
((
local_ip
[
2
]
<<
8
)
&
0xFF00
));
localdata
[
2
]
=
(
ushort
)((
local_mask
[
1
]
&
0xFF
)
|
((
local_mask
[
0
]
<<
8
)
&
0xFF00
));
localdata
[
3
]
=
(
ushort
)((
local_mask
[
3
]
&
0xFF
)
|
((
local_mask
[
2
]
<<
8
)
&
0xFF00
));
localdata
[
4
]
=
(
ushort
)((
local_gw
[
1
]
&
0xFF
)
|
((
local_gw
[
0
]
<<
8
)
&
0xFF00
));
localdata
[
5
]
=
(
ushort
)((
local_gw
[
3
]
&
0xFF
)
|
((
local_gw
[
2
]
<<
8
)
&
0xFF00
));
ret
=
tcpmodbus
.
WriteMultipleRegs
(
306
,
6
,
ip
,
port
,
ref
localdata
);
if
(
ret
==
0
)
{
ip
=
IP
;
}
}
catch
{
}
return
ret
;
}
}
}
GcDevicePc/ProThread/DataOutput.cs
0 → 100644
View file @
99c6abe7
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
GcDevicePc.Module
;
namespace
GcDevicePc.ProThread
{
class
DataOutput
{
ManualResetEvent
outputmre
=
new
ManualResetEvent
(
false
);
Thread
t_DataOut
;
private
WTD624X
wtd624x
=
new
WTD624X
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
moduleinfo
.
ip
,
502
);
private
bool
c6h6
=
false
;
private
bool
c7h8
=
false
;
private
bool
c8h10
=
false
;
//批量更新
//用于更新记录数据
private
void
OutPut_DataList
()
{
try
{
string
file
=
System
.
Windows
.
Forms
.
Application
.
StartupPath
+
"\\CarLine"
+
"\\Ingredient.ini"
;
int
[]
datano
=
new
int
[
6
]
{
1
,
1
,
1
,
1
,
1
,
1
};
if
(
File
.
Exists
(
file
))
{
INIOperation
test
=
new
INIOperation
(
file
);
string
scount
=
test
.
INIGetStringValue
(
"SYSINFO"
,
"ECOUNT"
,
null
);
int
count
=
Convert
.
ToInt32
(
scount
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
string
sid
=
test
.
INIGetStringValue
(
"ENTITY"
+
i
.
ToString
(),
"ID"
,
null
);
string
sname
=
test
.
INIGetStringValue
(
"ENTITY"
+
i
.
ToString
(),
"NAME"
,
null
);
if
(!
String
.
IsNullOrEmpty
(
sname
))
{
try
{
if
(
sname
==
"NMHC"
)
{
datano
[
0
]
=
Convert
.
ToInt32
(
sid
);
}
if
(
sname
==
"苯"
)
{
c6h6
=
true
;
datano
[
1
]
=
Convert
.
ToInt32
(
sid
);
}
if
(
sname
==
"甲苯"
)
{
c7h8
=
true
;
datano
[
2
]
=
Convert
.
ToInt32
(
sid
);
}
if
(
sname
==
"二甲苯"
)
{
c8h10
=
true
;
datano
[
3
]
=
Convert
.
ToInt32
(
sid
);
}
if
(
sname
==
"THC"
)
{
datano
[
4
]
=
Convert
.
ToInt32
(
sid
);
}
if
(
sname
==
"CH4"
)
{
datano
[
5
]
=
Convert
.
ToInt32
(
sid
);
}
}
catch
{
}
}
}
}
while
(!
outputmre
.
WaitOne
(
500
))
{
if
(
SharedSpace
.
Data
.
change
)
{
float
[]
data
=
new
float
[
4
]
{
0
,
0
,
0
,
0
};
double
[]
ratio
=
new
double
[
4
]
{
1
,
3.487053571
,
4.113392857
,
4.739285714
};
for
(
int
count
=
0
;
count
<
4
;
count
++)
{
switch
(
count
)
{
case
0
:
{
double
nmhc_data
=
(
SharedSpace
.
Data
.
listValue
[
datano
[
4
]
-
1
].
vale
-
SharedSpace
.
Data
.
listValue
[
datano
[
5
]
-
1
].
vale
)
*
ratio
[
count
]
*
12.0f
/
22.4f
;
data
[
count
]
=
float
.
Parse
(
nmhc_data
.
ToString
());
}
break
;
case
1
:
{
data
[
count
]
=
c6h6
?
float
.
Parse
(
(
SharedSpace
.
Data
.
listValue
[
datano
[
count
]
-
1
].
vale
*
ratio
[
count
])
.
ToString
())
:
0.0f
;
}
break
;
case
2
:
{
data
[
count
]
=
c7h8
?
float
.
Parse
(
(
SharedSpace
.
Data
.
listValue
[
datano
[
count
]
-
1
].
vale
*
ratio
[
count
])
.
ToString
())
:
0.0f
;
}
break
;
case
3
:
{
data
[
count
]
=
c8h10
?
float
.
Parse
(
(
SharedSpace
.
Data
.
listValue
[
datano
[
count
]
-
1
].
vale
*
ratio
[
count
])
.
ToString
())
:
0.0f
;
}
break
;
default
:
data
[
count
]
=
0
;
break
;
}
Trace
.
WriteLine
(
"周期结束"
+
count
.
ToString
()
+
":"
+
data
[
count
].
ToString
(),
"sys"
);
}
if
(
wtd624x
.
GetWorkFlag
())
{
wtd624x
.
UpdateData
(
data
);
}
}
}
}
catch
(
Exception
ex
)
{
Trace
.
WriteLine
(
"WTD624X模块输出 Crash 由于:"
+
ex
.
Message
,
"sys"
);
}
}
public
void
DataOutStart
()
{
if
(
outputmre
!=
null
)
{
outputmre
.
Reset
();
}
t_DataOut
=
new
Thread
(
OutPut_DataList
);
t_DataOut
.
IsBackground
=
true
;
t_DataOut
.
Start
();
if
(!
wtd624x
.
GetWorkFlag
())
{
wtd624x
.
WTD624X_Open
();
}
}
public
void
DataOutStop
()
{
outputmre
.
Set
();
if
(
wtd624x
.
GetWorkFlag
())
{
wtd624x
.
WTD624X_Open
();
}
}
}
}
GcDevicePc/ProThread/HMISearch.cs
View file @
99c6abe7
...
...
@@ -108,8 +108,8 @@ namespace GcDevicePc.ProThread
{
client
=
new
UdpClient
(
new
IPEndPoint
(
IPAddress
.
Any
,
0
));
// client = new UdpClient(new IPEndPoint(IPAddress.Parse(this._localip), 0));
//
endpoint = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 233);
endpoint
=
new
IPEndPoint
(
IPAddress
.
Parse
(
"192.168.10.230"
),
233
);
endpoint
=
new
IPEndPoint
(
IPAddress
.
Parse
(
"255.255.255.255"
),
233
);
//
endpoint = new IPEndPoint(IPAddress.Parse("192.168.10.230"), 233);
client
.
Send
(
sendBytes
,
sendBytes
.
Length
,
endpoint
);
Thread
.
Sleep
(
500
);
...
...
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