Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
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
潘栩锋
Thick-Common
Commits
2d5a6d39
Commit
2d5a6d39
authored
May 10, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复 系统有多个PLC,但只显示第1个PLC的连接状态,现在任何一个断开都会触发报警
优化 AppJustOne 能实现程序重启
parent
8957f54b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
21 deletions
+58
-21
AppJustOne.cs
Project.FLY.AppHelper/FLY.AppHelper/AppJustOne.cs
+18
-0
WindowNotifyIconHelper.cs
...ect.FLY.AppHelper/FLY.AppHelper/WindowNotifyIconHelper.cs
+11
-3
PLCProxySystemServiceClient.cs
...nents/OBJComponents/Client/PLCProxySystemServiceClient.cs
+1
-1
ErrorConf.cs
Project.FLY.OBJComponents/OBJComponents/Server/ErrorConf.cs
+15
-10
PLCProxySystem.cs
....FLY.OBJComponents/OBJComponents/Server/PLCProxySystem.cs
+13
-7
No files found.
Project.FLY.AppHelper/FLY.AppHelper/AppJustOne.cs
View file @
2d5a6d39
...
...
@@ -8,6 +8,17 @@ namespace FLY.AppHelper
{
public
class
AppJustOne
{
static
bool
IsReboot
=
false
;
public
static
void
Restart
()
{
//通知AppJustOne不要限制
IsReboot
=
true
;
//重启软件
System
.
Windows
.
Forms
.
Application
.
Restart
();
Application
.
Current
.
Shutdown
();
}
public
AppJustOne
(
Application
app
)
{
app
.
Startup
+=
new
StartupEventHandler
(
app_Startup
);
...
...
@@ -16,6 +27,13 @@ namespace FLY.AppHelper
void
app_Startup
(
object
sender
,
StartupEventArgs
e
)
{
if
(
IsReboot
)
{
IsReboot
=
false
;
return
;
}
Process
process
=
Process
.
GetCurrentProcess
();
string
name
=
process
.
ProcessName
;
...
...
Project.FLY.AppHelper/FLY.AppHelper/WindowNotifyIconHelper.cs
View file @
2d5a6d39
...
...
@@ -47,8 +47,16 @@ namespace FLY.AppHelper
wsl
=
this
.
window
.
WindowState
;
this
.
window
.
StateChanged
+=
new
EventHandler
(
window_StateChanged
);
this
.
window
.
Closing
+=
new
System
.
ComponentModel
.
CancelEventHandler
(
window_Closing
);
Application
.
ApplicationExit
+=
Application_ApplicationExit
;
}
private
void
Application_ApplicationExit
(
object
sender
,
EventArgs
e
)
{
notifyIcon
.
Dispose
();
System
.
Environment
.
Exit
(
0
);
//这个是不会触发 ApplicationExit, 但可以把全部线程清除掉
}
/// <summary>
/// 退出选项
...
...
@@ -61,9 +69,9 @@ namespace FLY.AppHelper
if
(
r
==
System
.
Windows
.
MessageBoxResult
.
Yes
)
{
//notifyIcon.Visible = false;
notifyIcon
.
Dispose
();
//
notifyIcon.Dispose();
//System.Windows.Application.Current.Shutdown();
System
.
Environment
.
Exit
(
0
);
Application
.
Exit
();
}
}
void
window_Closing
(
object
sender
,
System
.
ComponentModel
.
CancelEventArgs
e
)
...
...
Project.FLY.OBJComponents/OBJComponents/Client/PLCProxySystemServiceClient.cs
View file @
2d5a6d39
...
...
@@ -120,7 +120,7 @@ namespace FLY.OBJComponents.Client
public
string
[]
GetSyncPropNames
()
{
return
new
string
[]
{
"IsConnectedWithPLC"
nameof
(
IsConnectedWithPLC
)
};
}
...
...
Project.FLY.OBJComponents/OBJComponents/Server/ErrorConf.cs
View file @
2d5a6d39
...
...
@@ -20,13 +20,13 @@ namespace FLY.OBJComponents.Server
/// <summary>
/// 需要设置
/// </summary>
IPLCProxySystemService
PLCos
;
PLCProxySystem
PLCos
;
/// <summary>
/// 报警系统
/// </summary>
WarningSystem
mWarning
;
public
byte
ErrCode
=
0
;
public
ErrorConf
(
IPLCProxySystemService
PLCos
,
WarningSystem
mWarning
,
string
plcName
)
public
ErrorConf
(
PLCProxySystem
PLCos
,
WarningSystem
mWarning
,
string
plcName
)
{
this
.
PLCos
=
PLCos
;
this
.
mWarning
=
mWarning
;
...
...
@@ -98,22 +98,27 @@ namespace FLY.OBJComponents.Server
}
//--------------------------------------------------------------------------------
//连接断开事件
//连接断开事件
, 3秒查一次,不能有复位的机会
FObjBase
.
PollModule
.
Current
.
Poll_Config
(
PollModule
.
POLL_CONFIG
.
ADD
,
()
=>
{
Misc
.
BindingOperations
.
SetBinding
(
PLCos
,
nameof
(
PLCos
.
IsConnectedWithPLC
),
()
=>
for
(
int
i
=
0
;
i
<
PLCos
.
PLCs
.
Count
();
i
++)
{
bool
b
=
!
PLCos
.
IsConnectedWithPLC
;
bool
b
=
!
PLCos
.
PLCs
[
i
].
Client
.
IsConnected
;
ERR_STATE
state
=
b
?
ERR_STATE
.
ON
:
ERR_STATE
.
OFF
;
ERRNO
errno
=
PlcErrNos
.
ERRNO_PLC_DISCONNECTED
;
byte
errcode
=
errno
.
Code
;
string
description
=
$"
{
plcName
}
"
+
errno
.
Descrption
;
byte
errcode
=
(
byte
)(
errno
.
Code
-
i
);
string
description
;
if
(
PLCos
.
PLCs
.
Count
()
>
1
)
description
=
$"
{
plcName
}
No.
{
i
}
"
+
errno
.
Descrption
;
else
description
=
$"
{
plcName
}
"
+
errno
.
Descrption
;
mWarning
.
Add
(
errcode
,
description
,
state
);
});
},
TimeSpan
.
FromSeconds
(
3
),
true
,
false
,
this
,
MARKNO_DELAY_ISCONNECTED
,
true
);
}
},
TimeSpan
.
FromSeconds
(
3
),
true
,
false
,
this
,
MARKNO_DELAY_ISCONNECTED
,
false
);
//--------------------------------------------------------------------------------
//启动定时器,每1秒查报警,防止 以为报警复位了,但其实还在报警
...
...
Project.FLY.OBJComponents/OBJComponents/Server/PLCProxySystem.cs
View file @
2d5a6d39
...
...
@@ -110,13 +110,19 @@ namespace FLY.OBJComponents.Server
plc
.
NameDataChanged
+=
Plc_NameDataChanged
;
}
Misc
.
BindingOperations
.
SetBinding
(
PLCs
[
0
].
Client
,
"IsConnected"
,
()
=>
//任何一个PLC断开,也会显示连接断开
IsConnectedWithPLC
=
PLCs
.
All
(
plc
=>
plc
.
Client
.
IsConnected
);
foreach
(
var
plc
in
PLCs
)
{
IsConnectedWithPLC
=
PLCs
[
0
].
Client
.
IsConnected
;
//if (!IsConnectedWithPLC)
// ClearPlan();
});
plc
.
Client
.
PropertyChanged
+=
(
s
,
e
)
=>
{
if
(
e
.
PropertyName
==
nameof
(
Modbus
.
WithThread
.
ClientTCP
.
IsConnected
))
{
IsConnectedWithPLC
=
PLCs
.
All
(
p
=>
p
.
Client
.
IsConnected
);
}
};
}
foreach
(
var
obj
in
ObjNames
.
Values
)
{
...
...
@@ -357,7 +363,7 @@ namespace FLY.OBJComponents.Server
public
string
[]
GetSyncPropNames
()
{
return
new
string
[]
{
"IsConnectedWithPLC"
};
return
new
string
[]
{
nameof
(
IsConnectedWithPLC
)
};
}
public
string
[]
GetNoSyncPropNames
()
...
...
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