Commit 569af27c 张东亮

关闭启动按钮

1 个父辈 eabc27d3
......@@ -14,118 +14,44 @@ namespace OnlineStore.DeviceLibrary
{
//"E:\\Codes\\CSharp-Workspace\\MyProject\\WindowsService\\IPCamService\\bin\\Debug\\IPCamService.exe"
static string appPath = AppDomain.CurrentDomain.BaseDirectory;
static string serviceFilePath = ConfigHelper.Config.Get("IPCamService_FilePath", $"{appPath}IPCamService\\IPCamService.exe");
static string serviceName = ConfigHelper.Config.Get("IPCamService_ServiceName", "IPCamService");
//static string serviceFilePath = ConfigHelper.Config.Get("IPCamService_FilePath", $"{appPath}IPCamService\\IPCamService.exe");
//static string serviceName = ConfigHelper.Config.Get("IPCamService_ServiceName", "IPCamService");
/// <summary>
/// 安装服务
/// </summary>
public static void InstallService()
{
if (!IsServiceExisted(serviceName))
{
InstallService(serviceFilePath);
LogUtil.info("安装监控相机服务");
ServiceStart(serviceName);
LogUtil.info("启动监控相机服务");
}
else
{
ServiceStart(serviceName);
LogUtil.info("启动监控相机服务");
}
//if (!IsServiceExisted(serviceName))
//{
// InstallService(serviceFilePath);
// LogUtil.info("安装监控相机服务");
// ServiceStart(serviceName);
// LogUtil.info("启动监控相机服务");
//}
//else
//{
// ServiceStart(serviceName);
// LogUtil.info("启动监控相机服务");
//}
}
static string baseDir = ConfigHelper.Config.Get("IPCameraService_HttpServer", "http://localhost:8088");
public static void StartRecord(string camName,string fileName="")
{
Task.Factory.StartNew(delegate {
string url = $"{baseDir}/cam/startRecord?camName={camName}&filename={fileName}";
string res = HttpHelper.Get(url);
LogUtil.info($"开始记录视频:{fileName},{res}");
});
//Task.Factory.StartNew(delegate {
// string url = $"{baseDir}/cam/startRecord?camName={camName}&filename={fileName}";
// string res = HttpHelper.Get(url);
// LogUtil.info($"开始记录视频:{fileName},{res}");
//});
}
public static void StopRecord(string camName)
{
Task.Factory.StartNew(delegate {
string url = $"{baseDir}/cam/stopRecord?camName={camName}";
string res = HttpHelper.Get(url);
LogUtil.info($"停止记录视频:{res}");
});
//Task.Factory.StartNew(delegate {
// string url = $"{baseDir}/cam/stopRecord?camName={camName}";
// string res = HttpHelper.Get(url);
// 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();
}
}
}
}
}
......@@ -70,6 +70,7 @@ namespace OnlineStore.XLRStore
this.notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
this.Cursor = Cursors.Default;
this.timer1.Start();
}
private FrmInputEquip inputEquip = null;
private FrmBoxEquip box = null;
......@@ -332,17 +333,17 @@ namespace OnlineStore.XLRStore
private void 启动所有料仓AToolStripMenuItem_Click(object sender, EventArgs e)
{
if (StoreBean.runStatus != RunStatus.Wait)
{
MessageBox.Show(StoreBean.Name + "当前状态:" + StoreBean.runStatus + ",不能启动!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
//if (StoreBean.runStatus != RunStatus.Wait)
//{
// MessageBox.Show(StoreBean.Name + "当前状态:" + StoreBean.runStatus + ",不能启动!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
//}
LogUtil.info("点击 开始启动");
startTimer.Interval = 300;
startTimer.Elapsed += timer_Elapsed;
startTimer.AutoReset = false;
startTimer.Enabled = true;
this.timer1.Start();
//this.timer1.Start();
}
private delegate void ShowFormDelegate();
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
......@@ -352,10 +353,10 @@ namespace OnlineStore.XLRStore
{
return;
}
if (StoreBean.StartRun())
{
BeginInvoke(new ShowFormDelegate(ShowStatus));
}
//if (StoreBean.StartRun())
//{
// BeginInvoke(new ShowFormDelegate(ShowStatus));
//}
}
private void ShowStatus()
{
......@@ -364,18 +365,18 @@ namespace OnlineStore.XLRStore
private void formLineStatus(bool isStart)
{
启动AToolStripMenuItem.Enabled = !isStart;
停止TToolStripMenuItem.Enabled = isStart;
//启动AToolStripMenuItem.Enabled = !isStart;
//停止TToolStripMenuItem.Enabled = isStart;
}
private void 停止所有料仓TToolStripMenuItem_Click(object sender, EventArgs e)
{
if (StoreBean != null)
{
if (StoreBean.runStatus.Equals(RunStatus.Wait))
{
MessageBox.Show(StoreBean.Name + "流水线未启动,不需要停止", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
//if (StoreBean.runStatus.Equals(RunStatus.Wait))
//{
// MessageBox.Show(StoreBean.Name + "流水线未启动,不需要停止", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
//}
LogUtil.info(StoreBean.Name + "点击:停止");
if (StoreBean != null)
{
......@@ -387,20 +388,20 @@ namespace OnlineStore.XLRStore
private void 复位RToolStripMenuItem_Click(object sender, EventArgs e)
{
if (StoreBean.runStatus.Equals(RunStatus.Wait))
{
MessageBox.Show(StoreBean.Name + "流水线未启动,无法复位", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
LogUtil.info(StoreBean.Name + "点击:复位");
StoreBean.Reset();
//if (StoreBean.runStatus.Equals(RunStatus.Wait))
//{
// MessageBox.Show(StoreBean.Name + "流水线未启动,无法复位", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
// return;
//}
//LogUtil.info(StoreBean.Name + "点击:复位");
//StoreBean.Reset();
}
private void FrmLineStore_FormClosed(object sender, FormClosedEventArgs e)
{
if (停止TToolStripMenuItem.Enabled)
{
停止所有料仓TToolStripMenuItem_Click(null, null);
}
//if (停止TToolStripMenuItem.Enabled)
//{
// 停止所有料仓TToolStripMenuItem_Click(null, null);
//}
//AgvClient.Dispose();
if (IOManager.instance != null)
......@@ -481,9 +482,9 @@ namespace OnlineStore.XLRStore
{
LogM();
GC.Collect();
string canScanCode = "";
// string canScanCode = "";
lblStatus.Text = StoreBean.GetRunStr() + canScanCode;
// lblStatus.Text = StoreBean.GetRunStr() + canScanCode;
string warnMsg = "";
List<DeviceBase> deviceBases = new List<DeviceBase>() { StoreManager.XLRStore, StoreManager.XLRStore.inputEquip, StoreManager.XLRStore.boxEquip };
//if (StoreManager.XLRStore.runStatus > RunStatus.Wait)
......@@ -517,29 +518,29 @@ namespace OnlineStore.XLRStore
ReelControlB1.ShowData("B进料暂存区", BufferDataManager.BInStoreInfo, input.IOValue(IO_Type.FeedB_ReelCheck));
ReelControlB2.ShowData("B出料暂存区", BufferDataManager.BOutStoreInfo, input.IOValue(IO_Type.LineB_ReelInPlaceCheck));
if (StoreBean.runStatus > RunStatus.Wait)
{
if (启动AToolStripMenuItem.Enabled.Equals(true))
{
formLineStatus(true);
}
if ((StoreBean.runStatus.Equals(RunStatus.HomeMoving) || StoreBean.runStatus.Equals(RunStatus.Reset))
&& StoreBean.alarmType.Equals(AlarmType.None))
{
SetMenuS(复位RToolStripMenuItem, false);
SetMenuS(启动AToolStripMenuItem, false);
}
else
{
SetMenuS(复位RToolStripMenuItem, true);
}
}
else
{
SetMenuS(启动AToolStripMenuItem, true);
SetMenuS(复位RToolStripMenuItem, false);
SetMenuS(停止TToolStripMenuItem, false);
}
//if (StoreBean.runStatus > RunStatus.Wait)
//{
// if (启动AToolStripMenuItem.Enabled.Equals(true))
// {
// formLineStatus(true);
// }
// if ((StoreBean.runStatus.Equals(RunStatus.HomeMoving) || StoreBean.runStatus.Equals(RunStatus.Reset))
// && StoreBean.alarmType.Equals(AlarmType.None))
// {
// SetMenuS(复位RToolStripMenuItem, false);
// SetMenuS(启动AToolStripMenuItem, false);
// }
// else
// {
// SetMenuS(复位RToolStripMenuItem, true);
// }
//}
//else
//{
// SetMenuS(启动AToolStripMenuItem, true);
// SetMenuS(复位RToolStripMenuItem, false);
// SetMenuS(停止TToolStripMenuItem, false);
//}
}
catch (Exception ex)
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!