Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张东亮
/
SO1131-XLRStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 569af27c
由
张东亮
编写于
2023-04-25 11:52:15 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
关闭启动按钮
1 个父辈
eabc27d3
全部展开
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
78 行增加
和
151 行删除
source/DeviceLibrary/manager/IPCameraHelper.cs
source/XLRStoreClient/FrmXLRStore.Designer.cs
source/XLRStoreClient/FrmXLRStore.cs
source/DeviceLibrary/manager/IPCameraHelper.cs
查看文件 @
569af27
...
@@ -14,118 +14,44 @@ namespace OnlineStore.DeviceLibrary
...
@@ -14,118 +14,44 @@ namespace OnlineStore.DeviceLibrary
{
{
//"E:\\Codes\\CSharp-Workspace\\MyProject\\WindowsService\\IPCamService\\bin\\Debug\\IPCamService.exe"
//"E:\\Codes\\CSharp-Workspace\\MyProject\\WindowsService\\IPCamService\\bin\\Debug\\IPCamService.exe"
static
string
appPath
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
static
string
appPath
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
static
string
serviceFilePath
=
ConfigHelper
.
Config
.
Get
(
"IPCamService_FilePath"
,
$
"{appPath}IPCamService\\IPCamService.exe"
);
//
static string serviceFilePath = ConfigHelper.Config.Get("IPCamService_FilePath", $"{appPath}IPCamService\\IPCamService.exe");
static
string
serviceName
=
ConfigHelper
.
Config
.
Get
(
"IPCamService_ServiceName"
,
"IPCamService"
);
//
static string serviceName = ConfigHelper.Config.Get("IPCamService_ServiceName", "IPCamService");
/// <summary>
/// <summary>
/// 安装服务
/// 安装服务
/// </summary>
/// </summary>
public
static
void
InstallService
()
public
static
void
InstallService
()
{
{
if
(!
IsServiceExisted
(
serviceName
))
//
if (!IsServiceExisted(serviceName))
{
//
{
InstallService
(
serviceFilePath
);
//
InstallService(serviceFilePath);
LogUtil
.
info
(
"安装监控相机服务"
);
//
LogUtil.info("安装监控相机服务");
ServiceStart
(
serviceName
);
//
ServiceStart(serviceName);
LogUtil
.
info
(
"启动监控相机服务"
);
//
LogUtil.info("启动监控相机服务");
}
//
}
else
//
else
{
//
{
ServiceStart
(
serviceName
);
//
ServiceStart(serviceName);
LogUtil
.
info
(
"启动监控相机服务"
);
//
LogUtil.info("启动监控相机服务");
}
//
}
}
}
static
string
baseDir
=
ConfigHelper
.
Config
.
Get
(
"IPCameraService_HttpServer"
,
"http://localhost:8088"
);
static
string
baseDir
=
ConfigHelper
.
Config
.
Get
(
"IPCameraService_HttpServer"
,
"http://localhost:8088"
);
public
static
void
StartRecord
(
string
camName
,
string
fileName
=
""
)
public
static
void
StartRecord
(
string
camName
,
string
fileName
=
""
)
{
{
Task
.
Factory
.
StartNew
(
delegate
{
//
Task.Factory.StartNew(delegate {
string
url
=
$
"{baseDir}/cam/startRecord?camName={camName}&filename={fileName}"
;
//
string url = $"{baseDir}/cam/startRecord?camName={camName}&filename={fileName}";
string
res
=
HttpHelper
.
Get
(
url
);
//
string res = HttpHelper.Get(url);
LogUtil
.
info
(
$
"开始记录视频:{fileName},{res}"
);
//
LogUtil.info($"开始记录视频:{fileName},{res}");
});
//
});
}
}
public
static
void
StopRecord
(
string
camName
)
public
static
void
StopRecord
(
string
camName
)
{
{
Task
.
Factory
.
StartNew
(
delegate
{
//Task.Factory.StartNew(delegate {
string
url
=
$
"{baseDir}/cam/stopRecord?camName={camName}"
;
// string url = $"{baseDir}/cam/stopRecord?camName={camName}";
string
res
=
HttpHelper
.
Get
(
url
);
// string res = HttpHelper.Get(url);
LogUtil
.
info
(
$
"停止记录视频:{res}"
);
// LogUtil.info($"停止记录视频:{res}");
});
//});
}
//判断服务是否存在
static
bool
IsServiceExisted
(
string
serviceName
)
{
ServiceController
[]
services
=
ServiceController
.
GetServices
();
foreach
(
ServiceController
sc
in
services
)
{
if
(
sc
.
ServiceName
.
ToLower
()
==
serviceName
.
ToLower
())
{
return
true
;
}
}
return
false
;
}
//安装服务
static
void
InstallService
(
string
serviceFilePath
)
{
try
{
using
(
AssemblyInstaller
installer
=
new
AssemblyInstaller
())
{
installer
.
UseNewContext
=
true
;
installer
.
Path
=
serviceFilePath
;
IDictionary
savedState
=
new
Hashtable
();
installer
.
Install
(
savedState
);
installer
.
Commit
(
savedState
);
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"安装监控相机服务失败"
,
ex
);
}
}
//卸载服务
static
void
UninstallService
(
string
serviceFilePath
)
{
using
(
AssemblyInstaller
installer
=
new
AssemblyInstaller
())
{
installer
.
UseNewContext
=
true
;
installer
.
Path
=
serviceFilePath
;
installer
.
Uninstall
(
null
);
}
}
//启动服务
static
void
ServiceStart
(
string
serviceName
)
{
try
{
using
(
ServiceController
control
=
new
ServiceController
(
serviceName
))
{
if
(
control
.
Status
==
ServiceControllerStatus
.
Stopped
)
{
control
.
Start
();
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
$
"启动监控相机服务失败"
,
ex
);
}
}
//停止服务
static
void
ServiceStop
(
string
serviceName
)
{
using
(
ServiceController
control
=
new
ServiceController
(
serviceName
))
{
if
(
control
.
Status
==
ServiceControllerStatus
.
Running
)
{
control
.
Stop
();
}
}
}
}
}
}
}
}
source/XLRStoreClient/FrmXLRStore.Designer.cs
查看文件 @
569af27
此文件的差异被折叠,
点击展开。
source/XLRStoreClient/FrmXLRStore.cs
查看文件 @
569af27
...
@@ -70,6 +70,7 @@ namespace OnlineStore.XLRStore
...
@@ -70,6 +70,7 @@ namespace OnlineStore.XLRStore
this
.
notifyIcon1
.
Visible
=
false
;
this
.
notifyIcon1
.
Visible
=
false
;
this
.
ShowInTaskbar
=
true
;
this
.
ShowInTaskbar
=
true
;
this
.
Cursor
=
Cursors
.
Default
;
this
.
Cursor
=
Cursors
.
Default
;
this
.
timer1
.
Start
();
}
}
private
FrmInputEquip
inputEquip
=
null
;
private
FrmInputEquip
inputEquip
=
null
;
private
FrmBoxEquip
box
=
null
;
private
FrmBoxEquip
box
=
null
;
...
@@ -332,17 +333,17 @@ namespace OnlineStore.XLRStore
...
@@ -332,17 +333,17 @@ namespace OnlineStore.XLRStore
private
void
启动所有料仓
AToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
private
void
启动所有料仓
AToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
{
if
(
StoreBean
.
runStatus
!=
RunStatus
.
Wait
)
//
if (StoreBean.runStatus != RunStatus.Wait)
{
//
{
MessageBox
.
Show
(
StoreBean
.
Name
+
"当前状态:"
+
StoreBean
.
runStatus
+
",不能启动!"
,
"提示"
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Warning
);
//
MessageBox.Show(StoreBean.Name + "当前状态:" + StoreBean.runStatus + ",不能启动!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return
;
//
return;
}
//
}
LogUtil
.
info
(
"点击 开始启动"
);
LogUtil
.
info
(
"点击 开始启动"
);
startTimer
.
Interval
=
300
;
startTimer
.
Interval
=
300
;
startTimer
.
Elapsed
+=
timer_Elapsed
;
startTimer
.
Elapsed
+=
timer_Elapsed
;
startTimer
.
AutoReset
=
false
;
startTimer
.
AutoReset
=
false
;
startTimer
.
Enabled
=
true
;
startTimer
.
Enabled
=
true
;
this
.
timer1
.
Start
();
//
this.timer1.Start();
}
}
private
delegate
void
ShowFormDelegate
();
private
delegate
void
ShowFormDelegate
();
void
timer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
void
timer_Elapsed
(
object
sender
,
System
.
Timers
.
ElapsedEventArgs
e
)
...
@@ -352,10 +353,10 @@ namespace OnlineStore.XLRStore
...
@@ -352,10 +353,10 @@ namespace OnlineStore.XLRStore
{
{
return
;
return
;
}
}
if
(
StoreBean
.
StartRun
())
//
if (StoreBean.StartRun())
{
//
{
BeginInvoke
(
new
ShowFormDelegate
(
ShowStatus
));
//
BeginInvoke(new ShowFormDelegate(ShowStatus));
}
//
}
}
}
private
void
ShowStatus
()
private
void
ShowStatus
()
{
{
...
@@ -364,18 +365,18 @@ namespace OnlineStore.XLRStore
...
@@ -364,18 +365,18 @@ namespace OnlineStore.XLRStore
private
void
formLineStatus
(
bool
isStart
)
private
void
formLineStatus
(
bool
isStart
)
{
{
启动
AToolStripMenuItem
.
Enabled
=
!
isStart
;
//
启动AToolStripMenuItem.Enabled = !isStart;
停止
TToolStripMenuItem
.
Enabled
=
isStart
;
//
停止TToolStripMenuItem.Enabled = isStart;
}
}
private
void
停止所有料仓
TToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
private
void
停止所有料仓
TToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
{
if
(
StoreBean
!=
null
)
if
(
StoreBean
!=
null
)
{
{
if
(
StoreBean
.
runStatus
.
Equals
(
RunStatus
.
Wait
))
//
if (StoreBean.runStatus.Equals(RunStatus.Wait))
{
//
{
MessageBox
.
Show
(
StoreBean
.
Name
+
"流水线未启动,不需要停止"
,
"提示"
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Warning
);
//
MessageBox.Show(StoreBean.Name + "流水线未启动,不需要停止", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return
;
//
return;
}
//
}
LogUtil
.
info
(
StoreBean
.
Name
+
"点击:停止"
);
LogUtil
.
info
(
StoreBean
.
Name
+
"点击:停止"
);
if
(
StoreBean
!=
null
)
if
(
StoreBean
!=
null
)
{
{
...
@@ -387,20 +388,20 @@ namespace OnlineStore.XLRStore
...
@@ -387,20 +388,20 @@ namespace OnlineStore.XLRStore
private
void
复位
RToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
private
void
复位
RToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
{
if
(
StoreBean
.
runStatus
.
Equals
(
RunStatus
.
Wait
))
//
if (StoreBean.runStatus.Equals(RunStatus.Wait))
{
//
{
MessageBox
.
Show
(
StoreBean
.
Name
+
"流水线未启动,无法复位"
,
"提示"
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Warning
);
//
MessageBox.Show(StoreBean.Name + "流水线未启动,无法复位", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return
;
//
return;
}
//
}
LogUtil
.
info
(
StoreBean
.
Name
+
"点击:复位"
);
//
LogUtil.info(StoreBean.Name + "点击:复位");
StoreBean
.
Reset
();
//
StoreBean.Reset();
}
}
private
void
FrmLineStore_FormClosed
(
object
sender
,
FormClosedEventArgs
e
)
private
void
FrmLineStore_FormClosed
(
object
sender
,
FormClosedEventArgs
e
)
{
{
if
(
停止
TToolStripMenuItem
.
Enabled
)
//
if (停止TToolStripMenuItem.Enabled)
{
//
{
停止所有料仓
TToolStripMenuItem_Click
(
null
,
null
);
//
停止所有料仓TToolStripMenuItem_Click(null, null);
}
//
}
//AgvClient.Dispose();
//AgvClient.Dispose();
if
(
IOManager
.
instance
!=
null
)
if
(
IOManager
.
instance
!=
null
)
...
@@ -481,9 +482,9 @@ namespace OnlineStore.XLRStore
...
@@ -481,9 +482,9 @@ namespace OnlineStore.XLRStore
{
{
LogM
();
LogM
();
GC
.
Collect
();
GC
.
Collect
();
string
canScanCode
=
""
;
//
string canScanCode = "";
lblStatus
.
Text
=
StoreBean
.
GetRunStr
()
+
canScanCode
;
//
lblStatus.Text = StoreBean.GetRunStr() + canScanCode;
string
warnMsg
=
""
;
string
warnMsg
=
""
;
List
<
DeviceBase
>
deviceBases
=
new
List
<
DeviceBase
>()
{
StoreManager
.
XLRStore
,
StoreManager
.
XLRStore
.
inputEquip
,
StoreManager
.
XLRStore
.
boxEquip
};
List
<
DeviceBase
>
deviceBases
=
new
List
<
DeviceBase
>()
{
StoreManager
.
XLRStore
,
StoreManager
.
XLRStore
.
inputEquip
,
StoreManager
.
XLRStore
.
boxEquip
};
//if (StoreManager.XLRStore.runStatus > RunStatus.Wait)
//if (StoreManager.XLRStore.runStatus > RunStatus.Wait)
...
@@ -517,29 +518,29 @@ namespace OnlineStore.XLRStore
...
@@ -517,29 +518,29 @@ namespace OnlineStore.XLRStore
ReelControlB1
.
ShowData
(
"B进料暂存区"
,
BufferDataManager
.
BInStoreInfo
,
input
.
IOValue
(
IO_Type
.
FeedB_ReelCheck
));
ReelControlB1
.
ShowData
(
"B进料暂存区"
,
BufferDataManager
.
BInStoreInfo
,
input
.
IOValue
(
IO_Type
.
FeedB_ReelCheck
));
ReelControlB2
.
ShowData
(
"B出料暂存区"
,
BufferDataManager
.
BOutStoreInfo
,
input
.
IOValue
(
IO_Type
.
LineB_ReelInPlaceCheck
));
ReelControlB2
.
ShowData
(
"B出料暂存区"
,
BufferDataManager
.
BOutStoreInfo
,
input
.
IOValue
(
IO_Type
.
LineB_ReelInPlaceCheck
));
if
(
StoreBean
.
runStatus
>
RunStatus
.
Wait
)
//
if (StoreBean.runStatus > RunStatus.Wait)
{
//
{
if
(
启动
AToolStripMenuItem
.
Enabled
.
Equals
(
true
))
//
if (启动AToolStripMenuItem.Enabled.Equals(true))
{
//
{
formLineStatus
(
true
);
//
formLineStatus(true);
}
//
}
if
((
StoreBean
.
runStatus
.
Equals
(
RunStatus
.
HomeMoving
)
||
StoreBean
.
runStatus
.
Equals
(
RunStatus
.
Reset
))
//
if ((StoreBean.runStatus.Equals(RunStatus.HomeMoving) || StoreBean.runStatus.Equals(RunStatus.Reset))
&&
StoreBean
.
alarmType
.
Equals
(
AlarmType
.
None
))
//
&& StoreBean.alarmType.Equals(AlarmType.None))
{
//
{
SetMenuS
(
复位
RToolStripMenuItem
,
false
);
//
SetMenuS(复位RToolStripMenuItem, false);
SetMenuS
(
启动
AToolStripMenuItem
,
false
);
//
SetMenuS(启动AToolStripMenuItem, false);
}
//
}
else
//
else
{
//
{
SetMenuS
(
复位
RToolStripMenuItem
,
true
);
//
SetMenuS(复位RToolStripMenuItem, true);
}
//
}
}
//
}
else
//
else
{
//
{
SetMenuS
(
启动
AToolStripMenuItem
,
true
);
//
SetMenuS(启动AToolStripMenuItem, true);
SetMenuS
(
复位
RToolStripMenuItem
,
false
);
//
SetMenuS(复位RToolStripMenuItem, false);
SetMenuS
(
停止
TToolStripMenuItem
,
false
);
//
SetMenuS(停止TToolStripMenuItem, false);
}
//
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论