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
d269da47
Commit
d269da47
authored
Mar 22, 2018
by
wangjunqiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
清理部分代码
parent
a4d691be
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
1495 additions
and
834 deletions
+1495
-834
App.config
GcDevicePc/App.config
+47
-3
AppInit.cs
GcDevicePc/AppInit.cs
+402
-0
GCModbus.cs
GcDevicePc/Common/GCModbus.cs
+19
-19
GCModbusSlave.cs
GcDevicePc/Common/GCModbusSlave.cs
+1
-3
GCModbusSlave485.cs
GcDevicePc/Common/GCModbusSlave485.cs
+138
-0
Log.cs
GcDevicePc/Common/Log.cs
+32
-0
RunTableHelper.cs
GcDevicePc/Common/RunTableHelper.cs
+199
-0
FormUser.Designer.cs
GcDevicePc/FormUser.Designer.cs
+1
-0
FormUser.cs
GcDevicePc/FormUser.cs
+8
-1
PCBuffer.cs
GcDevicePc/GCBuffer/PCBuffer.cs
+9
-3
GcDevicePc.csproj
GcDevicePc/GcDevicePc.csproj
+12
-3
MDIBase.Designer.cs
GcDevicePc/MDIBase.Designer.cs
+104
-104
MDIBase.cs
GcDevicePc/MDIBase.cs
+376
-469
MDIBase.resx
GcDevicePc/MDIBase.resx
+1
-1
MainBase.cs
GcDevicePc/MainBase.cs
+2
-6
DataRcv.cs
GcDevicePc/ProThread/DataRcv.cs
+1
-1
HMISearch.cs
GcDevicePc/ProThread/HMISearch.cs
+54
-37
Program.cs
GcDevicePc/Program.cs
+45
-107
AssemblyInfo.cs
GcDevicePc/Properties/AssemblyInfo.cs
+1
-0
Resources.Designer.cs
GcDevicePc/Properties/Resources.Designer.cs
+1
-1
Settings.Designer.cs
GcDevicePc/Properties/Settings.Designer.cs
+1
-1
SaveCfg.cs
GcDevicePc/SaveCfg.cs
+2
-2
SendConfig.cs
GcDevicePc/SendConfig.cs
+2
-2
StartForm.cs
GcDevicePc/StartForm.cs
+27
-68
StartWin.cs
GcDevicePc/StartWin.cs
+4
-1
auxtool.cs
GcDevicePc/auxtool.cs
+1
-1
globaldata.cs
GcDevicePc/globaldata.cs
+2
-0
packages.config
GcDevicePc/packages.config
+3
-1
No files found.
GcDevicePc/App.config
View file @
d269da47
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.0"
/></
startup
>
<
configSections
>
<
section
name
=
"log4net"
type
=
"log4net.Config.Log4NetConfigurationSectionHandler, log4net"
/>
</
configSections
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.5"
/>
</
startup
>
<
runtime
>
<
legacyUnhandledExceptionPolicy
enabled
=
"true"
/>
</
runtime
>
<
log4net
>
<
logger
name
=
"Log"
>
<
level
value
=
"INFO"
/>
<
appender
-
ref
ref
=
"RollingLog"
/>
</
logger
>
<
logger
name
=
"Err"
>
<
level
value
=
"ERROR"
/>
<
appender
-
ref
ref
=
"RollingErr"
/>
</
logger
>
<
appender
name
=
"RollingLog"
type
=
"log4net.Appender.RollingFileAppender"
>
<
file
value
=
"Logs\InfoLog_"
/>
<
appendToFile
value
=
"true"
/>
<
rollingStyle
value
=
"Date"
/>
<
datePattern
value
=
"yyyyMMdd'.txt'"
/>
<
staticLogFileName
value
=
"false"
/>
<
layout
type
=
"log4net.Layout.PatternLayout"
>
<
conversionPattern
value
=
"Record Time:%d Thread ID:[%thread]- Info:%m%n"
/>
</
layout
>
<
filter
type
=
"log4net.Filter.LevelRangeFilter"
>
<
param
name
=
"LevelMin"
value
=
"INFO"
/>
<
param
name
=
"LevelMax"
value
=
"INFO"
/>
</
filter
>
</
appender
>
<
appender
name
=
"RollingErr"
type
=
"log4net.Appender.RollingFileAppender"
>
<
file
value
=
"Logs\ErrLog_"
/>
<
appendToFile
value
=
"true"
/>
<
rollingStyle
value
=
"Date"
/>
<
datePattern
value
=
"yyyyMMdd'.txt'"
/>
<
staticLogFileName
value
=
"false"
/>
<
layout
type
=
"log4net.Layout.PatternLayout"
>
<
conversionPattern
value
=
"Record Time:%d Thread ID:[%thread]- Error:%m%n"
/>
</
layout
>
<
filter
type
=
"log4net.Filter.LevelRangeFilter"
>
<
param
name
=
"LevelMin"
value
=
"ERROR"
/>
<
param
name
=
"LevelMax"
value
=
"ERROR"
/>
</
filter
>
</
appender
>
</
log4net
>
</
configuration
>
GcDevicePc/AppInit.cs
0 → 100644
View file @
d269da47
using
System
;
using
System.IO
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
GcDevicePc.Common
;
namespace
GcDevicePc
{
class
AppInit
{
/// <summary>
/// 检测文件和目录是否存在
/// </summary>
/// <param name="flag">检测标志 0-表示检测目录</param>
/// <param name="sPath"></param>
/// <returns></returns>
private
bool
CheckFolderandFile
(
int
flag
,
string
sPath
)
{
switch
(
flag
)
{
case
0
:
//检测并创建目录
{
if
(!
Directory
.
Exists
(
sPath
))
{
Directory
.
CreateDirectory
(
sPath
);
}
}
break
;
case
1
:
break
;
}
return
true
;
}
//private void GetGCCode()
//{
// int devicecount = 0;
// devicecount = globaldata.DeviceList.Count;
// int i = 0;
// int count = 0;
// string tmpfile = "";
// string tmpip = "";
// string tmpname = "";
// int ret = 0;
// if (devicecount > 0)
// {
// globaldata.DeviceName.Clear();
// FileServerClient mainclient = new FileServerClient();
// for (i = 0; i < devicecount; i++)
// {
// tmpip = (((globaldata.DeviceInfo)(globaldata.DeviceList[i])).IpAddr);
// mainclient.WtClientInit(tmpip, globaldata.fileserverport);
// //获取设备配置
// tmpfile = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.tmpFolder + "\\" + i.ToString() + "\\DevStatus.ini";
// if (System.IO.File.Exists(tmpfile))
// {
// Thread.Sleep(100);
// System.IO.File.Delete(tmpfile);
// }
// ret = mainclient.WtClientCopyfromServer("DevStatus.ini", tmpfile, globaldata.remoteFolder + "仪器状态\\");
// Thread.Sleep(400);
// {
// FileHelper tmpfh = new FileHelper(tmpfile);
// tmpname = tmpfh.GetProfileString("仪器编号", "仪器编码", "无编码设备");
// if (tmpname == "无编码设备")
// {
// tmpname = tmpname + count.ToString();
// count++;
// }
// globaldata.DeviceName.Add(tmpname);
// }
// }
// }
//}
//private void MoveDevFile()
//{
// int devicecount = 0;
// devicecount = globaldata.DeviceList.Count;
// int i = 0;
// string tmpfile = "";
// string tmpfile2 = "";
// string folderToBeDeleted = "";
// if (devicecount > 0)
// {
// for (i = 0; i < devicecount; i++)
// {
// tmpfile = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.tmpFolder + "\\" + i.ToString() + "\\DevStatus.ini";
// tmpfile2 = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.StatusFolder + "\\" + globaldata.DeviceName[i].ToString() + "\\DevStatus.ini";
// if (System.IO.File.Exists(tmpfile2))
// {
// System.IO.File.Delete(tmpfile2);
// }
// if (System.IO.File.Exists(tmpfile))
// {
// System.IO.File.Move(tmpfile, tmpfile2);
// Thread.Sleep(100);
// }
// {
// folderToBeDeleted = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.tmpFolder + "\\" + i.ToString();
// DirectoryInfo folder = new DirectoryInfo(folderToBeDeleted);
// if (folder.Exists)
// {
// folder.Delete(true);
// }
// }
// }
// }
//}
public
void
InitAppFolder
()
{
string
tmpFolder
;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunFolder
=
System
.
Windows
.
Forms
.
Application
.
StartupPath
;
tmpFolder
=
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunFolder
;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
MethodFolder
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"仪器方法"
);
CheckFolderandFile
(
0
,
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
MethodFolder
);
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
StatusFolder
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"仪器状态"
);
CheckFolderandFile
(
0
,
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
StatusFolder
);
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunTabFolder
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"运行表"
);
CheckFolderandFile
(
0
,
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunTabFolder
);
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
DataFolder
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"历史数据"
);
CheckFolderandFile
(
0
,
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
DataFolder
);
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
FwFolder
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"固件更新"
);
CheckFolderandFile
(
0
,
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
FwFolder
);
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
TmpFolder
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"tmpfile"
);
CheckFolderandFile
(
0
,
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
TmpFolder
);
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
LogFolder
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"Logs"
);
CheckFolderandFile
(
0
,
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
LogFolder
);
tmpFolder
=
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
StatusFolder
;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
SubStatusFolder
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"子状态"
);
CheckFolderandFile
(
0
,
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
SubStatusFolder
);
tmpFolder
=
null
;
}
public
void
InitAppDefaultConfig
()
{
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_MethodName
=
System
.
IO
.
Path
.
Combine
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
MethodFolder
,
"SingleAnal.ini(单次运行默认方法)"
);
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_StatusName
=
System
.
IO
.
Path
.
Combine
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
StatusFolder
,
"DevStatus.ini"
);
if
(!
String
.
IsNullOrEmpty
(
globaldata
.
connection_ip
)
&&
File
.
Exists
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_StatusName
)
==
false
)
{
File
.
Create
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_StatusName
).
Dispose
();
}
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_RunTab
=
System
.
IO
.
Path
.
Combine
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunTabFolder
,
"RunMethod.ini"
);
if
(!
File
.
Exists
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_RunTab
))
{
RunTableHelper
default_runtable
=
new
RunTableHelper
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunTabFolder
,
"RunMethod.ini"
);
default_runtable
.
SaveRunTable
();
}
}
public
void
InitDB
()
{
//SQLiteHelper mydb = new SQLiteHelper();
//mydb.fillmachineinfo("GC1001", "a.ini", "DevStatus.ini", "192.168.1.87", 1, 2);
}
/// <summary>
/// 获取所有GC的配置和方法
/// </summary>
//public void InitAllGC()
//{
// int devicecount = 0;
// devicecount = globaldata.DeviceList.Count;
// int i = 0;
// int j = 0;
// string tmpfile = "";
// string tmpip = "";
// string tmpname = "";
// int ret = 0;
// if (devicecount > 0)
// {
// //globaldata.DeviceName.Clear();
// globaldata.GCMethodName.Clear();
// globaldata.GCBatMethodName.Clear();
// FileServerClient mainclient = new FileServerClient();
// try
// {
// for (i = 0; i < devicecount; i++)
// {
// tmpip = (((globaldata.DeviceInfo)(globaldata.DeviceList[i])).IpAddr);
// mainclient.WtClientInit(tmpip, globaldata.fileserverport);
// ////获取设备配置
// //tmpfile = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.StatusFolder + "\\" + globaldata.DeviceName[i].ToString() + "\\DevStatus.ini";
// //if (System.IO.File.Exists(tmpfile))
// //{
// // Thread.Sleep(100);
// // System.IO.File.Delete(tmpfile);
// //}
// //ret = mainclient.WtClientCopyfromServer("DevStatus.ini", tmpfile, globaldata.remoteFolder + "仪器状态\\");
// //Thread.Sleep(400);
// //{
// // FileHelper tmpfh = new FileHelper(tmpfile);
// // tmpname = tmpfh.GetProfileString("仪器编号", "仪器编码", "无编码设备");
// // globaldata.DeviceName.Add(tmpname);
// //}
// //获取单次运行方法
// tmpfile = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.MethodFolder + "\\" + globaldata.DeviceName[i].ToString() + "\\SingleAnal.ini";
// if (System.IO.File.Exists(tmpfile))
// {
// Thread.Sleep(100);
// System.IO.File.Delete(tmpfile);
// }
// ret = mainclient.WtClientCopyfromServer("SingleAnal.ini", tmpfile, globaldata.remoteFolder + "仪器方法\\");
// Thread.Sleep(500);
// if (System.IO.File.Exists(tmpfile))
// {
// FileHelper tmpfh = new FileHelper(tmpfile);
// tmpname = tmpfh.GetProfileString("方法名称", "名称", "SingleAnal.ini");
// if (tmpname != "SingleAnal.ini")
// {
// tmpfile = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.MethodFolder + "\\" + globaldata.DeviceName[i].ToString() + "\\" + tmpname;
// ret = mainclient.WtClientCopyfromServer(tmpname, tmpfile, globaldata.remoteFolder + "仪器方法\\");
// Thread.Sleep(500);
// }
// globaldata.GCMethodName.Add(tmpname);
// }
// //获取批处理及其方法
// tmpfile = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.RunTabFolder + "\\" + globaldata.DeviceName[i].ToString() + "\\RunMethod.ini";
// if (System.IO.File.Exists(tmpfile))
// {
// Thread.Sleep(100);
// System.IO.File.Delete(tmpfile);
// }
// ret = mainclient.WtClientCopyfromServer("RunMethod.ini", tmpfile, globaldata.remoteFolder + "运行表\\");
// Thread.Sleep(500);
// if (System.IO.File.Exists(tmpfile))
// {
// string[] runtabnames = new string[256];
// FileHelper tmpfh = new FileHelper(tmpfile);
// runtabnames = tmpfh.GetAllItemKeys("运行表");
// Console.WriteLine("IP:" + tmpip);
// for (j = 0; j < runtabnames.Length; j++)
// {
// if (j != 0)
// {
// tmpname = tmpfh.GetProfileString("运行表", runtabnames[j], "SingleAnal.ini");
// tmpfile = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.MethodFolder + "\\" + globaldata.DeviceName[i].ToString() + "\\" + tmpname;
// if (System.IO.File.Exists(tmpfile))
// {
// Console.WriteLine(tmpfile.ToString() + " 方法已经存在!");
// }
// else
// {
// mainclient.WtClientCopyfromServer(tmpname, tmpfile, globaldata.remoteFolder + "仪器方法\\");
// Thread.Sleep(500);
// }
// if (j == 0)
// {
// globaldata.GCBatMethodName.Add(tmpname);
// }
// }
// }
// }
// }
// }
// catch
// {
// Console.WriteLine(tmpip + " is error!");
// }
// mainclient.WtClientClose();
// Console.WriteLine("InitAllGC is OK!");
// }
//}
//public void InitAllGCConfig()
//{
// int devicecount = 0;
// devicecount = globaldata.DeviceList.Count;
// int i = 0;
// string tmpfile = "";
// if (devicecount > 0)
// {
// globaldata.GCHWConfigs.Clear();
// for (i = 0; i < devicecount; i++)
// {
// tmpfile = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.StatusFolder + "\\" + globaldata.DeviceName[i].ToString() + "\\DevStatus.ini";
// HWConfig m_hwconfig = new HWConfig(tmpfile);
// m_hwconfig.GetHWConfig();
// globaldata.GCHWConfigs.Add(m_hwconfig);
// }
// }
//}
/// <summary>
/// 初始化基础线程
/// </summary>
//public void InitGCThread()
//{
// int devicecount = 0;
// devicecount = globaldata.DeviceList.Count;
// int i = 0;
// string tmpip = "";
// HWConfig m_hwconfig;
// HMIState mystate;
// ChannelData mychanneldata;
// GCDisplay mydisplay;
// Console.WriteLine("开始启动线程!");
// if (devicecount > 0)
// {
// globaldata.t_hmistate.Clear(); //清理状态采集线程
// globaldata.t_channeldata.Clear(); //清理通道采集线程
// globaldata.t_displaydata.Clear();
// for (i = 0; i < devicecount; i++)
// {
// tmpip = (((globaldata.DeviceInfo)(globaldata.DeviceList[i])).IpAddr);
// m_hwconfig = (HWConfig)globaldata.GCHWConfigs[i];
// mystate = new HMIState(tmpip, 502);
// mystate.SetHMIMAcState((((globaldata.DeviceInfo)(globaldata.DeviceList[i])).MacAddr));
// mystate.HmiStatueStart();
// mystate.SetHWConfig(m_hwconfig);
// globaldata.t_hmistate.Add(mystate);
// mychanneldata = new ChannelData(tmpip, 502);
// mychanneldata.ChannelDataStart();
// mychanneldata.SetHWConfig(m_hwconfig);
// globaldata.t_channeldata.Add(mychanneldata);
// mydisplay = new GCDisplay(tmpip, 502);
// mydisplay.DisplayDataStart();
// globaldata.t_displaydata.Add(mydisplay);
// }
// }
// Console.WriteLine("线程均启动!");
//}
//public void InitGCControl()
//{
// int devicecount = 0;
// devicecount = globaldata.DeviceList.Count;
// int i = 0;
// string tmpip = "";
// HMIControl mycontrol;
// if (devicecount > 0)
// {
// globaldata.t_hmicontrol.Clear();
// for (i = 0; i < devicecount; i++)
// {
// tmpip = (((globaldata.DeviceInfo)(globaldata.DeviceList[i])).IpAddr);
// mycontrol = new HMIControl(tmpip, globaldata.datamodbusport);
// globaldata.t_hmicontrol.Add(mycontrol);
// }
// }
//}
}
}
GcDevicePc/Common/GCModbus.cs
View file @
d269da47
...
...
@@ -12,27 +12,27 @@ namespace GcDevicePc.Common
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnLibModbus"
,
CharSet
=
CharSet
.
Unicode
)]
public
static
extern
uint
fnLibModbus
();
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnReadCoilStatus"
)]
public
static
extern
int
fnReadCoilStatus
(
uint
handle
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
Byte
[]
dest
,
byte
[]
Ip
,
ushort
wTcpPort
);
public
static
extern
int
fnReadCoilStatus
(
uint
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
Byte
[]
dest
,
byte
[]
Ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnReadInputStatus"
)]
public
static
extern
int
fnReadInputStatus
(
uint
handle
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
Char
[]
dest
,
byte
[]
Ip
,
ushort
wTcpPort
);
public
static
extern
int
fnReadInputStatus
(
uint
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
Char
[]
dest
,
byte
[]
Ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnReadHoldingReg"
)]
public
static
extern
int
fnReadHoldingReg
(
uint
handle
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
UInt16
[]
dest
,
byte
[]
Ip
,
ushort
wTcpPort
);
public
static
extern
int
fnReadHoldingReg
(
uint
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
UInt16
[]
dest
,
byte
[]
Ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnReadInputReg"
)]
public
static
extern
int
fnReadInputReg
(
uint
handle
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
UInt16
[]
dest
,
byte
[]
Ip
,
ushort
wTcpPort
);
public
static
extern
int
fnReadInputReg
(
uint
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
UInt16
[]
dest
,
byte
[]
Ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnWriteSingleCoil"
)]
public
static
extern
int
fnWriteSingleCoil
(
uint
handle
,
ushort
address
,
ushort
state
,
byte
[]
Ip
,
ushort
wTcpPort
);
public
static
extern
int
fnWriteSingleCoil
(
uint
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
state
,
byte
[]
Ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnWriteHoldingReg"
)]
public
static
extern
int
fnWriteHoldingReg
(
uint
handle
,
ushort
address
,
ushort
state
,
byte
[]
Ip
,
ushort
wTcpPort
);
public
static
extern
int
fnWriteHoldingReg
(
uint
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
state
,
byte
[]
Ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnWriteMultipleCoils"
)]
public
static
extern
int
fnWriteMultipleCoils
(
uint
handle
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
Char
[]
src
,
byte
[]
Ip
,
ushort
wTcpPort
);
public
static
extern
int
fnWriteMultipleCoils
(
uint
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
Char
[]
src
,
byte
[]
Ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnWriteMultipleRegs"
)]
public
static
extern
int
fnWriteMultipleRegs
(
uint
handle
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
UInt16
[]
src
,
byte
[]
Ip
,
ushort
wTcpPort
);
public
static
extern
int
fnWriteMultipleRegs
(
uint
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
num
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
UInt16
[]
src
,
byte
[]
Ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnReportSlaveID"
)]
public
static
extern
int
fnReportSlaveID
(
uint
handle
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
Char
[]
src
,
byte
[]
Ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnMaskWriteReg"
)]
public
static
extern
int
fnMaskWriteReg
(
uint
handle
,
ushort
address
,
ushort
amask
,
ushort
omask
,
byte
[]
Ip
,
ushort
wTcpPort
);
public
static
extern
int
fnMaskWriteReg
(
uint
handle
,
byte
slaveaddress
,
ushort
address
,
ushort
amask
,
ushort
omask
,
byte
[]
Ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnReadWriteMultipleRegs"
)]
public
static
extern
int
fnReadWriteMultipleRegs
(
uint
handle
,
ushort
waddress
,
ushort
wnum
,
ushort
raddress
,
ushort
rnum
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
UInt16
[]
dest
,
byte
[]
Ip
,
ushort
wTcpPort
);
public
static
extern
int
fnReadWriteMultipleRegs
(
uint
handle
,
byte
slaveaddress
,
ushort
waddress
,
ushort
wnum
,
ushort
raddress
,
ushort
rnum
,
[
MarshalAs
(
UnmanagedType
.
LPArray
,
SizeParamIndex
=
1
)]
System
.
UInt16
[]
dest
,
byte
[]
Ip
,
ushort
wTcpPort
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnLibModbusClose"
)]
public
static
extern
void
fnLibModbusClose
(
uint
handle
);
...
...
@@ -53,7 +53,7 @@ namespace GcDevicePc.Common
{
int
ret
;
byte
[]
bIp
=
Encoding
.
Unicode
.
GetBytes
(
ip
);
ret
=
fnReadCoilStatus
(
hModbusHandle
,
(
ushort
)(
addr
-
1
),
num
,
buf
,
bIp
,
wport
);
ret
=
fnReadCoilStatus
(
hModbusHandle
,
1
,
(
ushort
)(
addr
-
1
),
num
,
buf
,
bIp
,
wport
);
return
ret
;
}
...
...
@@ -61,7 +61,7 @@ namespace GcDevicePc.Common
{
int
ret
;
byte
[]
bIp
=
Encoding
.
Unicode
.
GetBytes
(
ip
);
ret
=
fnReadInputStatus
(
hModbusHandle
,
addr
,
1
,
buf
,
bIp
,
502
);
ret
=
fnReadInputStatus
(
hModbusHandle
,
1
,
addr
,
1
,
buf
,
bIp
,
502
);
return
ret
;
}
...
...
@@ -69,7 +69,7 @@ namespace GcDevicePc.Common
{
int
ret
;
byte
[]
bIp
=
Encoding
.
Unicode
.
GetBytes
(
ip
);
ret
=
fnReadHoldingReg
(
hModbusHandle
,
(
ushort
)(
addr
-
1
),
num
,
buf
,
bIp
,
wport
);
ret
=
fnReadHoldingReg
(
hModbusHandle
,
1
,
(
ushort
)(
addr
-
1
),
num
,
buf
,
bIp
,
wport
);
return
ret
;
}
...
...
@@ -77,7 +77,7 @@ namespace GcDevicePc.Common
{
int
ret
;
byte
[]
bIp
=
Encoding
.
Unicode
.
GetBytes
(
ip
);
ret
=
fnReadInputReg
(
hModbusHandle
,
addr
,
1
,
dest
,
bIp
,
502
);
ret
=
fnReadInputReg
(
hModbusHandle
,
1
,
addr
,
1
,
dest
,
bIp
,
502
);
buf
[
0
]
=
dest
[
0
];
return
ret
;
}
...
...
@@ -86,7 +86,7 @@ namespace GcDevicePc.Common
{
int
ret
=
0
;
byte
[]
bIp
=
Encoding
.
Unicode
.
GetBytes
(
ip
);
ret
=
fnWriteSingleCoil
(
hModbusHandle
,
(
ushort
)(
addr
-
1
),
state
,
bIp
,
wport
);
ret
=
fnWriteSingleCoil
(
hModbusHandle
,
1
,
(
ushort
)(
addr
-
1
),
state
,
bIp
,
wport
);
return
ret
;
}
...
...
@@ -94,7 +94,7 @@ namespace GcDevicePc.Common
{
int
ret
=
0
;
byte
[]
bIp
=
Encoding
.
Unicode
.
GetBytes
(
ip
);
ret
=
fnWriteHoldingReg
(
hModbusHandle
,
(
ushort
)(
addr
-
1
),
state
,
bIp
,
wport
);
ret
=
fnWriteHoldingReg
(
hModbusHandle
,
1
,
(
ushort
)(
addr
-
1
),
state
,
bIp
,
wport
);
return
ret
;
}
...
...
@@ -102,7 +102,7 @@ namespace GcDevicePc.Common
{
int
ret
;
byte
[]
bIp
=
Encoding
.
Unicode
.
GetBytes
(
ip
);
ret
=
fnWriteMultipleRegs
(
hModbusHandle
,
(
ushort
)(
addr
-
1
),
num
,
buf
,
bIp
,
wport
);
ret
=
fnWriteMultipleRegs
(
hModbusHandle
,
1
,
(
ushort
)(
addr
-
1
),
num
,
buf
,
bIp
,
wport
);
return
ret
;
}
...
...
@@ -118,7 +118,7 @@ namespace GcDevicePc.Common
{
int
ret
=
0
;
byte
[]
bIp
=
Encoding
.
Unicode
.
GetBytes
(
ip
);
ret
=
fnMaskWriteReg
(
hModbusHandle
,
addr
,
amask
,
omask
,
bIp
,
502
);
ret
=
fnMaskWriteReg
(
hModbusHandle
,
1
,
addr
,
amask
,
omask
,
bIp
,
502
);
return
ret
;
}
...
...
@@ -126,7 +126,7 @@ namespace GcDevicePc.Common
{
int
ret
=
0
;
byte
[]
bIp
=
Encoding
.
Unicode
.
GetBytes
(
ip
);
ret
=
fnReadWriteMultipleRegs
(
hModbusHandle
,
waddr
,
wnum
,
raddr
,
rnum
,
buf
,
bIp
,
502
);
ret
=
fnReadWriteMultipleRegs
(
hModbusHandle
,
1
,
waddr
,
wnum
,
raddr
,
rnum
,
buf
,
bIp
,
502
);
return
ret
;
}
...
...
GcDevicePc/Common/GCModbusSlave.cs
View file @
d269da47
...
...
@@ -105,8 +105,6 @@ namespace GcDevicePc.Common
value
=
s
[(
address
-
baseaddress
)%
2
];
}
catch
{
}
finally
{
}
//}
}
...
...
@@ -137,7 +135,7 @@ namespace GcDevicePc.Common
break
;
case
8
:
//HMI状态
{
value
=
(
ushort
)(
globaldata
.
m_hmibuffer
.
gcinfo
.
methodstatus
)
;
value
=
globaldata
.
m_hmibuffer
.
gcinfo
.
methodstatus
;
}
break
;
case
9
:
//前进样口
...
...
GcDevicePc/Common/GCModbusSlave485.cs
0 → 100644
View file @
d269da47
using
System
;
using
System.Runtime.InteropServices
;
namespace
GcDevicePc.Common
{
class
GCModbusSlave485
{
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
public
unsafe
delegate
ushort
SlaveReadHoldingRegister
(
ushort
address
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
public
unsafe
delegate
void
SlaveWriteHoldingRegister
(
ushort
address
,
ushort
value
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
public
unsafe
delegate
ushort
SlaveReadCoilsRegister
(
ushort
address
);
[
UnmanagedFunctionPointer
(
CallingConvention
.
Cdecl
)]
public
unsafe
delegate
void
SlaveWriteCoilsRegister
(
ushort
address
,
ushort
value
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnLibModbusSlave485Init"
,
CharSet
=
CharSet
.
Unicode
)]
public
static
extern
uint
fnLibModbusSlave485Init
(
System
.
Byte
port
,
System
.
Int32
BaudRate
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnLibModbusSlaveHoldingRegister"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
public
static
extern
void
fnLibModbusSlaveHoldingRegister
(
System
.
UInt32
handle
,
SlaveReadHoldingRegister
callslavereadholdingreg
,
SlaveWriteHoldingRegister
callslavewirteholdingreg
,
ushort
startAddr
,
ushort
NReg
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnLibModbusSlaveCoilsRegister"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
public
static
extern
void
fnLibModbusSlaveCoilsRegister
(
System
.
UInt32
handle
,
SlaveReadCoilsRegister
callslavereadcoilsreg
,
SlaveWriteCoilsRegister
callslavewirtecoilsreg
,
ushort
startAddr
,
ushort
NReg
);
[
DllImport
(
@"LibModbus.dll"
,
EntryPoint
=
"fnLibModbusSlaveClose"
)]
public
static
extern
uint
fnLibModbusSlaveClose
(
uint
handle
);
private
uint
hModbusHandle
;
public
GCModbusSlave485
(
Byte
port
,
int
baudrate
)
{
this
.
hModbusHandle
=
fnLibModbusSlave485Init
(
port
,
baudrate
);
}
~
GCModbusSlave485
()
{
try
{
fnLibModbusSlaveClose
(
hModbusHandle
);
}
catch
{
}
}
public
uint
CModbusSlave485Close
()
{
uint
ret
=
0
;
try
{
ret
=
fnLibModbusSlaveClose
(
hModbusHandle
);
}
catch
{
Console
.
WriteLine
(
"Slave 退出出现Bug"
);
}
return
ret
;
}
public
void
CModbusSlave485Init
(
ushort
hstartaddr
,
ushort
hnreg
,
ushort
cstartaddr
,
ushort
cnreg
)
{
setHoldingRegisterFunc
(
hstartaddr
,
hnreg
);
setCoilsRegisterFunc
(
cstartaddr
,
cnreg
);
}
SlaveReadHoldingRegister
MySlaveReadHoldingRegister
;
SlaveWriteHoldingRegister
MySlaveWriteHoldingRegister
;
public
void
setHoldingRegisterFunc
(
ushort
startaddr
,
ushort
nreg
)
{
MySlaveReadHoldingRegister
=
new
SlaveReadHoldingRegister
(
slavereadhreg
);
MySlaveWriteHoldingRegister
=
new
SlaveWriteHoldingRegister
(
slavewirtehreg
);
fnLibModbusSlaveHoldingRegister
(
hModbusHandle
,
MySlaveReadHoldingRegister
,
MySlaveWriteHoldingRegister
,
startaddr
,
nreg
);
}
static
ushort
slavereadhreg
(
ushort
address
)
{
ushort
value
=
0
;
ushort
baseaddress
=
20
;
address
=
(
ushort
)(
address
-
1
);
int
listnum
=
CKVocAnalyzer
.
GlobalCKV
.
valueparamlist
.
Count
;
int
readnum
=
(
address
-
baseaddress
)
/
2
;
if
(
readnum
<=
listnum
-
1
&&
listnum
>
0
&&
address
>=
20
)
{
try
{
ushort
[]
s
=
new
ushort
[
2
];
float
[]
f
=
new
float
[
2
];
{
f
[
0
]
=
float
.
Parse
(
CKVocAnalyzer
.
GlobalCKV
.
valueparamlist
[(
ushort
)
readnum
].
ToString
());
Buffer
.
BlockCopy
(
f
,
2
,
s
,
0
,
2
);
Buffer
.
BlockCopy
(
f
,
0
,
s
,
2
,
2
);
}
value
=
s
[(
address
-
baseaddress
)
%
2
];
}
catch
{
}
}
return
value
;
}
static
void
slavewirtehreg
(
ushort
address
,
ushort
value
)
{
Console
.
WriteLine
(
"MoudbusSlave Wirte adder:"
+
address
.
ToString
()
+
" value:"
+
value
.
ToString
());
}
SlaveReadCoilsRegister
MySlaveReadCoilsRegister
;
SlaveWriteCoilsRegister
MySlaveWriteCoilsRegister
;
public
void
setCoilsRegisterFunc
(
ushort
startaddr
,
ushort
nreg
)
{
MySlaveReadCoilsRegister
=
new
SlaveReadCoilsRegister
(
slavereadcreg
);
MySlaveWriteCoilsRegister
=
new
SlaveWriteCoilsRegister
(
slavewirtecreg
);
fnLibModbusSlaveCoilsRegister
(
hModbusHandle
,
MySlaveReadCoilsRegister
,
MySlaveWriteCoilsRegister
,
startaddr
,
nreg
);
}
public
static
ushort
slavereadcreg
(
ushort
address
)
{
ushort
value
=
0
;
// Console.WriteLine("MoudbusSlave Read Holding adder is " + CKVocAnalyzer.GlobalCKV.valueparamlist.ToString());
return
value
;
}
public
static
void
slavewirtecreg
(
ushort
address
,
ushort
value
)
{
//Console.WriteLine("MoudbusSlave Wirte adder:" + address.ToString() + " value:" + value.ToString());
}
}
}
GcDevicePc/Common/Log.cs
0 → 100644
View file @
d269da47
using
System.Diagnostics
;
using
log4net
;
using
System.Reflection
;
namespace
GcDevicePc.Common
{
public
static
class
Log
{
private
static
readonly
ILog
logInfo
=
LogManager
.
GetLogger
(
"Log"
);
private
static
readonly
ILog
logErr
=
LogManager
.
GetLogger
(
"Err"
);
/// <summary>
/// 记录正常的消息
/// </summary>
/// <param name="msg">消息内容</param>
public
static
void
Info
(
string
msg
)
{
logInfo
.
Info
(
msg
);
}
/// <summary>
/// 记录异常信息
/// </summary>
/// <param name="msg">异常信息内容</param>
public
static
void
Error
(
string
msg
)
{
StackTrace
stackTrace
=
new
StackTrace
();
StackFrame
stackFrame
=
stackTrace
.
GetFrame
(
1
);
MethodBase
methodBase
=
stackFrame
.
GetMethod
();
logErr
.
Error
(
"ClassName:"
+
methodBase
.
ReflectedType
.
Name
+
" Func Name:"
+
methodBase
.
Name
+
" Info:"
+
msg
);
}
}
}
GcDevicePc/Common/RunTableHelper.cs
0 → 100644
View file @
d269da47
using
System
;
using
System.IO
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Ini.Net
;
namespace
GcDevicePc.Common
{
class
RunTableHelper
{
private
string
_filename
;
private
string
_asfilename
;
public
bool
fileflag
=
false
;
private
IniFile
RunTableFile
;
private
IniFile
AsRunTableFile
;
public
List
<
String
>
_methodname
=
new
List
<
String
>();
public
List
<
Int32
>
_runcount
=
new
List
<
Int32
>();
public
List
<
Int32
>
_runtime
=
new
List
<
Int32
>();
private
void
RunTableInit
()
{
_methodname
.
Add
(
"开机"
);
_runcount
.
Add
(
1
);
_runtime
.
Add
(
1
);
}
public
RunTableHelper
(
String
folder
,
String
filename
)
{
_filename
=
folder
+
"\\"
+
filename
;
try
{
if
(!
File
.
Exists
(
_filename
))
{
StreamWriter
sw
=
new
StreamWriter
(
_filename
,
false
,
Encoding
.
Unicode
);
sw
.
WriteLine
(
"[Total]"
);
sw
.
WriteLine
(
"[运行表]"
);
sw
.
WriteLine
(
"[循环]"
);
sw
.
WriteLine
(
"[运行时间]"
);
sw
.
Close
();
fileflag
=
true
;
RunTableInit
();
}
else
{
fileflag
=
true
;
}
}
catch
(
Exception
e
)
{
Log
.
Error
(
e
.
Message
);
}
if
(
fileflag
)
LoadRunTable
();
}
public
void
LoadRunTable
()
{
RunTableFile
=
new
IniFile
(
_filename
);
int
num
=
0
;
int
i
=
0
;
if
(
RunTableFile
.
KeyExists
(
"Total"
,
"count"
))
{
num
=
RunTableFile
.
ReadInteger
(
"Total"
,
"count"
);
for
(
i
=
0
;
i
<
num
;
i
++)
{
_methodname
.
Add
(
RunTableFile
.
ReadString
(
"运行表"
,
i
.
ToString
()));
_runcount
.
Add
(
RunTableFile
.
ReadInteger
(
"循环"
,
i
.
ToString
()));
_runtime
.
Add
(
RunTableFile
.
ReadInteger
(
"运行时间"
,
i
.
ToString
()));
}
}
else
{
for
(
i
=
0
;
i
<
100
;
i
++)
{
if
(
RunTableFile
.
KeyExists
(
"运行表"
,
i
.
ToString
())
&&
RunTableFile
.
KeyExists
(
"循环"
,
i
.
ToString
())
&&
RunTableFile
.
KeyExists
(
"运行时间"
,
i
.
ToString
()))
{
_methodname
.
Add
(
RunTableFile
.
ReadString
(
"运行表"
,
i
.
ToString
()));
_runcount
.
Add
(
RunTableFile
.
ReadInteger
(
"循环"
,
i
.
ToString
()));
_runtime
.
Add
(
RunTableFile
.
ReadInteger
(
"运行时间"
,
i
.
ToString
()));
}
else
{
RunTableFile
.
WriteInteger
(
"Total"
,
"count"
,
i
);
break
;
}
}
}
}
public
void
DelRunTable
()
{
if
(
File
.
Exists
(
_filename
))
File
.
Delete
(
_filename
);
}
public
void
AddItem
(
String
name
,
Int32
count
,
Int32
time
)
{
_methodname
.
Add
(
name
);
_runcount
.
Add
(
count
);
_runtime
.
Add
(
time
);
}
public
void
ModifyItem
(
Int32
index
,
String
name
,
Int32
count
,
Int32
time
)
{
_methodname
[
index
]
=
name
;
_runcount
[
index
]
=
count
;
_runtime
[
index
]
=
time
;
}
public
bool
RemoveItem
(
String
name
,
Int32
count
,
Int32
time
)
{
int
indexno
=
0
;
if
(
_methodname
.
Contains
(
name
))
{
indexno
&=
_methodname
.
IndexOf
(
name
);
indexno
&=
_runcount
.
IndexOf
(
count
);
indexno
&=
_runtime
.
IndexOf
(
time
);
if
(
indexno
==
0
)
{
_methodname
.
RemoveAt
(
indexno
);
_runcount
.
RemoveAt
(
indexno
);
_runtime
.
RemoveAt
(
indexno
);
return
true
;
}
}
return
false
;
}
private
bool
saveini
(
IniFile
saveini
)
{
int
i
;
int
count
=
_methodname
.
Count
&
_runcount
.
Count
&
_runtime
.
Count
;
for
(
i
=
0
;
i
<
_methodname
.
Count
;
i
++)
{
saveini
.
WriteString
(
"运行表"
,
i
.
ToString
(),
_methodname
[
i
]);
}
for
(
i
=
0
;
i
<
_runcount
.
Count
;
i
++)
{
saveini
.
WriteInteger
(
"循环"
,
i
.
ToString
(),
_runcount
[
i
]);
}
for
(
i
=
0
;
i
<
_runtime
.
Count
;
i
++)
{
saveini
.
WriteInteger
(
"运行时间"
,
i
.
ToString
(),
_runtime
[
i
]);
}
saveini
.
WriteInteger
(
"Total"
,
"count"
,
count
);
return
true
;
}
public
bool
SaveRunTable
()
{
return
saveini
(
RunTableFile
);
}
public
bool
SaveAsRunTable
(
String
folder
,
String
filename
)
{
_asfilename
=
folder
+
"\\"
+
filename
;
try
{
if
(!
File
.
Exists
(
_asfilename
))
{
StreamWriter
sw
=
new
StreamWriter
(
_asfilename
,
false
,
Encoding
.
Unicode
);
sw
.
WriteLine
(
"[Total]"
);
sw
.
WriteLine
(
"[运行表]"
);
sw
.
WriteLine
(
"[循环]"
);
sw
.
WriteLine
(
"[运行时间]"
);
sw
.
Close
();
}
}
catch
(
Exception
e
)
{
Log
.
Error
(
e
.
Message
);
}
AsRunTableFile
=
new
IniFile
(
_asfilename
);
return
saveini
(
AsRunTableFile
);
}
}
}
GcDevicePc/FormUser.Designer.cs
View file @
d269da47
...
...
@@ -89,6 +89,7 @@
this
.
Activated
+=
new
System
.
EventHandler
(
this
.
FormUser_Activated
);
this
.
Deactivate
+=
new
System
.
EventHandler
(
this
.
FormUser_Deactivate
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
FormUser_Load
);
this
.
Resize
+=
new
System
.
EventHandler
(
this
.
FormUser_Resize
);
this
.
ResumeLayout
(
false
);
}
...
...
GcDevicePc/FormUser.cs
View file @
d269da47
...
...
@@ -34,12 +34,19 @@ namespace GcDevicePc
// MessageBox.Show("停用");
// Console.WriteLine("停用");
}
public
event
Fireport
autofire
;
private
void
buttonFID_Click
(
object
sender
,
EventArgs
e
)
{
autofire
(
0
,
10
,
5
);
}
private
void
FormUser_Resize
(
object
sender
,
EventArgs
e
)
{
this
.
buttonFID
.
Location
=
new
Point
(
this
.
infoBarUser1
.
Width
+
50
,
this
.
infoBarUser1
.
Location
.
Y
+
10
);
this
.
buttonauto
.
Location
=
new
Point
(
this
.
infoBarUser1
.
Width
+
50
,
this
.
infoBarUser1
.
Location
.
Y
+
80
);
}
}
}
GcDevicePc/GCBuffer/PCBuffer.cs
View file @
d269da47
...
...
@@ -12,9 +12,12 @@ namespace GcDevicePc.GCBuffer
public
string
DataFolder
;
//数据保存目录
public
string
RunFolder
;
//当前程序运行目录
public
string
MethodFolder
;
//当前方法目录
public
string
StatusFolder
;
//当前
状态
目录
public
string
subStatusFolder
;
//当前状态
目录
public
string
StatusFolder
;
//当前
配置
目录
public
string
SubStatusFolder
;
//当前配置子
目录
public
string
RunTabFolder
;
//当前运行表目录
public
string
FwFolder
;
//固件更新目录
public
string
TmpFolder
;
//TMPFile目录
public
string
LogFolder
;
//Log目录
}
public
struct
GCFileInfo
...
...
@@ -58,8 +61,11 @@ namespace GcDevicePc.GCBuffer
gcpcinfo
.
pcfolderinfo
.
RunFolder
=
null
;
gcpcinfo
.
pcfolderinfo
.
MethodFolder
=
null
;
gcpcinfo
.
pcfolderinfo
.
StatusFolder
=
null
;
gcpcinfo
.
pcfolderinfo
.
s
ubStatusFolder
=
null
;
gcpcinfo
.
pcfolderinfo
.
S
ubStatusFolder
=
null
;
gcpcinfo
.
pcfolderinfo
.
RunTabFolder
=
null
;
gcpcinfo
.
pcfolderinfo
.
FwFolder
=
null
;
gcpcinfo
.
pcfolderinfo
.
TmpFolder
=
null
;
gcpcinfo
.
pcfolderinfo
.
LogFolder
=
null
;
gcpcinfo
.
pcfileinfo
.
cur_MethodName
=
null
;
gcpcinfo
.
pcfileinfo
.
cur_OpenMethodName
=
null
;
...
...
GcDevicePc/GcDevicePc.csproj
View file @
d269da47
...
...
@@ -9,7 +9,7 @@
<AppDesignerFolder>
Properties
</AppDesignerFolder>
<RootNamespace>
GcDevicePc
</RootNamespace>
<AssemblyName>
GcDevicePc
</AssemblyName>
<TargetFrameworkVersion>
v4.
0
</TargetFrameworkVersion>
<TargetFrameworkVersion>
v4.
5
</TargetFrameworkVersion>
<FileAlignment>
512
</FileAlignment>
<IsWebBootstrapper>
false
</IsWebBootstrapper>
<TargetFrameworkProfile>
...
...
@@ -67,7 +67,7 @@
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)' == 'Debug|x86'"
>
<DebugSymbols>
true
</DebugSymbols>
<OutputPath>
bin\
x86\
Debug\
</OutputPath>
<OutputPath>
bin\Debug\
</OutputPath>
<DefineConstants>
DEBUG;TRACE
</DefineConstants>
<AllowUnsafeBlocks>
true
</AllowUnsafeBlocks>
<DebugType>
full
</DebugType>
...
...
@@ -99,6 +99,12 @@
<Reference
Include=
"CKVocAnalyzer"
>
<HintPath>
..\dll\CKVocAnalyzer.dll
</HintPath>
</Reference>
<Reference
Include=
"Ini.Net, Version=1.0.5531.18665, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\ini.net.1.1.0\lib\net20\Ini.Net.dll
</HintPath>
</Reference>
<Reference
Include=
"log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"
>
<HintPath>
..\packages\log4net.2.0.8\lib\net45-full\log4net.dll
</HintPath>
</Reference>
<Reference
Include=
"LogOperate"
>
<HintPath>
..\dll\LogOperate.dll
</HintPath>
</Reference>
...
...
@@ -138,6 +144,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"AppInit.cs"
/>
<Compile
Include=
"auxtool.cs"
>
<SubType>
Form
</SubType>
</Compile>
...
...
@@ -183,7 +190,9 @@
<Compile
Include=
"Common\GCModbus.cs"
/>
<Compile
Include=
"Common\GCModbusSlave.cs"
/>
<Compile
Include=
"Common\FileHelper.cs"
/>
<Compile
Include=
"Common\LogHelper.cs"
/>
<Compile
Include=
"Common\GCModbusSlave485.cs"
/>
<Compile
Include=
"Common\Log.cs"
/>
<Compile
Include=
"Common\RunTableHelper.cs"
/>
<Compile
Include=
"Common\SendDataToHW.cs"
/>
<Compile
Include=
"ConfigDlg\ChromeDlg.cs"
>
<SubType>
Form
</SubType>
...
...
GcDevicePc/MDIBase.Designer.cs
View file @
d269da47
...
...
@@ -31,22 +31,22 @@
this
.
components
=
new
System
.
ComponentModel
.
Container
();
this
.
menuStrip
=
new
System
.
Windows
.
Forms
.
MenuStrip
();
this
.
用户管理
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
用户登录
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
用户注销
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
UserLoginMenu
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
UserLogoutMenu
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
系统
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
系统开启
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
系统关闭
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
辅助工具
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
SystemStartMenu
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
SystemStopMenu
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
AuxToolMenu
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
运行
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
网络配置
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
方法批处理
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
新建方法
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
打开方法文件
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
方法查阅
ToolStrip
MenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
NetWorkMenu
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
MethodBatMenu
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
NewMethodMenu
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
OpenMethodMenu
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
MethodBrowse
MenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
窗口
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
调试窗口
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
校准查看
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
历史谱图
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
HistoryDataMenu
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
CalibrationMenu
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
HistoryPicMenu
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
statusStrip
=
new
System
.
Windows
.
Forms
.
StatusStrip
();
this
.
toolStripStatusLabelusertime
=
new
System
.
Windows
.
Forms
.
ToolStripStatusLabel
();
this
.
toolStripStatusLabeSystme
=
new
System
.
Windows
.
Forms
.
ToolStripStatusLabel
();
...
...
@@ -75,134 +75,134 @@
// 用户管理ToolStripMenuItem
//
this
.
用户管理
ToolStripMenuItem
.
DropDownItems
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
this
.
用户登录
ToolStripMenuItem
,
this
.
用户注销
ToolStripMenuItem
});
this
.
UserLoginMenu
,
this
.
UserLogoutMenu
});
this
.
用户管理
ToolStripMenuItem
.
Name
=
"用户管理ToolStripMenuItem"
;
this
.
用户管理
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
68
,
21
);
this
.
用户管理
ToolStripMenuItem
.
Text
=
"用户管理"
;
//
//
用户登录ToolStripMenuItem
//
UserLoginMenu
//
this
.
用户登录
ToolStripMenuItem
.
Name
=
"用户登录ToolStripMenuItem
"
;
this
.
用户登录
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
124
,
22
);
this
.
用户登录
ToolStripMenuItem
.
Text
=
"用户登录"
;
this
.
用户登录
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
用户登录
ToolStripMenuItem
_Click
);
this
.
UserLoginMenu
.
Name
=
"UserLoginMenu
"
;
this
.
UserLoginMenu
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
UserLoginMenu
.
Text
=
"用户登录"
;
this
.
UserLoginMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
UserLoginMenu
_Click
);
//
//
用户注销ToolStripMenuItem
//
UserLogoutMenu
//
this
.
用户注销
ToolStripMenuItem
.
Name
=
"用户注销ToolStripMenuItem
"
;
this
.
用户注销
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
124
,
22
);
this
.
用户注销
ToolStripMenuItem
.
Text
=
"用户注销"
;
this
.
用户注销
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
用户注销
ToolStripMenuItem
_Click
);
this
.
UserLogoutMenu
.
Name
=
"UserLogoutMenu
"
;
this
.
UserLogoutMenu
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
UserLogoutMenu
.
Text
=
"用户注销"
;
this
.
UserLogoutMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
UserLogoutMenu
_Click
);
//
// 系统ToolStripMenuItem
//
this
.
系统
ToolStripMenuItem
.
DropDownItems
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
this
.
系统开启
ToolStripMenuItem
,
this
.
系统关闭
ToolStripMenuItem
,
this
.
辅助工具
ToolStripMenuItem
});
this
.
SystemStartMenu
,
this
.
SystemStopMenu
,
this
.
AuxToolMenu
});
this
.
系统
ToolStripMenuItem
.
Name
=
"系统ToolStripMenuItem"
;
this
.
系统
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
44
,
21
);
this
.
系统
ToolStripMenuItem
.
Text
=
"系统"
;
//
//
系统开启ToolStripMenuItem
//
SystemStartMenu
//
this
.
系统开启
ToolStripMenuItem
.
Name
=
"系统开启ToolStripMenuItem
"
;
this
.
系统开启
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
124
,
22
);
this
.
系统开启
ToolStripMenuItem
.
Text
=
"系统开启"
;
this
.
系统开启
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
系统开启
ToolStripMenuItem
_Click
);
this
.
SystemStartMenu
.
Name
=
"SystemStartMenu
"
;
this
.
SystemStartMenu
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
SystemStartMenu
.
Text
=
"系统开启"
;
this
.
SystemStartMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
SystemStartMenu
_Click
);
//
//
系统关闭ToolStripMenuItem
//
SystemStopMenu
//
this
.
系统关闭
ToolStripMenuItem
.
Name
=
"系统关闭ToolStripMenuItem
"
;
this
.
系统关闭
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
124
,
22
);
this
.
系统关闭
ToolStripMenuItem
.
Text
=
"系统关闭"
;
this
.
系统关闭
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
系统关闭
ToolStripMenuItem
_Click
);
this
.
SystemStopMenu
.
Name
=
"SystemStopMenu
"
;
this
.
SystemStopMenu
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
SystemStopMenu
.
Text
=
"系统关闭"
;
this
.
SystemStopMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
SystemStopMenu
_Click
);
//
//
辅助工具ToolStripMenuItem
//
AuxToolMenu
//
this
.
辅助工具
ToolStripMenuItem
.
Name
=
"辅助工具ToolStripMenuItem
"
;
this
.
辅助工具
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
124
,
22
);
this
.
辅助工具
ToolStripMenuItem
.
Text
=
"辅助工具"
;
this
.
辅助工具
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
辅助工具
ToolStripMenuItem
_Click
);
this
.
AuxToolMenu
.
Name
=
"AuxToolMenu
"
;
this
.
AuxToolMenu
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
AuxToolMenu
.
Text
=
"辅助工具"
;
this
.
AuxToolMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
AuxToolMenu
_Click
);
//
// 运行ToolStripMenuItem
//
this
.
运行
ToolStripMenuItem
.
DropDownItems
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
this
.
网络配置
ToolStripMenuItem
,
this
.
方法批处理
ToolStripMenuItem
,
this
.
新建方法
ToolStripMenuItem
,
this
.
打开方法文件
ToolStripMenuItem
,
this
.
方法查阅
ToolStrip
MenuItem
});
this
.
NetWorkMenu
,
this
.
MethodBatMenu
,
this
.
NewMethodMenu
,
this
.
OpenMethodMenu
,
this
.
MethodBrowse
MenuItem
});
this
.
运行
ToolStripMenuItem
.
Name
=
"运行ToolStripMenuItem"
;
this
.
运行
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
44
,
21
);
this
.
运行
ToolStripMenuItem
.
Text
=
"设置"
;
//
//
网络配置ToolStripMenuItem
//
NetWorkMenu
//
this
.
网络配置
ToolStripMenuItem
.
Name
=
"网络配置ToolStripMenuItem
"
;
this
.
网络配置
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
148
,
22
);
this
.
网络配置
ToolStripMenuItem
.
Text
=
"网络配置"
;
this
.
网络配置
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
网络配置
ToolStripMenuItem
_Click
);
this
.
NetWorkMenu
.
Name
=
"NetWorkMenu
"
;
this
.
NetWorkMenu
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
NetWorkMenu
.
Text
=
"网络配置"
;
this
.
NetWorkMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
NetWorkMenu
_Click
);
//
//
方法批处理ToolStripMenuItem
//
MethodBatMenu
//
this
.
方法批处理
ToolStripMenuItem
.
Name
=
"方法批处理ToolStripMenuItem
"
;
this
.
方法批处理
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
148
,
22
);
this
.
方法批处理
ToolStripMenuItem
.
Text
=
"方法批处理"
;
this
.
方法批处理
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
方法批处理
ToolStripMenuItem
_Click
);
this
.
MethodBatMenu
.
Name
=
"MethodBatMenu
"
;
this
.
MethodBatMenu
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
MethodBatMenu
.
Text
=
"方法批处理"
;
this
.
MethodBatMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
MethodBatMenu
_Click
);
//
//
新建方法ToolStripMenuItem
//
NewMethodMenu
//
this
.
新建方法
ToolStripMenuItem
.
Name
=
"新建方法ToolStripMenuItem
"
;
this
.
新建方法
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
148
,
22
);
this
.
新建方法
ToolStripMenuItem
.
Text
=
"新建方法"
;
this
.
新建方法
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
新建方法
ToolStripMenuItem
_Click
);
this
.
NewMethodMenu
.
Name
=
"NewMethodMenu
"
;
this
.
NewMethodMenu
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
NewMethodMenu
.
Text
=
"新建方法"
;
this
.
NewMethodMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
NewMethodMenu
_Click
);
//
//
打开方法文件ToolStripMenuItem
//
OpenMethodMenu
//
this
.
打开方法文件
ToolStripMenuItem
.
Name
=
"打开方法文件ToolStripMenuItem
"
;
this
.
打开方法文件
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
148
,
22
);
this
.
打开方法文件
ToolStripMenuItem
.
Text
=
"打开方法文件"
;
this
.
打开方法文件
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
打开方法文件
ToolStripMenuItem
_Click
);
this
.
OpenMethodMenu
.
Name
=
"OpenMethodMenu
"
;
this
.
OpenMethodMenu
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
OpenMethodMenu
.
Text
=
"打开方法文件"
;
this
.
OpenMethodMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
OpenMethodMenu
_Click
);
//
//
方法查阅ToolStrip
MenuItem
//
MethodBrowse
MenuItem
//
this
.
方法查阅
ToolStripMenuItem
.
Name
=
"方法查阅ToolStrip
MenuItem"
;
this
.
方法查阅
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
148
,
22
);
this
.
方法查阅
ToolStrip
MenuItem
.
Text
=
"方法查阅"
;
this
.
方法查阅
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
方法查阅
ToolStrip
MenuItem_Click
);
this
.
MethodBrowseMenuItem
.
Name
=
"MethodBrowse
MenuItem"
;
this
.
MethodBrowseMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
MethodBrowse
MenuItem
.
Text
=
"方法查阅"
;
this
.
MethodBrowseMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
MethodBrowse
MenuItem_Click
);
//
// 窗口ToolStripMenuItem
//
this
.
窗口
ToolStripMenuItem
.
DropDownItems
.
AddRange
(
new
System
.
Windows
.
Forms
.
ToolStripItem
[]
{
this
.
调试窗口
ToolStripMenuItem
,
this
.
校准查看
ToolStripMenuItem
,
this
.
历史谱图
ToolStripMenuItem
});
this
.
HistoryDataMenu
,
this
.
CalibrationMenu
,
this
.
HistoryPicMenu
});
this
.
窗口
ToolStripMenuItem
.
Name
=
"窗口ToolStripMenuItem"
;
this
.
窗口
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
68
,
21
);
this
.
窗口
ToolStripMenuItem
.
Text
=
"数据查看"
;
//
//
调试窗口ToolStripMenuItem
//
HistoryDataMenu
//
this
.
调试窗口
ToolStripMenuItem
.
Name
=
"调试窗口ToolStripMenuItem
"
;
this
.
调试窗口
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
148
,
22
);
this
.
调试窗口
ToolStripMenuItem
.
Text
=
"历史数据查询"
;
this
.
调试窗口
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
调试窗口
ToolStripMenuItem
_Click
);
this
.
HistoryDataMenu
.
Name
=
"HistoryDataMenu
"
;
this
.
HistoryDataMenu
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
HistoryDataMenu
.
Text
=
"历史数据查询"
;
this
.
HistoryDataMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
HistoryDataMenu
_Click
);
//
//
校准查看ToolStripMenuItem
//
CalibrationMenu
//
this
.
校准查看
ToolStripMenuItem
.
Name
=
"校准查看ToolStripMenuItem
"
;
this
.
校准查看
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
148
,
22
);
this
.
校准查看
ToolStripMenuItem
.
Text
=
"校准查看"
;
this
.
校准查看
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
校准查看
ToolStripMenuItem
_Click
);
this
.
CalibrationMenu
.
Name
=
"CalibrationMenu
"
;
this
.
CalibrationMenu
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
CalibrationMenu
.
Text
=
"校准查看"
;
this
.
CalibrationMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
CalibrationMenu
_Click
);
//
//
历史谱图ToolStripMenuItem
//
HistoryPicMenu
//
this
.
历史谱图
ToolStripMenuItem
.
Name
=
"历史谱图ToolStripMenuItem
"
;
this
.
历史谱图
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
148
,
22
);
this
.
历史谱图
ToolStripMenuItem
.
Text
=
"历史谱图"
;
this
.
历史谱图
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
历史谱图
ToolStripMenuItem
_Click
);
this
.
HistoryPicMenu
.
Name
=
"HistoryPicMenu
"
;
this
.
HistoryPicMenu
.
Size
=
new
System
.
Drawing
.
Size
(
180
,
22
);
this
.
HistoryPicMenu
.
Text
=
"历史谱图"
;
this
.
HistoryPicMenu
.
Click
+=
new
System
.
EventHandler
(
this
.
HistoryPicMenu
_Click
);
//
// statusStrip
//
...
...
@@ -289,27 +289,27 @@
private
System
.
Windows
.
Forms
.
ToolStripStatusLabel
toolStripStatusLabeSystme
;
private
System
.
Windows
.
Forms
.
ToolTip
toolTip
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
用户管理
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
用户登录
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
用户注销
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
UserLoginMenu
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
UserLogoutMenu
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
运行
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
窗口
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
调试窗口
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
HistoryDataMenu
;
private
System
.
Windows
.
Forms
.
Timer
timer1
;
private
System
.
Windows
.
Forms
.
ToolStripStatusLabel
toolStripStatusLabelusertime
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
网络配置
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
方法批处理
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
打开方法文件
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
方法查阅
ToolStrip
MenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
NetWorkMenu
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
MethodBatMenu
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
OpenMethodMenu
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
MethodBrowse
MenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripStatusLabel
toolStripStatusLabelText
;
private
System
.
ComponentModel
.
BackgroundWorker
backgroundWorker1
;
private
System
.
ComponentModel
.
BackgroundWorker
backgroundWorker2
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
校准查看
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
历史谱图
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
新建方法
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
CalibrationMenu
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
HistoryPicMenu
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
NewMethodMenu
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
系统
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
系统开启
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
系统关闭
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
辅助工具
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
SystemStartMenu
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
SystemStopMenu
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
AuxToolMenu
;
}
}
...
...
GcDevicePc/MDIBase.cs
View file @
d269da47
...
...
@@ -13,14 +13,15 @@ using GcDevicePc.IniParam;
using
System.Threading
;
using
System.IO
;
using
GcDevicePc.CK_UI
;
using
GcDevicePc.Common
;
namespace
GcDevicePc
{
public
partial
class
MDIBase
:
Form
{
private
int
childFormNumber
=
0
;
private
static
FormUser
userForm
;
//用户界面
private
static
Formdebug
debugForm
;
//调试界面
private
static
FormUser
_
userForm
;
//用户界面
private
static
Formdebug
_
debugForm
;
//调试界面
// private static MainBase basefrom;
private
string
Formstr
;
//窗口名称
private
string
statestr
;
//状态信息
...
...
@@ -28,32 +29,47 @@ namespace GcDevicePc
private
bool
IsStateColor
=
false
;
System
.
DateTime
startTime
;
//系统启动时间
TimeSpan
timespan
;
bool
inifilec
=
false
;
//方法文件是否加载
/// <summary>
/// HMI控制接口
/// </summary>
HMIControl
hmiopt
;
/// <summary>
/// HMI数据获取接口
/// </summary>
GcDataTh
mymodbus
;
/// <summary>
/// Modbus Slave
接口
/// Modbus Slave
变量
/// </summary>
GCModbusSlave
Slavetest
;
/// <summary>
/// Modbus Slave 485 变量
/// </summary>
GCModbusSlave485
Slave485test
;
/// <summary>
/// 数据接收
/// </summary>
DataRcv
mytcptest
=
new
DataRcv
();
/// <summary>
/// 处理数据接口
/// </summary>
CKvocUpdata
dataVOC
=
new
CKvocUpdata
();
/// <summary>
/// 构造函数
/// </summary>
public
MDIBase
()
{
InitializeComponent
();
//
this.WindowState = FormWindowState.Maximized;
this
.
WindowState
=
FormWindowState
.
Maximized
;
}
private
void
ShowNewForm
(
object
sender
,
EventArgs
e
)
...
...
@@ -141,19 +157,28 @@ namespace GcDevicePc
}
}
/// <summary>
/// 主窗口载入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
MDIBase_Load
(
object
sender
,
EventArgs
e
)
{
dllInit
();
DllInit
();
InitConfig
();
debugForm
=
new
Formdebug
();
debugForm
.
MdiParent
=
this
;
debugForm
.
Dock
=
DockStyle
.
Fill
;
debugForm
.
Show
();
_debugForm
=
new
Formdebug
();
_debugForm
.
MdiParent
=
this
;
_debugForm
.
Dock
=
DockStyle
.
Fill
;
_debugForm
.
Show
();
// debugForm.Hide();
userForm
=
new
FormUser
();
userForm
.
MdiParent
=
this
;
userForm
.
Dock
=
DockStyle
.
Fill
;
userForm
.
Show
();
_userForm
=
new
FormUser
();
_userForm
.
MdiParent
=
this
;
_userForm
.
Dock
=
DockStyle
.
Fill
;
_userForm
.
Show
();
// debugForm.Show();
Formstr
=
"用户窗口"
;
startTime
=
DateTime
.
Now
;
...
...
@@ -161,6 +186,7 @@ namespace GcDevicePc
timespan
=
System
.
DateTime
.
Now
-
startTime
;
toolStripStatusLabelusertime
.
Text
=
string
.
Format
(
"运行时间:{0}"
,
timespan
.
Days
.
ToString
()
+
"天"
+
timespan
.
Hours
.
ToString
()
+
"时"
+
timespan
.
Minutes
.
ToString
()
+
"分"
+
timespan
.
Seconds
.
ToString
()
+
"秒"
);
//显示方法名称
if
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_MethodName
==
null
)
{
...
...
@@ -175,7 +201,7 @@ namespace GcDevicePc
autopensys
();
//点火接口
userForm
.
autofire
+=
new
Fireport
(
fireupopt
);
_
userForm
.
autofire
+=
new
Fireport
(
fireupopt
);
}
...
...
@@ -213,172 +239,80 @@ namespace GcDevicePc
/// <summary>
/// 组件初始化
/// </summary>
private
void
d
llInit
()
private
void
D
llInit
()
{
try
{
MainBase_InitAppConfig
();
//初始化路径
if
(
CKVocAnalyzer
.
Config
.
Instance
.
ReadPath
())
{
//初始化
CKVocAnalyzer
.
VOCEntityConfig
.
Instance
.
vocinit
();
CKVocAnalyzer
.
VOCEntityConfig
.
Instance
.
vocinit
();
CKVocAnalyzer
.
Config
.
Instance
.
ReadAxisRange
();
LogOperate
.
LogInit
.
Instance
.
path
=
CKVocAnalyzer
.
GlobalCKV
.
FolderLog
;
LogOperate
.
LogInit
.
Instance
.
Init
();
CKVocAnalyzer
.
GlobalCKV
.
tcpservice
.
tcpStart
(
CKVocAnalyzer
.
GlobalCKV
.
hostadd
,
CKVocAnalyzer
.
GlobalCKV
.
tcpport
);
Trace
.
WriteLine
(
"系统初始化成功"
,
"sy
s"
);
Log
.
Info
(
"System Init Succes
s"
);
}
else
{
//MessageBox.Show("系统初始化失败,请检查配置文件是否存在
");
Log
.
Error
(
"System Init Failed, Plesae Check Config File
"
);
}
}
catch
(
Exception
ex
)
{
Trace
.
WriteLine
(
ex
);
MessageBox
.
Show
(
ex
.
Message
);
Log
.
Error
(
ex
.
Message
);
}
}
private
void
调试窗口
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
//历史数据查询
{
try
{
WaveTotalForm
total
=
new
WaveTotalForm
();
total
.
Show
();
}
catch
(
Exception
ex
)
{
Trace
.
Write
(
ex
);
}
}
private
void
SetMenu
(
bool
isbool
)
{
try
{
if
(
isbool
)
{
网络配置
ToolStripMenuItem
.
Enabled
=
true
;
方法查阅
ToolStripMenuItem
.
Enabled
=
true
;
新建方法
ToolStripMenuItem
.
Enabled
=
true
;
打开方法文件
ToolStripMenuItem
.
Enabled
=
true
;
方法查阅
ToolStripMenuItem
.
Enabled
=
true
;
校准查看
ToolStripMenuItem
.
Enabled
=
true
;
//方法批处理ToolStripMenuItem.Enabled = true;
NetWorkMenu
.
Enabled
=
true
;
MethodBrowseMenuItem
.
Enabled
=
true
;
NewMethodMenu
.
Enabled
=
true
;
OpenMethodMenu
.
Enabled
=
true
;
MethodBrowseMenuItem
.
Enabled
=
true
;
CalibrationMenu
.
Enabled
=
true
;
}
else
{
网络配置
ToolStripMenuItem
.
Enabled
=
false
;
方法查阅
ToolStripMenuItem
.
Enabled
=
false
;
新建方法
ToolStripMenuItem
.
Enabled
=
false
;
打开方法文件
ToolStripMenuItem
.
Enabled
=
false
;
方法查阅
ToolStripMenuItem
.
Enabled
=
false
;
校准查看
ToolStripMenuItem
.
Enabled
=
false
;
//方法批处理ToolStripMenuItem.Enabled = false;
NetWorkMenu
.
Enabled
=
false
;
MethodBrowseMenuItem
.
Enabled
=
false
;
NewMethodMenu
.
Enabled
=
false
;
OpenMethodMenu
.
Enabled
=
false
;
MethodBrowseMenuItem
.
Enabled
=
false
;
CalibrationMenu
.
Enabled
=
false
;
}
}
catch
(
Exception
ex
)
{
Trace
.
Write
(
ex
);
}
}
private
void
用户登录
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
DialogResult
dr
=
new
LandIn
().
ShowDialog
();
if
(
dr
==
DialogResult
.
OK
)
//停止系统并退出
{
if
(
LandIn
.
Island
)
{
if
(
debugForm
!=
null
)
{
Formstr
=
"调试窗口"
;
debugForm
.
Activate
();
}
SetMenu
(
LandIn
.
Island
);
}
}
if
(
dr
==
DialogResult
.
No
)
{
}
}
private
void
用户注销
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
if
(
debugForm
!=
null
)
{
// debugForm.Hide();
}
if
(
userForm
!=
null
)
{
Formstr
=
"用户窗口"
;
userForm
.
Activate
();
//userForm.Show();
Log
.
Error
(
ex
.
Message
);
}
LandIn
.
Island
=
false
;
SetMenu
(
LandIn
.
Island
);
}
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
//显示状态栏信息
{
this
.
Text
=
string
.
Format
(
"VOCs在线监测-1.0.0.0 {0}"
,
Formstr
);
toolStripStatusLabeSystme
.
Text
=
string
.
Format
(
"状态:{0}"
,
statestr
);
//if (IsStateColor)
// toolStripStatusLabeSystme.BackColor = Color.LightBlue;// System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(149)))), ((int)(((byte)(237)))));
//else
// toolStripStatusLabeSystme.BackColor = Color.Coral;//System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
timespan
=
System
.
DateTime
.
Now
-
startTime
;
toolStripStatusLabelusertime
.
Text
=
string
.
Format
(
"运行时间:{0}"
,
timespan
.
Days
.
ToString
()
+
"天"
+
timespan
.
Hours
.
ToString
()
+
"时"
+
timespan
.
Minutes
.
ToString
()
+
"分"
+
timespan
.
Seconds
.
ToString
()
+
"秒"
);
//if(globaldata.MethodRun_Statue==4||globaldata.MethodRun_Statue==5)
//{
// toolStripProgressBar1.Maximum = globaldata.m_dpbuffer.ShowList.showtime.alltime;
// if (globaldata.m_dpbuffer.ShowList.showtime.runtimenow < globaldata.m_dpbuffer.ShowList.showtime.alltime)
// {
// toolStripProgressBar1.Value = globaldata.m_dpbuffer.ShowList.showtime.runtimenow;
// }else
// {
// toolStripProgressBar1.Value = globaldata.m_dpbuffer.ShowList.showtime.alltime;
// }
//}
//else
//{
// toolStripProgressBar1.Value=0;
//}
}
/// <summary>
///
网络配置
///
更新显示栏信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
网络配置
ToolStripMenuItem_Cl
ick
(
object
sender
,
EventArgs
e
)
private
void
timer1_T
ick
(
object
sender
,
EventArgs
e
)
{
UserConfig
confu
=
new
UserConfig
();
confu
.
Show
();
this
.
Text
=
string
.
Format
(
"VOCs在线监测-1.0.0.0 {0}"
,
Formstr
);
toolStripStatusLabeSystme
.
Text
=
string
.
Format
(
"状态:{0}"
,
statestr
);
timespan
=
System
.
DateTime
.
Now
-
startTime
;
toolStripStatusLabelusertime
.
Text
=
string
.
Format
(
"运行时间:{0}"
,
timespan
.
Days
.
ToString
()
+
"天"
+
timespan
.
Hours
.
ToString
()
+
"时"
+
timespan
.
Minutes
.
ToString
()
+
"分"
+
timespan
.
Seconds
.
ToString
()
+
"秒"
);
}
public
void
SendPCCMD
(
bool
flag
)
{
if
(
flag
)
//打开运行
{
hmiopt
.
WriteStopVal
();
//singlemodbus.WriteStopVal();
WaitHMIFree
();
if
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
system_Statue
)
...
...
@@ -387,17 +321,14 @@ namespace GcDevicePc
{
hmiopt
.
WriteStopVal
();
}
if
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
RunType
==
1
)
hmiopt
.
WriteSingleVal
();
WaitHMIWork
();
}
}
else
//批处理
{
hmiopt
.
WriteStopVal
();
// singlemodbus.WriteStopVal();
WaitHMIFree
();
if
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
system_Statue
)
...
...
@@ -414,122 +345,10 @@ namespace GcDevicePc
}
}
}
public
void
SetMainFormMethodName
(
string
text
)
{
// this.now_method.Text = "当前运行方法:" + text;
this
.
toolStripStatusLabelText
.
Text
=
"当前运行方法:"
+
text
;
}
private
void
打开方法文件
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
OpenFileDialog
fileDlg
=
new
OpenFileDialog
();
fileDlg
.
Multiselect
=
false
;
fileDlg
.
InitialDirectory
=
Application
.
StartupPath
+
"\\仪器方法"
;
fileDlg
.
Title
=
"请选择方法文件"
;
fileDlg
.
Filter
=
"配置文件(*.ini)|*.ini"
;
if
(
fileDlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
string
file
=
fileDlg
.
FileName
;
// globaldata.cur_MethodName = file;
// globaldata.cur_OpenMethodName = file;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_OpenMethodName
=
file
;
this
.
inifilec
=
true
;
globaldata
.
m_profileMethod
.
SetMethodFullName
(
file
);
globaldata
.
m_profileMethod
.
GetDevState
();
if
(
globaldata
.
m_configDlg
.
IsDisposed
)
globaldata
.
m_configDlg
=
new
MethodConfig
();
globaldata
.
m_configDlg
.
m_InjPortDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_InjSampleDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_InjValveDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_chromeDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_RealColDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_det
.
reflashContent
();
globaldata
.
m_configDlg
.
m_AuxDlg
.
reflashContent
();
// globaldata.m_configDlg.m_SignalDlg.reflashContent();
globaldata
.
m_configDlg
.
changenameforup
-=
new
ConfigDlg
.
ChangeMNameForUp
(
SetMainFormMethodName
);
globaldata
.
m_configDlg
.
changenameforup
+=
new
ConfigDlg
.
ChangeMNameForUp
(
SetMainFormMethodName
);
globaldata
.
m_configDlg
.
sendupdatecmd
-=
new
ConfigDlg
.
SendUpdateCMD
(
SendPCCMD
);
globaldata
.
m_configDlg
.
sendupdatecmd
+=
new
ConfigDlg
.
SendUpdateCMD
(
SendPCCMD
);
globaldata
.
m_configDlg
.
Show
();
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
RunType
=
0
;
//globaldata.RunType = 0;
// globaldata.m_configDlg.m_RunTableDlg.reflashContent();
}
}
private
void
方法查阅
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
private
void
SetMainFormMethodName
(
string
text
)
{
if
(
globaldata
.
m_configDlg
.
Visible
==
true
)
return
;
if
(
inifilec
)
{
globaldata
.
m_profileMethod
.
SetMethodFullName
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_MethodName
);
globaldata
.
m_profileMethod
.
GetDevState
();
if
(
globaldata
.
m_configDlg
.
IsDisposed
)
globaldata
.
m_configDlg
=
new
MethodConfig
();
globaldata
.
m_configDlg
.
m_InjPortDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_InjSampleDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_InjValveDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_chromeDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_RealColDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_det
.
reflashContent
();
globaldata
.
m_configDlg
.
m_AuxDlg
.
reflashContent
();
// globaldata.m_configDlg.m_SignalDlg.reflashContent();
globaldata
.
m_configDlg
.
changenameforup
-=
new
ConfigDlg
.
ChangeMNameForUp
(
SetMainFormMethodName
);
globaldata
.
m_configDlg
.
changenameforup
+=
new
ConfigDlg
.
ChangeMNameForUp
(
SetMainFormMethodName
);
globaldata
.
m_configDlg
.
sendupdatecmd
-=
new
ConfigDlg
.
SendUpdateCMD
(
SendPCCMD
);
globaldata
.
m_configDlg
.
sendupdatecmd
+=
new
ConfigDlg
.
SendUpdateCMD
(
SendPCCMD
);
globaldata
.
m_configDlg
.
Show
();
}
else
{
OpenFileDialog
fileDlg
=
new
OpenFileDialog
();
fileDlg
.
Multiselect
=
false
;
fileDlg
.
InitialDirectory
=
Application
.
StartupPath
+
"\\仪器方法"
;
fileDlg
.
Title
=
"请选择方法文件"
;
fileDlg
.
Filter
=
"配置文件(*.ini)|*.ini"
;
if
(
fileDlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
string
file
=
fileDlg
.
FileName
;
// globaldata.cur_MethodName = file;
//globaldata.cur_OpenMethodName = file;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_OpenMethodName
=
file
;
globaldata
.
m_profileMethod
.
SetMethodFullName
(
file
);
globaldata
.
m_profileMethod
.
GetDevState
();
if
(
globaldata
.
m_configDlg
.
IsDisposed
)
globaldata
.
m_configDlg
=
new
MethodConfig
();
globaldata
.
m_configDlg
.
m_InjPortDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_InjSampleDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_InjValveDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_chromeDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_RealColDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_det
.
reflashContent
();
globaldata
.
m_configDlg
.
m_AuxDlg
.
reflashContent
();
// globaldata.m_configDlg.m_SignalDlg.reflashContent();
globaldata
.
m_configDlg
.
changenameforup
-=
new
ConfigDlg
.
ChangeMNameForUp
(
SetMainFormMethodName
);
globaldata
.
m_configDlg
.
changenameforup
+=
new
ConfigDlg
.
ChangeMNameForUp
(
SetMainFormMethodName
);
globaldata
.
m_configDlg
.
sendupdatecmd
-=
new
ConfigDlg
.
SendUpdateCMD
(
SendPCCMD
);
globaldata
.
m_configDlg
.
sendupdatecmd
+=
new
ConfigDlg
.
SendUpdateCMD
(
SendPCCMD
);
globaldata
.
m_configDlg
.
Show
();
// globaldata.m_configDlg.m_RunTableDlg.reflashContent();
}
}
this
.
toolStripStatusLabelText
.
Text
=
"当前运行方法:"
+
text
;
}
private
void
backgroundWorker1_DoWork
(
object
sender
,
DoWorkEventArgs
e
)
...
...
@@ -554,12 +373,10 @@ namespace GcDevicePc
if
(
globaldata
.
OS_STOP
)
{
hmiopt
.
WriteEndVal
();
// LogHelper.I("backgroundWorker1_DoWork", "WriteEndVal");
}
else
{
hmiopt
.
WriteStopVal
();
// LogHelper.I("backgroundWorker1_DoWork", "WriteStopVal");
}
}
...
...
@@ -590,6 +407,7 @@ namespace GcDevicePc
{
}
}
public
void
WaitHMIFree
()
{
this
.
backgroundWorker1
.
RunWorkerAsync
();
...
...
@@ -659,84 +477,7 @@ namespace GcDevicePc
form
.
ShowDialog
(
this
);
form
.
Close
();
}
/// <summary>
/// 检测本地默认目录
/// </summary>
private
void
MainBase_InitAppConfig
()
{
try
{
string
tmpFolder
;
//检查创建仪器方法目录
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunFolder
=
System
.
Windows
.
Forms
.
Application
.
StartupPath
;
tmpFolder
=
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunFolder
;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
MethodFolder
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"仪器方法"
);
tmpFolder
=
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
MethodFolder
;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_MethodName
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"SingleAnal.ini(单次运行默认方法)"
);
tmpFolder
=
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
MethodFolder
;
if
(
System
.
IO
.
Directory
.
Exists
(
tmpFolder
)
==
false
)
{
System
.
IO
.
Directory
.
CreateDirectory
(
tmpFolder
);
}
//检查创建仪器状态目录
tmpFolder
=
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunFolder
;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
StatusFolder
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"仪器状态"
);
tmpFolder
=
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
StatusFolder
;
if
(
System
.
IO
.
Directory
.
Exists
(
tmpFolder
)
==
false
)
{
System
.
IO
.
Directory
.
CreateDirectory
(
tmpFolder
);
}
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_StatusName
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"DevStatus.ini"
);
if
((
globaldata
.
connection_ip
==
null
||
globaldata
.
connection_ip
==
""
)
&&
System
.
IO
.
File
.
Exists
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_StatusName
)
==
false
)
{
System
.
IO
.
File
.
Create
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_StatusName
).
Dispose
();
}
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
subStatusFolder
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"子状态"
);
if
(
System
.
IO
.
Directory
.
Exists
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
subStatusFolder
)
==
false
)
{
System
.
IO
.
Directory
.
CreateDirectory
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
subStatusFolder
);
}
globaldata
.
m_profileMethod
.
SetStatusFullName
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_StatusName
);
//获取硬件配置
//globaldata.m_hwconfig = new GCBuffer.HWConfig(globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_StatusName);
// globaldata.m_hwconfig.GetHWConfig();
//检查创建运行表目录
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunTabFolder
=
System
.
IO
.
Path
.
Combine
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunFolder
,
"运行表"
);
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_RunTab
=
System
.
IO
.
Path
.
Combine
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunTabFolder
,
"RunMethod.ini"
);
if
(
System
.
IO
.
Directory
.
Exists
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunTabFolder
)
==
false
)
{
System
.
IO
.
Directory
.
CreateDirectory
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunTabFolder
);
}
if
(
System
.
IO
.
File
.
Exists
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_RunTab
)
==
false
)
{
StreamWriter
sw
=
new
StreamWriter
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_RunTab
,
false
,
System
.
Text
.
Encoding
.
Unicode
);
sw
.
WriteLine
(
"[运行表]"
);
sw
.
Close
();
}
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
DataFolder
=
System
.
IO
.
Path
.
Combine
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunFolder
,
"历史数据"
);
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_DataName
=
null
;
if
(
System
.
IO
.
Directory
.
Exists
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
DataFolder
)
==
false
)
{
System
.
IO
.
Directory
.
CreateDirectory
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
DataFolder
);
}
tmpFolder
=
null
;
}
catch
(
Exception
ex
)
{
Trace
.
Write
(
ex
);
}
}
public
void
SendStopCMD
()
{
try
...
...
@@ -749,73 +490,20 @@ namespace GcDevicePc
}
}
private
void
方法批处理
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
try
{
RunTables
f_runtable
=
new
RunTables
();
f_runtable
.
sendupdatecmd
-=
new
SendUpdateCMD
(
SendPCCMD
);
f_runtable
.
sendupdatecmd
+=
new
SendUpdateCMD
(
SendPCCMD
);
f_runtable
.
sendstopcmd
-=
new
SendStopCMD
(
SendStopCMD
);
f_runtable
.
sendstopcmd
+=
new
SendStopCMD
(
SendStopCMD
);
f_runtable
.
Show
();
}
catch
(
Exception
ex
)
{
Trace
.
Write
(
ex
);
}
}
private
void
校准查看
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
private
void
InitConfig
(
)
{
try
{
AdjustFrom
just
=
new
AdjustFrom
();
just
.
Show
();
string
singlefilename
=
System
.
IO
.
Path
.
Combine
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
MethodFolder
,
"SingleAnal.ini"
);
string
tmpname
;
string
runtabfilename
=
""
;
}
catch
(
Exception
ex
)
{
Trace
.
Write
(
ex
);
}
}
int
ret
;
private
void
历史谱图
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
try
{
HistChartForm
hist
=
new
HistChartForm
();
hist
.
Show
();
}
catch
(
Exception
ex
)
{
Trace
.
Write
(
ex
);
}
}
private
void
新建方法
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
MethodNameInputForm
m_methodNameInputForm
=
new
MethodNameInputForm
();
m_methodNameInputForm
.
Show
();
}
private
void
InitConfig
()
{
try
{
string
singlefilename
=
System
.
IO
.
Path
.
Combine
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
MethodFolder
,
"SingleAnal.ini"
);
string
tmpname
;
string
runtabfilename
=
""
;
int
ret
;
if
(
globaldata
.
connection_ip
!=
null
&&
globaldata
.
connection_ip
!=
""
)
{
Start_ConnectStatusThread
();
if
(!
String
.
IsNullOrEmpty
(
globaldata
.
connection_ip
))
{
Start_ConnectStatusThread
();
//获取配置文件
try
...
...
@@ -978,6 +666,9 @@ namespace GcDevicePc
Slavetest
=
new
GCModbusSlave
();
Slavetest
.
CModbusSlaveInit
(
1
,
2
,
3
,
5
);
Slave485test
=
new
GCModbusSlave485
(
1
,
9600
);
Slave485test
.
CModbusSlave485Init
(
1
,
2
,
3
,
5
);
}
catch
{
...
...
@@ -1025,6 +716,8 @@ namespace GcDevicePc
ManualResetEvent
conmre
=
new
ManualResetEvent
(
false
);
ushort
GCstatus
=
9
;
Thread
Connect_Status
;
/// <summary>
/// HMI状态监控线程
/// </summary>
...
...
@@ -1432,8 +1125,8 @@ namespace GcDevicePc
globaldata
.
stopflag
=
true
;
globaldata
.
cancelflag
=
false
;
// globaldata.starttimer = 0x7FFFFFFF;
Console
.
WriteLine
(
"stopbtn startimer"
);
if
(
globaldata
.
connection_ip
!=
null
&&
globaldata
.
connection_ip
!=
""
)
if
(
!
String
.
IsNullOrEmpty
(
globaldata
.
connection_ip
)
)
{
// globaldata.work_Statue = 2;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
work_Statue
=
2
;
...
...
@@ -1485,7 +1178,7 @@ namespace GcDevicePc
if
(
dr
==
DialogResult
.
OK
)
//停止系统并退出
{
count
=
0
;
if
(
globaldata
.
connection_ip
!=
null
&&
globaldata
.
connection_ip
!=
""
)
if
(
!
String
.
IsNullOrEmpty
(
globaldata
.
connection_ip
)
)
{
globaldata
.
OS_STOP
=
true
;
hmiopt
.
WriteEndVal
();
...
...
@@ -1511,13 +1204,25 @@ namespace GcDevicePc
}
}
System
.
Environment
.
Exit
(
0
);
count
=
0
;
ret
=
Slave485test
.
CModbusSlave485Close
();
while
(
ret
!=
0
)
{
count
++;
ret
=
Slave485test
.
CModbusSlave485Close
();
Thread
.
Sleep
(
100
);
if
(
count
>
3
)
{
break
;
}
}
Environment
.
Exit
(
0
);
}
if
(
dr
==
DialogResult
.
Yes
)
//仅退出
{
count
=
0
;
if
(
globaldata
.
connection_ip
!=
null
&&
globaldata
.
connection_ip
!=
""
)
if
(
!
String
.
IsNullOrEmpty
(
globaldata
.
connection_ip
)
)
{
if
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
RunType
==
2
)
{
...
...
@@ -1550,15 +1255,25 @@ namespace GcDevicePc
break
;
}
}
System
.
Environment
.
Exit
(
0
);
count
=
0
;
ret
=
Slave485test
.
CModbusSlave485Close
();
while
(
ret
!=
0
)
{
count
++;
ret
=
Slave485test
.
CModbusSlave485Close
();
Thread
.
Sleep
(
100
);
if
(
count
>
3
)
{
break
;
}
}
Environment
.
Exit
(
0
);
}
}
private
void
系统开启
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
open
();
}
// private bool isopen = false;
private
void
open
()
{
...
...
@@ -1569,11 +1284,10 @@ namespace GcDevicePc
MessageBox
.
Show
(
"系统开启中......"
);
return
;
}
if
(
globaldata
.
connection_ip
!=
null
&&
globaldata
.
connection_ip
!=
""
)
if
(
!
String
.
IsNullOrEmpty
(
globaldata
.
connection_ip
)
)
{
hmiopt
.
WriteStopVal
();
statestr
=
"系统准备中..."
;
WaitHMIFree
();
...
...
@@ -1620,29 +1334,6 @@ namespace GcDevicePc
}
}
private
void
系统关闭
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
if
(
globaldata
.
connection_ip
!=
null
&&
globaldata
.
connection_ip
!=
""
)
{
statestr
=
"系统停止中..."
;
globaldata
.
OS_STOP
=
true
;
hmiopt
.
WriteEndVal
();
WaitHMIFree
();
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
system_Statue
=
false
;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
work_Statue
=
0
;
}
else
{
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
system_Statue
=
false
;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
work_Statue
=
0
;
}
}
public
void
fireupopt
(
int
flag
,
ushort
time1
,
ushort
time2
)
{
hmiopt
.
FireUPWork
(
flag
,
time1
,
time2
);
...
...
@@ -1653,35 +1344,20 @@ namespace GcDevicePc
/// </summary>
public
void
stopforupdatefirm
()
{
if
(
globaldata
.
connection_ip
!=
null
&&
globaldata
.
connection_ip
!=
""
)
if
(
!
String
.
IsNullOrEmpty
(
globaldata
.
connection_ip
)
)
{
//、、 OSflag = !OSflag;
//globaldata.m_pcbuffer.gcpcinfo.pcworkinfo.work_Statue = 0;
//SetTitleStatueName("系统停止中...", false);
statestr
=
"系统停止中..."
;
globaldata
.
OS_STOP
=
true
;
hmiopt
.
WriteEndVal
();
WaitHMIFree
();
// SetTitleStatueName("系统停止...", false);
statestr
=
"系统停止中..."
;
//int tagnum = Convert.ToInt32(((PictureBox)panelMenu.Controls[14]).Tag);
//((PictureBox)panelMenu.Controls[14]).Image = menuList.Images[tagnum];
//((PictureBox)panelMenu.Controls[0]).Enabled = false;
//((PictureBox)panelMenu.Controls[0]).Image = menuList.Images[14];
//((PictureBox)panelMenu.Controls[1]).Enabled = false;
//((PictureBox)panelMenu.Controls[1]).Image = menuList.Images[15];
//((PictureBox)panelMenu.Controls[2]).Enabled = false;
//((PictureBox)panelMenu.Controls[2]).Image = menuList.Images[16];
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
system_Statue
=
false
;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
work_Statue
=
0
;
}
else
{
//string message = "系统处于离线状态...";
//MessageBox.Show(message, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
system_Statue
=
false
;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
work_Statue
=
0
;
}
...
...
@@ -1698,61 +1374,292 @@ namespace GcDevicePc
{
hmiopt
.
HAirSwitch
(
val
);
}
private
void
辅助工具
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
private
void
UserLoginMenu_Click
(
object
sender
,
EventArgs
e
)
{
DialogResult
dr
=
new
LandIn
().
ShowDialog
();
if
(
dr
==
DialogResult
.
OK
)
{
if
(
LandIn
.
Island
)
{
if
(
_debugForm
!=
null
)
{
Formstr
=
"调试窗口"
;
_debugForm
.
Activate
();
}
SetMenu
(
LandIn
.
Island
);
}
}
if
(
dr
==
DialogResult
.
No
)
{
}
}
private
void
UserLogoutMenu_Click
(
object
sender
,
EventArgs
e
)
{
if
(
_debugForm
!=
null
)
{
// debugForm.Hide();
}
if
(
_userForm
!=
null
)
{
Formstr
=
"用户窗口"
;
_userForm
.
Activate
();
//userForm.Show();
}
LandIn
.
Island
=
false
;
SetMenu
(
LandIn
.
Island
);
}
private
void
SystemStartMenu_Click
(
object
sender
,
EventArgs
e
)
{
open
();
}
private
void
SystemStopMenu_Click
(
object
sender
,
EventArgs
e
)
{
if
(!
String
.
IsNullOrEmpty
(
globaldata
.
connection_ip
))
{
statestr
=
"系统停止中..."
;
globaldata
.
OS_STOP
=
true
;
hmiopt
.
WriteEndVal
();
WaitHMIFree
();
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
system_Statue
=
false
;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
work_Statue
=
0
;
}
else
{
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
system_Statue
=
false
;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
work_Statue
=
0
;
}
}
private
void
AuxToolMenu_Click
(
object
sender
,
EventArgs
e
)
{
auxtool
f_auxtool
=
new
auxtool
();
int
ret
=
0
;
ushort
[]
firetime
=
new
ushort
[
2
];
ret
=
mymodbus
.
GetFireUpTime
(
ref
firetime
);
if
(
f_auxtool
==
null
)
if
(
f_auxtool
.
IsDisposed
)
{
f_auxtool
=
new
auxtool
(
firetime
[
0
],
firetime
[
1
]);
f_auxtool
.
auxtoolforfireup
+=
new
AUXTool
(
fireupopt
);
f_auxtool
.
sfupdatefirm
+=
new
StopForUpdateFirm
(
stopforupdatefirm
);
f_auxtool
.
updatefirm
+=
new
UpdateFirmCMD
(
startupdatefirm
);
f_auxtool
.
hairsw
+=
new
HAir_SW
(
hair_sw
);
f_auxtool
.
Show
();
}
else
{
f_auxtool
.
setfireuptime
(
firetime
[
0
],
firetime
[
1
]);
f_auxtool
.
auxtoolforfireup
-=
new
AUXTool
(
fireupopt
);
f_auxtool
.
auxtoolforfireup
+=
new
AUXTool
(
fireupopt
);
f_auxtool
.
sfupdatefirm
-=
new
StopForUpdateFirm
(
stopforupdatefirm
);
f_auxtool
.
sfupdatefirm
+=
new
StopForUpdateFirm
(
stopforupdatefirm
);
f_auxtool
.
updatefirm
-=
new
UpdateFirmCMD
(
startupdatefirm
);
f_auxtool
.
updatefirm
+=
new
UpdateFirmCMD
(
startupdatefirm
);
f_auxtool
.
hairsw
-=
new
HAir_SW
(
hair_sw
);
f_auxtool
.
hairsw
+=
new
HAir_SW
(
hair_sw
);
f_auxtool
.
Show
();
}
}
private
void
NetWorkMenu_Click
(
object
sender
,
EventArgs
e
)
{
UserConfig
confu
=
new
UserConfig
();
confu
.
Show
();
}
private
void
MethodBatMenu_Click
(
object
sender
,
EventArgs
e
)
{
try
{
RunTables
f_runtable
=
new
RunTables
();
f_runtable
.
sendupdatecmd
-=
new
SendUpdateCMD
(
SendPCCMD
);
f_runtable
.
sendupdatecmd
+=
new
SendUpdateCMD
(
SendPCCMD
);
f_runtable
.
sendstopcmd
-=
new
SendStopCMD
(
SendStopCMD
);
f_runtable
.
sendstopcmd
+=
new
SendStopCMD
(
SendStopCMD
);
f_runtable
.
Show
();
f_auxtool
.
Show
();
}
else
catch
(
Exception
ex
)
{
if
(
f_auxtool
.
IsDisposed
)
{
f_auxtool
=
new
auxtool
(
firetime
[
0
],
firetime
[
1
]);
Log
.
Error
(
ex
.
Message
);
f_auxtool
.
auxtoolforfireup
+=
new
AUXTool
(
fireupopt
);
}
}
f_auxtool
.
sfupdatefirm
+=
new
StopForUpdateFirm
(
stopforupdatefirm
);
f_auxtool
.
updatefirm
+=
new
UpdateFirmCMD
(
startupdatefirm
);
f_auxtool
.
hairsw
+=
new
HAir_SW
(
hair_sw
);
private
void
NewMethodMenu_Click
(
object
sender
,
EventArgs
e
)
{
MethodNameInputForm
m_methodNameInputForm
=
new
MethodNameInputForm
();
m_methodNameInputForm
.
Show
();
}
f_auxtool
.
Show
();
}
else
private
void
OpenMethodMenu_Click
(
object
sender
,
EventArgs
e
)
{
OpenFileDialog
fileDlg
=
new
OpenFileDialog
();
fileDlg
.
Multiselect
=
false
;
fileDlg
.
InitialDirectory
=
Application
.
StartupPath
+
"\\仪器方法"
;
fileDlg
.
Title
=
"请选择方法文件"
;
fileDlg
.
Filter
=
"配置文件(*.ini)|*.ini"
;
if
(
fileDlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
string
file
=
fileDlg
.
FileName
;
// globaldata.cur_MethodName = file;
// globaldata.cur_OpenMethodName = file;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_OpenMethodName
=
file
;
this
.
inifilec
=
true
;
globaldata
.
m_profileMethod
.
SetMethodFullName
(
file
);
globaldata
.
m_profileMethod
.
GetDevState
();
if
(
globaldata
.
m_configDlg
.
IsDisposed
)
globaldata
.
m_configDlg
=
new
MethodConfig
();
globaldata
.
m_configDlg
.
m_InjPortDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_InjSampleDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_InjValveDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_chromeDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_RealColDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_det
.
reflashContent
();
globaldata
.
m_configDlg
.
m_AuxDlg
.
reflashContent
();
// globaldata.m_configDlg.m_SignalDlg.reflashContent();
globaldata
.
m_configDlg
.
changenameforup
-=
new
ConfigDlg
.
ChangeMNameForUp
(
SetMainFormMethodName
);
globaldata
.
m_configDlg
.
changenameforup
+=
new
ConfigDlg
.
ChangeMNameForUp
(
SetMainFormMethodName
);
globaldata
.
m_configDlg
.
sendupdatecmd
-=
new
ConfigDlg
.
SendUpdateCMD
(
SendPCCMD
);
globaldata
.
m_configDlg
.
sendupdatecmd
+=
new
ConfigDlg
.
SendUpdateCMD
(
SendPCCMD
);
globaldata
.
m_configDlg
.
Show
();
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcworkinfo
.
RunType
=
0
;
//globaldata.RunType = 0;
// globaldata.m_configDlg.m_RunTableDlg.reflashContent();
}
}
private
void
MethodBrowseMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
if
(
globaldata
.
m_configDlg
.
Visible
==
true
)
return
;
if
(
inifilec
)
{
globaldata
.
m_profileMethod
.
SetMethodFullName
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_MethodName
);
globaldata
.
m_profileMethod
.
GetDevState
();
if
(
globaldata
.
m_configDlg
.
IsDisposed
)
globaldata
.
m_configDlg
=
new
MethodConfig
();
globaldata
.
m_configDlg
.
m_InjPortDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_InjSampleDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_InjValveDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_chromeDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_RealColDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_det
.
reflashContent
();
globaldata
.
m_configDlg
.
m_AuxDlg
.
reflashContent
();
// globaldata.m_configDlg.m_SignalDlg.reflashContent();
globaldata
.
m_configDlg
.
changenameforup
-=
new
ConfigDlg
.
ChangeMNameForUp
(
SetMainFormMethodName
);
globaldata
.
m_configDlg
.
changenameforup
+=
new
ConfigDlg
.
ChangeMNameForUp
(
SetMainFormMethodName
);
globaldata
.
m_configDlg
.
sendupdatecmd
-=
new
ConfigDlg
.
SendUpdateCMD
(
SendPCCMD
);
globaldata
.
m_configDlg
.
sendupdatecmd
+=
new
ConfigDlg
.
SendUpdateCMD
(
SendPCCMD
);
globaldata
.
m_configDlg
.
Show
();
}
else
{
OpenFileDialog
fileDlg
=
new
OpenFileDialog
();
fileDlg
.
Multiselect
=
false
;
fileDlg
.
InitialDirectory
=
Application
.
StartupPath
+
"\\仪器方法"
;
fileDlg
.
Title
=
"请选择方法文件"
;
fileDlg
.
Filter
=
"配置文件(*.ini)|*.ini"
;
if
(
fileDlg
.
ShowDialog
()
==
DialogResult
.
OK
)
{
f_auxtool
.
setfireuptime
(
firetime
[
0
],
firetime
[
1
]);
string
file
=
fileDlg
.
FileName
;
// globaldata.cur_MethodName = file;
//globaldata.cur_OpenMethodName = file;
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_OpenMethodName
=
file
;
f_auxtool
.
auxtoolforfireup
-=
new
AUXTool
(
fireupopt
);
f_auxtool
.
auxtoolforfireup
+=
new
AUXTool
(
fireupopt
);
globaldata
.
m_profileMethod
.
SetMethodFullName
(
file
);
globaldata
.
m_profileMethod
.
GetDevState
();
if
(
globaldata
.
m_configDlg
.
IsDisposed
)
globaldata
.
m_configDlg
=
new
MethodConfig
();
f_auxtool
.
sfupdatefirm
-=
new
StopForUpdateFirm
(
stopforupdatefirm
);
f_auxtool
.
sfupdatefirm
+=
new
StopForUpdateFirm
(
stopforupdatefirm
);
f_auxtool
.
updatefirm
-=
new
UpdateFirmCMD
(
startupdatefirm
);
f_auxtool
.
updatefirm
+=
new
UpdateFirmCMD
(
startupdatefirm
);
globaldata
.
m_configDlg
.
m_InjPortDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_InjSampleDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_InjValveDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_chromeDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_RealColDlg
.
reflashContent
();
globaldata
.
m_configDlg
.
m_det
.
reflashContent
();
globaldata
.
m_configDlg
.
m_AuxDlg
.
reflashContent
();
// globaldata.m_configDlg.m_SignalDlg.reflashContent();
f_auxtool
.
hairsw
-=
new
HAir_SW
(
hair_sw
);
f_auxtool
.
hairsw
+=
new
HAir_SW
(
hair_sw
);
f_auxtool
.
Show
();
globaldata
.
m_configDlg
.
changenameforup
-=
new
ConfigDlg
.
ChangeMNameForUp
(
SetMainFormMethodName
);
globaldata
.
m_configDlg
.
changenameforup
+=
new
ConfigDlg
.
ChangeMNameForUp
(
SetMainFormMethodName
);
globaldata
.
m_configDlg
.
sendupdatecmd
-=
new
ConfigDlg
.
SendUpdateCMD
(
SendPCCMD
);
globaldata
.
m_configDlg
.
sendupdatecmd
+=
new
ConfigDlg
.
SendUpdateCMD
(
SendPCCMD
);
globaldata
.
m_configDlg
.
Show
();
// globaldata.m_configDlg.m_RunTableDlg.reflashContent();
}
}
}
private
void
HistoryDataMenu_Click
(
object
sender
,
EventArgs
e
)
{
try
{
WaveTotalForm
total
=
new
WaveTotalForm
();
total
.
Show
();
}
catch
(
Exception
ex
)
{
Log
.
Error
(
ex
.
Message
);
}
}
private
void
CalibrationMenu_Click
(
object
sender
,
EventArgs
e
)
{
try
{
AdjustFrom
just
=
new
AdjustFrom
();
just
.
Show
();
}
catch
(
Exception
ex
)
{
Log
.
Error
(
ex
.
Message
);
}
}
private
void
HistoryPicMenu_Click
(
object
sender
,
EventArgs
e
)
{
try
{
HistChartForm
hist
=
new
HistChartForm
();
hist
.
Show
();
}
catch
(
Exception
ex
)
{
Log
.
Error
(
ex
.
Message
);
}
}
}
}
GcDevicePc/MDIBase.resx
View file @
d269da47
...
...
@@ -136,6 +136,6 @@
<value>
601, 17
</value>
</metadata>
<metadata
name=
"$this.TrayHeight"
type=
"System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
>
<value>
175
</value>
<value>
86
</value>
</metadata>
</root>
\ No newline at end of file
GcDevicePc/MainBase.cs
View file @
d269da47
...
...
@@ -149,7 +149,7 @@ namespace GcDevicePc
//MainBase初始化
InitializeComponent
();
//运行环境初始化
MainBase_InitAppConfig
();
//
MainBase_InitAppConfig();
//标题初始化
ManinBase_InitFormTitle
();
//菜单初始化
...
...
@@ -735,11 +735,6 @@ namespace GcDevicePc
System
.
IO
.
File
.
Create
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_StatusName
).
Dispose
();
}
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
subStatusFolder
=
System
.
IO
.
Path
.
Combine
(
tmpFolder
,
"子状态"
);
if
(
System
.
IO
.
Directory
.
Exists
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
subStatusFolder
)
==
false
)
{
System
.
IO
.
Directory
.
CreateDirectory
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
subStatusFolder
);
}
globaldata
.
m_profileMethod
.
SetStatusFullName
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_StatusName
);
...
...
@@ -755,6 +750,7 @@ namespace GcDevicePc
{
System
.
IO
.
Directory
.
CreateDirectory
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
RunTabFolder
);
}
if
(
System
.
IO
.
File
.
Exists
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_RunTab
)
==
false
)
{
StreamWriter
sw
=
new
StreamWriter
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfileinfo
.
cur_RunTab
,
false
,
System
.
Text
.
Encoding
.
Unicode
);
...
...
GcDevicePc/ProThread/DataRcv.cs
View file @
d269da47
...
...
@@ -38,7 +38,7 @@ namespace GcDevicePc.ProThread
{
try
{
if
(
globaldata
.
connection_ip
!=
null
&&
globaldata
.
connection_ip
!=
""
)
if
(
!
String
.
IsNullOrEmpty
(
globaldata
.
connection_ip
)
)
socket
.
Connect
(
globaldata
.
connection_ip
,
8005
);
//配置服务器IP与端口
Console
.
WriteLine
(
"连接服务器成功"
);
break
;
...
...
GcDevicePc/ProThread/HMISearch.cs
View file @
d269da47
...
...
@@ -9,91 +9,109 @@ using System.Text.RegularExpressions;
using
System.Collections
;
using
System.Management
;
using
System.Net.NetworkInformation
;
using
GcDevicePc.Common
;
namespace
GcDevicePc.ProThread
{
class
HMISearch
{
p
ublic
UdpClient
client
;
p
ublic
IPEndPoint
endpoint
;
p
rivate
UdpClient
client
;
p
rivate
IPEndPoint
endpoint
;
Thread
searchth
;
ManualResetEvent
mre
=
new
ManualResetEvent
(
false
);
public
globaldata
.
DeviceInfo
m_DeviceInfo
;
public
ArrayList
myHMIList
=
new
ArrayList
();
string
FMAC
=
null
;
string
file
=
System
.
Windows
.
Forms
.
Application
.
StartupPath
+
"\\startup.ini"
;
string
localip
=
null
;
private
string
FMAC
=
null
;
private
string
_
localip
=
null
;
/// <summary>
/// 构造函数
/// </summary>
public
HMISearch
()
public
HMISearch
(
String
hmimac
)
{
// globaldata.hHMIList.Clear()
;
this
.
FMAC
=
hmimac
;
myHMIList
.
Clear
();
globaldata
.
DeviceList
.
Clear
();
GetHmiIp
();
}
INIOperation
test
=
new
INIOperation
(
file
);
this
.
FMAC
=
test
.
INIGetStringValue
(
"NetWorkConfig"
,
"MAC地址"
,
null
);
public
void
ReGetHmiIp
()
{
GetHmiIp
();
}
NetworkInterface
[]
nics
=
NetworkInterface
.
GetAllNetworkInterfaces
();
foreach
(
NetworkInterface
adapter
in
nics
)
private
void
GetHmiIp
()
{
Log
.
Info
(
"Start Get PC Local IP..."
);
try
{
if
(
adapter
.
Name
==
"本地连接"
)
NetworkInterface
[]
nics
=
NetworkInterface
.
GetAllNetworkInterfaces
();
foreach
(
NetworkInterface
adapter
in
nics
)
{
bool
Pd1
=
(
adapter
.
NetworkInterfaceType
==
NetworkInterfaceType
.
Ethernet
);
//判断是否是以太网连接
if
(
Pd1
)
if
(
adapter
.
Name
==
"本地连接"
)
{
bool
pd1
=
(
adapter
.
NetworkInterfaceType
==
NetworkInterfaceType
.
Ethernet
);
//判断是否是以太网连接
if
(
pd1
)
{
IPInterfaceProperties
ip
=
adapter
.
GetIPProperties
();
//IP配置信息
UnicastIPAddressInformationCollection
ipCollection
=
ip
.
UnicastAddresses
;
foreach
(
UnicastIPAddressInformation
ipadd
in
ipCollection
)
{
if
(
ipadd
.
Address
.
AddressFamily
==
AddressFamily
.
InterNetwork
)
this
.
localip
=
ipadd
.
Address
.
ToString
();
//获取ip
this
.
_
localip
=
ipadd
.
Address
.
ToString
();
//获取ip
}
}
}
}
}
}
catch
(
Exception
e
)
{
Log
.
Error
(
e
.
Message
);
}
}
public
void
ThStart
()
public
Boolean
ThStart
()
{
if
(
mre
!=
null
)
mre
.
Reset
();
Console
.
WriteLine
(
"搜索线程开始...."
);
searchth
=
new
Thread
(
ThreadMethod
);
searchth
.
IsBackground
=
true
;
searchth
.
Start
();
if
(
String
.
IsNullOrEmpty
(
this
.
_localip
))
{
return
false
;
}
else
{
if
(
mre
!=
null
)
mre
.
Reset
();
Log
.
Info
(
"Start Search HMI..."
);
searchth
=
new
Thread
(
ThreadMethod
);
searchth
.
IsBackground
=
true
;
searchth
.
Start
();
return
true
;
}
}
public
void
ThStop
()
{
Console
.
WriteLine
(
"搜索线程结束.
..."
);
Log
.
Info
(
"Stop Search HMI
..."
);
mre
.
Set
();
// FMAC = null;
}
public
int
HMICount
()
{
//return globaldata.hHMIList.Count;
return
myHMIList
.
Count
;
}
private
void
ThreadMethod
()
{
//byte[] sendBytes = new byte[] { 0x57, 0x54, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x55, 0xAA };
byte
[]
sendBytes
=
new
byte
[]
{
0x57
,
0x54
,
0x04
,
0x00
,
0x00
,
0x00
,
0x03
,
0x02
,
0x00
,
0x00
,
0x55
,
0xAA
};
//脱机
byte
[]
sendBytes
=
new
byte
[]
{
0x57
,
0x54
,
0x04
,
0x00
,
0x00
,
0x00
,
0x03
,
0x02
,
0x00
,
0x00
,
0x55
,
0xAA
};
int
iReadBytes
=
0
;
try
{
//
client = new UdpClient(new IPEndPoint(IPAddress.Any, 0));
client
=
new
UdpClient
(
new
IPEndPoint
(
IPAddress
.
Parse
(
this
.
localip
),
0
));
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
);
client
.
Send
(
sendBytes
,
sendBytes
.
Length
,
endpoint
);
Thread
.
Sleep
(
500
);
...
...
@@ -112,14 +130,13 @@ namespace GcDevicePc.ProThread
DoRecvDataCallBack
(
recvBytes
,
iReadBytes
);
}
}
}
catch
}
catch
(
Exception
e
)
{
}
Console
.
WriteLine
(
e
.
Message
);
}
}
p
ublic
Boolean
DoRecvDataCallBack
(
byte
[]
pcData
,
int
iRecvLength
)
p
rivate
Boolean
DoRecvDataCallBack
(
byte
[]
pcData
,
int
iRecvLength
)
{
int
i
;
int
count
=
0
;
...
...
@@ -138,7 +155,7 @@ namespace GcDevicePc.ProThread
if
((
iDataLength
>=
4
)
&&
(
iRecvLength
==
8
+
iDataLength
))
{
System
.
Text
.
ASCIIEncoding
asciiEncoding
=
new
System
.
Text
.
ASCIIEncoding
();
ASCIIEncoding
asciiEncoding
=
new
ASCIIEncoding
();
m_DeviceInfo
.
bActive
=
false
;
for
(
i
=
0
;
i
<
100
;
i
++
)
...
...
GcDevicePc/Program.cs
View file @
d269da47
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading
;
using
System.Windows.Forms
;
using
System.Net.NetworkInformation
;
using
System.Net.Sockets
;
using
GcDevicePc.Common
;
using
GcDevicePc.ProThread
;
namespace
GcDevicePc
{
static
class
Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
///
//static public string GetGW()
//{
// string strGateway = "192.168.10.1";
// try
// {
// NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
// //遍历数组
// foreach (NetworkInterface adapter in nics)
// {
// if (adapter.Name == "本地连接")
// {
// bool Pd1 = (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet); //判断是否是以太网连接
// if (Pd1)
// {
// IPInterfaceProperties ip = adapter.GetIPProperties();
// GatewayIPAddressInformationCollection gateways = ip.GatewayAddresses;
// foreach (var gateWay in gateways)
// {
// strGateway = gateWay.Address.ToString();
// if (strGateway.Length > 0)
// {
// break;
// }
// }
// }
// }
// }
// return strGateway;
// }
// finally
// {
// }
// return strGateway;
//}
static
public
void
isnetworkok
()
private
static
void
Isnetworkok
()
{
string
localip
=
""
;
String
localip
=
""
;
while
(
true
)
{
try
...
...
@@ -67,8 +23,8 @@ namespace GcDevicePc
{
if
(
adapter
.
Name
==
"本地连接"
)
{
bool
Pd1
=
(
adapter
.
NetworkInterfaceType
==
NetworkInterfaceType
.
Ethernet
);
//判断是否是以太网连接
if
(
P
d1
)
bool
pd1
=
(
adapter
.
NetworkInterfaceType
==
NetworkInterfaceType
.
Ethernet
);
if
(
p
d1
)
{
IPInterfaceProperties
ip
=
adapter
.
GetIPProperties
();
UnicastIPAddressInformationCollection
ipCollection
=
ip
.
UnicastAddresses
;
...
...
@@ -85,11 +41,10 @@ namespace GcDevicePc
}
}
}
}
finally
catch
(
Exception
e
)
{
Log
.
Error
(
e
.
Message
);
}
if
(
globaldata
.
OffLinkMode
||
globaldata
.
StartNetwork
)
...
...
@@ -103,23 +58,23 @@ namespace GcDevicePc
static
public
bool
Ping
(
string
ip
)
{
System
.
Net
.
NetworkInformation
.
Ping
p
;
System
.
Net
.
NetworkInformation
.
PingOptions
options
;
System
.
Net
.
NetworkInformation
.
PingReply
reply
;
Ping
p
;
PingOptions
options
;
PingReply
reply
;
string
data
;
int
timeout
;
try
{
p
=
new
System
.
Net
.
NetworkInformation
.
Ping
();
options
=
new
System
.
Net
.
NetworkInformation
.
PingOptions
();
p
=
new
Ping
();
options
=
new
PingOptions
();
options
.
DontFragment
=
true
;
data
=
"Test Data!"
;
byte
[]
buffer
=
System
.
Text
.
Encoding
.
ASCII
.
GetBytes
(
data
);
timeout
=
1000
;
// Timeout 时间,单位:毫秒
reply
=
p
.
Send
(
ip
,
timeout
,
buffer
,
options
);
if
(
reply
.
Status
==
System
.
Net
.
NetworkInformation
.
IPStatus
.
Success
)
if
(
reply
.
Status
==
IPStatus
.
Success
)
{
globaldata
.
StartNetwork
=
true
;
return
true
;
...
...
@@ -136,25 +91,35 @@ namespace GcDevicePc
}
static
string
ip
;
static
private
void
CheckHmi
()
private
static
void
CheckHmi
()
{
ProThread
.
HMISearch
mysearch
=
new
ProThread
.
HMISearch
(
);
HMISearch
mysearch
=
new
HMISearch
(
null
);
int
hmicount
=
0
;
bool
ret
=
false
;
while
(
true
)
{
mysearch
.
ThStart
();
Thread
.
Sleep
(
3000
);
hmicount
=
mysearch
.
HMICount
();
ret
=
mysearch
.
ThStart
();
if
(
hmicount
>=
1
)
if
(
ret
)
{
ip
=
(((
globaldata
.
DeviceInfo
)(
mysearch
.
myHMIList
[
0
])).
IpAddr
);
globaldata
.
connection_ip
=
ip
;
break
;
}
mysearch
.
ThStop
();
Thread
.
Sleep
(
3000
);
hmicount
=
mysearch
.
HMICount
();
if
(
hmicount
>=
1
)
{
ip
=
(((
globaldata
.
DeviceInfo
)(
mysearch
.
myHMIList
[
0
])).
IpAddr
);
globaldata
.
connection_ip
=
ip
;
break
;
}
mysearch
.
ThStop
();
ret
=
false
;
}
else
{
mysearch
.
ReGetHmiIp
();
Thread
.
Sleep
(
2000
);
}
if
(
globaldata
.
OffLinkMode
)
{
globaldata
.
connection_ip
=
""
;
...
...
@@ -162,16 +127,10 @@ namespace GcDevicePc
}
}
}
static
private
System
.
Windows
.
Forms
.
DialogResult
ShowStart
()
private
static
void
RunStartWin
()
{
return
new
StartWin
().
ShowDialog
();
}
static
private
void
runStartWin
()
{
DialogResult
dr
;
dr
=
ShowStart
();
DialogResult
dr
=
new
StartWin
().
ShowDialog
();
}
[
STAThread
]
...
...
@@ -180,36 +139,16 @@ namespace GcDevicePc
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
//bool pingok = false;
bool
createNew
;
//string ipgw = "";
Thread
t_StartWin
;
t_StartWin
=
new
Thread
(
runStartWin
);
t_StartWin
.
IsBackground
=
true
;
t_StartWin
.
Start
();
//while (true)
//{
// ipgw = GetGW();
// pingok = Ping(ipgw);
// if (pingok)
// {
// break;
// }
Thread
tStartWin
=
new
Thread
(
RunStartWin
)
{
IsBackground
=
true
};
tStartWin
.
Start
();
// if(globaldata.OffLinkMode)
// {
// break;
// }
// Thread.Sleep(1000);
//}
isnetworkok
();
Isnetworkok
();
CheckHmi
();
{
using
(
System
.
Threading
.
Mutex
mutex
=
new
System
.
Threading
.
Mutex
(
true
,
Application
.
ProductName
,
out
createNew
))
{
...
...
@@ -220,7 +159,6 @@ namespace GcDevicePc
else
{
MessageBox
.
Show
(
"应用程序已经在运行中..."
);
System
.
Threading
.
Thread
.
Sleep
(
1000
);
System
.
Environment
.
Exit
(
1
);
}
...
...
GcDevicePc/Properties/AssemblyInfo.cs
View file @
d269da47
...
...
@@ -34,3 +34,4 @@ using System.Runtime.InteropServices;
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
\ No newline at end of file
GcDevicePc/Properties/Resources.Designer.cs
View file @
d269da47
...
...
@@ -19,7 +19,7 @@ namespace GcDevicePc.Properties {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"System.Resources.Tools.StronglyTypedResourceBuilder"
,
"
4
.0.0.0"
)]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"System.Resources.Tools.StronglyTypedResourceBuilder"
,
"
15
.0.0.0"
)]
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
internal
class
Resources
{
...
...
GcDevicePc/Properties/Settings.Designer.cs
View file @
d269da47
...
...
@@ -12,7 +12,7 @@ namespace GcDevicePc.Properties {
[
global
::
System
.
Runtime
.
CompilerServices
.
CompilerGeneratedAttribute
()]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator"
,
"1
2.0
.0.0"
)]
[
global
::
System
.
CodeDom
.
Compiler
.
GeneratedCodeAttribute
(
"Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator"
,
"1
5.6
.0.0"
)]
internal
sealed
partial
class
Settings
:
global
::
System
.
Configuration
.
ApplicationSettingsBase
{
private
static
Settings
defaultInstance
=
((
Settings
)(
global
::
System
.
Configuration
.
ApplicationSettingsBase
.
Synchronized
(
new
Settings
())));
...
...
GcDevicePc/SaveCfg.cs
View file @
d269da47
...
...
@@ -28,7 +28,7 @@ namespace GcDevicePc
bool
VerifyName
()
{
string
strtmp
;
DirectoryInfo
MethodDir
=
new
DirectoryInfo
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
s
ubStatusFolder
);
DirectoryInfo
MethodDir
=
new
DirectoryInfo
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
S
ubStatusFolder
);
foreach
(
FileInfo
file
in
MethodDir
.
GetFiles
(
"*.ini"
))
{
strtmp
=
this
.
newcfgname
.
Text
+
".ini"
;
...
...
@@ -64,7 +64,7 @@ namespace GcDevicePc
private
void
okbutton_Click
(
object
sender
,
EventArgs
e
)
{
string
filename
=
this
.
newcfgname
.
Text
+
".ini"
;
filename
=
System
.
IO
.
Path
.
Combine
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
s
ubStatusFolder
,
filename
);
filename
=
System
.
IO
.
Path
.
Combine
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
S
ubStatusFolder
,
filename
);
SaveInI
(
filename
);
this
.
Close
();
}
...
...
GcDevicePc/SendConfig.cs
View file @
d269da47
...
...
@@ -25,7 +25,7 @@ namespace GcDevicePc
private
void
SendConfig_Load
(
object
sender
,
EventArgs
e
)
{
DirectoryInfo
subStatusDir
=
new
DirectoryInfo
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
s
ubStatusFolder
);
DirectoryInfo
subStatusDir
=
new
DirectoryInfo
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
S
ubStatusFolder
);
localStatusList
.
Items
.
Clear
();
foreach
(
FileInfo
file
in
subStatusDir
.
GetFiles
(
"*.ini"
))
...
...
@@ -102,7 +102,7 @@ namespace GcDevicePc
if
(
localStatusList
.
GetItemChecked
(
i
))
{
checkfilename
=
localStatusList
.
GetItemText
(
localStatusList
.
Items
[
i
]);
sendfilename
=
System
.
IO
.
Path
.
Combine
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
s
ubStatusFolder
,
checkfilename
);
sendfilename
=
System
.
IO
.
Path
.
Combine
(
globaldata
.
m_pcbuffer
.
gcpcinfo
.
pcfolderinfo
.
S
ubStatusFolder
,
checkfilename
);
}
}
...
...
GcDevicePc/StartForm.cs
View file @
d269da47
...
...
@@ -17,14 +17,9 @@ namespace GcDevicePc
private
const
double
OpacityInterval
=
0.02
;
//0.02
private
const
double
StayTime
=
2000
;
//5s
//int count = 0;
System
.
Timers
.
Timer
OpacityTimer
;
Thread
t_preload
;
//Thread addhmi;
//ManualResetEvent mre = new ManualResetEvent(false);
System
.
Timers
.
Timer
OpacityTimer
;
static
Thread
t_preload
;
MainForm
m_mainform
;
private
void
OpacityTimerProcOpen
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
...
...
@@ -32,9 +27,7 @@ namespace GcDevicePc
if
(
this
.
m_CurrentOpacity
<
1
)
{
////如果当前的透明度小于1,则继续增加透明度
this
.
m_CurrentOpacity
+=
OpacityInterval
;
MethodInvoker
mi
=
new
MethodInvoker
(
UpdateFrmOpacity
);
this
.
BeginInvoke
(
mi
);
}
...
...
@@ -42,12 +35,9 @@ namespace GcDevicePc
{
//如果当前已经完全不透明,则停止timer
this
.
OpacityTimer
.
Stop
();
System
.
Timers
.
Timer
t
=
new
System
.
Timers
.
Timer
(
StayTime
);
//设置时间间隔为5秒
t
.
Elapsed
+=
new
System
.
Timers
.
ElapsedEventHandler
(
Timer_TimesUp
);
t
.
AutoReset
=
false
;
//每到指定时间Elapsed事件是触发一次(false),还是一直触发(true)
t
.
Start
();
}
}
...
...
@@ -56,9 +46,10 @@ namespace GcDevicePc
{
if
(
this
.
m_CurrentOpacity
>
0
)
{
t_preload
.
Join
();
//拦截透明度下降请求
//如果当前的透明度>0,则降低透明度
this
.
m_CurrentOpacity
-=
OpacityInterval
;
MethodInvoker
mi
=
new
MethodInvoker
(
UpdateFrmOpacity
);
this
.
BeginInvoke
(
mi
);
}
...
...
@@ -87,17 +78,6 @@ namespace GcDevicePc
OpacityTimer
.
Interval
=
30
;
OpacityTimer
.
Elapsed
+=
new
System
.
Timers
.
ElapsedEventHandler
(
OpacityTimerProcOpen
);
OpacityTimer
.
Start
();
t_preload
=
new
Thread
(
PreLoadingProc
);
t_preload
.
IsBackground
=
true
;
t_preload
.
Start
();
}
private
void
PreLoadingProc
()
{
//diagToolDevProxy.Instance.OpenDevice();
//AppCfg.Instance.Init();
//Frm_manager.Instance.Init();
}
private
void
Timer_TimesUp
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
...
...
@@ -118,54 +98,33 @@ namespace GcDevicePc
m_mainform
.
Show
();
}
}
/// <summary>
/// 窗口载入函数
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
StartForm_Load
(
object
sender
,
EventArgs
e
)
{
//if (mre != null)
// mre.Reset();
//addhmi = new Thread(searchhmi);
//addhmi.IsBackground = true;
//addhmi.Start();
//载入时开启预载线程
t_preload
=
new
Thread
(
PreLoadingProc
);
t_preload
.
IsBackground
=
true
;
t_preload
.
Start
();
}
//string ip;
//private void searchhmi()
//{
// ProThread.HMISearch mysearch = new ProThread.HMISearch();
// int hmicount = 0;
// while (!mre.WaitOne(100))
// {
// mysearch.ThStart();
// Thread.Sleep(3000);
// hmicount = mysearch.HMICount();
// if (hmicount == 1)
// {
// mre.Set();
// break;
// }
// mysearch.ThStop();
// count++;
// if (count >= 10)
// {
// mre.Set();
// break;
// }
// }
// if (count < 10)
// {
// ip = (((globaldata.DeviceInfo)(mysearch.myHMIList[0])).IpAddr);
// globaldata.connection_ip = ip;
// mysearch.ThStop();
// }
// count = 0;
//}
/// <summary>
/// 预载操作
/// </summary>
private
void
PreLoadingProc
()
{
globaldata
.
m_appinit
.
InitAppFolder
();
globaldata
.
m_appinit
.
InitAppDefaultConfig
();
// globaldata.m_appinit.InitDB();
// globaldata.m_appinit.InitAllGC();
//globaldata.m_appinit.InitAllGCConfig();
//globaldata.m_appinit.InitGCThread();
//globaldata.m_appinit.InitGCControl();
}
}
}
GcDevicePc/StartWin.cs
View file @
d269da47
...
...
@@ -14,6 +14,8 @@ namespace GcDevicePc
{
private
int
searchsec
=
0
;
private
int
i
=
0
;
public
StartWin
()
{
InitializeComponent
();
...
...
@@ -22,9 +24,10 @@ namespace GcDevicePc
private
void
checkhmitimer_Tick
(
object
sender
,
EventArgs
e
)
{
searchsec
++;
if
(
globaldata
.
StartNetwork
)
{
if
(
globaldata
.
connection_ip
!=
""
&&
globaldata
.
connection_ip
!=
null
)
if
(
!
String
.
IsNullOrEmpty
(
globaldata
.
connection_ip
)
)
{
this
.
Close
();
}
...
...
GcDevicePc/auxtool.cs
View file @
d269da47
...
...
@@ -286,7 +286,7 @@ namespace GcDevicePc
private
void
searchhmi
()
{
ProThread
.
HMISearch
mysearch
=
new
ProThread
.
HMISearch
();
ProThread
.
HMISearch
mysearch
=
new
ProThread
.
HMISearch
(
null
);
int
hmicount
=
0
;
int
i
;
mysearch
.
ThStart
();
...
...
GcDevicePc/globaldata.cs
View file @
d269da47
...
...
@@ -34,6 +34,8 @@ namespace GcDevicePc
public
static
int
device_index
=
0
;
//总共探测出的设备数目
public
static
int
current_device
;
//当前使用的设备号
public
static
AppInit
m_appinit
=
new
AppInit
();
public
const
string
remoteFolder
=
"\\Hard Disk2\\"
;
// public const string remoteFolder = "\\Storage Card\\";
public
const
string
exeremoteFolder
=
"\\Hard Disk\\"
;
...
...
GcDevicePc/packages.config
View file @
d269da47
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"CircularProgressBar"
version
=
"2.5.6403.13419"
targetFramework
=
"net40"
/>
<
package
id
=
"M2Mqtt"
version
=
"4.3.0.0"
targetFramework
=
"net45"
requireReinstallation
=
"True"
/>
<
package
id
=
"ini.net"
version
=
"1.1.0"
targetFramework
=
"net45"
/>
<
package
id
=
"log4net"
version
=
"2.0.8"
targetFramework
=
"net45"
/>
<
package
id
=
"M2Mqtt"
version
=
"4.3.0.0"
targetFramework
=
"net45"
/>
<
package
id
=
"WinFormAnimation"
version
=
"1.5.6298.3372"
targetFramework
=
"net40"
/>
</
packages
>
\ No newline at end of file
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