You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
285 lines
11 KiB
C#
285 lines
11 KiB
C#
using DataBlockHelper;
|
|
using DevExpress.XtraExport.Helpers;
|
|
using DevExpress.XtraRichEdit.Model;
|
|
using ICSharpCode.Core;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Action.ChemicalWeighing.InterfaceDocking;
|
|
using Mesnac.Action.ChemicalWeighing.InterfaceDocking.DockingEntity;
|
|
using Mesnac.Controls.ChemicalWeighing;
|
|
using Mesnac.Controls.Default;
|
|
using Mesnac.Core.Service;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices.ComTypes;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Report
|
|
{
|
|
public class LjLogReport : ChemicalWeighingAction, IAction
|
|
{
|
|
MCButton SelectButton;
|
|
MCButton WaterSet;
|
|
MCButton SpiralSet;
|
|
MCButton ManualControl;
|
|
MCButton Refresh;
|
|
MCButton SelectByText;
|
|
MCButton EliAlarms;
|
|
MCButton DownloadRequest;
|
|
|
|
//HslSwitch HslSwitch1;
|
|
//HslSwitch HslSwitch2;
|
|
//HslSwitch HslSwitch3;
|
|
//HslSwitch HslSwitch4;
|
|
//HslSwitch HslSwitch5;
|
|
//HslSwitch HslSwitch6;
|
|
//HslSwitch HslSwitch7;
|
|
//HslSwitch HslSwitch8;
|
|
|
|
MCTextBox SelectText;
|
|
|
|
MCDateTimePicker StartDate;
|
|
MCDateTimePicker EndDate;
|
|
|
|
DbMCControl LogForm;
|
|
|
|
MCCombobox Line;
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
base.RunIni(runtime);
|
|
|
|
var control = GetAllControls();
|
|
|
|
SelectButton = control.FirstOrDefault(x => x != null && x.Name == "SelectButton") as MCButton;
|
|
WaterSet = control.FirstOrDefault(x => x != null && x.Name == "WaterSet") as MCButton;
|
|
SpiralSet = control.FirstOrDefault(x => x != null && x.Name == "SpiralSet") as MCButton;
|
|
ManualControl = control.FirstOrDefault(x => x != null && x.Name == "ManualControl") as MCButton;
|
|
Refresh = control.FirstOrDefault(x => x != null && x.Name == "Refresh") as MCButton;
|
|
SelectByText = control.FirstOrDefault(x => x != null && x.Name == "SelectByText") as MCButton;
|
|
EliAlarms = control.FirstOrDefault(x => x != null && x.Name == "EliAlarms") as MCButton;
|
|
DownloadRequest = control.FirstOrDefault(x => x != null && x.Name == "DownloadRequest") as MCButton;
|
|
StartDate = control.FirstOrDefault(x => x != null && x.Name == "StartDate") as MCDateTimePicker;
|
|
EndDate = control.FirstOrDefault(x => x != null && x.Name == "EndDate") as MCDateTimePicker;
|
|
LogForm = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ManualLogGridView1").FirstOrDefault();
|
|
SelectText = control.FirstOrDefault(x => x != null && x.Name == "SelectText") as MCTextBox;
|
|
Line = control.FirstOrDefault(x => x != null && x.Name == "Line") as MCCombobox;
|
|
//HslSwitch1 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch1") as HslSwitch;
|
|
//HslSwitch2 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch2") as HslSwitch;
|
|
//HslSwitch3 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch3") as HslSwitch;
|
|
//HslSwitch4 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch4") as HslSwitch;
|
|
//HslSwitch5 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch5") as HslSwitch;
|
|
//HslSwitch6 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch6") as HslSwitch;
|
|
//HslSwitch7 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch7") as HslSwitch;
|
|
//HslSwitch8 = control.FirstOrDefault(x => x != null && x.Name == "HslSwitch8") as HslSwitch;
|
|
|
|
if (LogForm != null)
|
|
{
|
|
LogForm.BaseControl.BindDataSource = null;
|
|
LogForm.BaseControl.BindDataSource = LjLogControl.ManualLogSelect("");
|
|
}
|
|
|
|
DataTable dataTable = new DataTable();
|
|
dataTable.Columns.Add("CmbValue", typeof(string));
|
|
dataTable.Columns.Add("CmbDisplay", typeof(string));
|
|
DataRow dr = dataTable.NewRow();
|
|
dr[0] = "0";
|
|
dr[1] = "全部机台";
|
|
dataTable.Rows.Add(dr);
|
|
for (int i = 1; i <= 8; i++)
|
|
{
|
|
dr = dataTable.NewRow();
|
|
dr[0] = i.ToString();
|
|
dr[1] = i + "号机台";
|
|
dataTable.Rows.Add(dr);
|
|
}
|
|
Line.DataSource = dataTable;
|
|
|
|
StartDate.MCValue = DateTime.Now.AddDays(-7);
|
|
|
|
SetForm("");
|
|
|
|
SelectButton.Click += SelectByTime;
|
|
WaterSet.Click += WaterSetSelect;
|
|
SpiralSet.Click += SpiralSetSelect;
|
|
ManualControl.Click += ManualControlSelect;
|
|
Refresh.Click += RefreshAction;
|
|
SelectByText.Click += SelectByTextAction;
|
|
EliAlarms.Click += EliAlarmsClick;
|
|
DownloadRequest.Click += RequestDownloadClick;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 下发送料请求按钮点击
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void RequestDownloadClick(object sender, EventArgs e)
|
|
{
|
|
bool mixok1 = PlcConnect.Instance.ReadBool("DB3000.0.0").Content;
|
|
Time(1, mixok1 ? 1 : 0);
|
|
bool mixok2 = PlcConnect.Instance.ReadBool("DB3000.0.1").Content;
|
|
Time(2, mixok2 ? 1 : 0);
|
|
bool mixok3 = PlcConnect.Instance.ReadBool("DB3000.0.2").Content;
|
|
Time(3, mixok3 ? 1 : 0);
|
|
bool mixok4 = PlcConnect.Instance.ReadBool("DB3000.0.3").Content;
|
|
Time(4, mixok4 ? 1 : 0);
|
|
bool mixok5 = PlcConnect.Instance.ReadBool("DB3000.0.4").Content;
|
|
Time(5, mixok5 ? 1 : 0);
|
|
bool mixok6 = PlcConnect.Instance.ReadBool("DB3000.0.5").Content;
|
|
Time(6, mixok6 ? 1 : 0);
|
|
bool mixok7 = PlcConnect.Instance.ReadBool("DB3000.0.6").Content;
|
|
Trace.WriteLine("7号信号:" + mixok7);
|
|
Time(7, mixok7 ? 1 : 0);
|
|
bool mixok8 = PlcConnect.Instance.ReadBool("DB3000.0.7").Content;
|
|
Trace.WriteLine("8号信号:" + mixok8);
|
|
Time(8, mixok8 ? 1 : 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 下发接料请求
|
|
/// </summary>
|
|
/// <param name="deviceNo"></param>
|
|
/// <param name="statu"></param>
|
|
private void Time(int deviceNo, int statu)
|
|
{
|
|
TankIsDischargedSyncEntity tankIsDischargedSyncEntity = new TankIsDischargedSyncEntity()
|
|
{
|
|
reqCode = System.Guid.NewGuid().ToString(),
|
|
reqTime = DateTime.Now,
|
|
deviceNo = deviceNo.ToString(),
|
|
state = statu.ToString(),
|
|
};
|
|
//即使网络不同 也不会影响上位机的使用
|
|
ThreadPool.QueueUserWorkItem(delegate
|
|
{
|
|
HttpResponse httpResponse = new HttpResponse();
|
|
string returnTest = httpResponse.PostResponse(tankIsDischargedSyncEntity);
|
|
MesnacServiceManager.Instance.LoggingService.Info($"湿混机{deviceNo}返回数据" + returnTest);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 消除报警按钮点击
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void EliAlarmsClick(object sender, EventArgs e)
|
|
{
|
|
PlcConnect.Instance.Write("DB2107.10.7", true);
|
|
Thread.Sleep(2000);
|
|
PlcConnect.Instance.Write("DB2107.10.7", false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 按时间查询日志
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SelectByTime(object sender, EventArgs e)
|
|
{
|
|
SetForm(StartDate.Value.Date.ToString("yyyy-MM-dd"), EndDate.Value.Date.ToString("yyyy-MM-dd"));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 水称日志查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void WaterSetSelect(object sender, EventArgs e)
|
|
{
|
|
SetForm("水", Convert.ToInt32(Line.MCValue.ToString()));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 螺旋日志查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SpiralSetSelect(object sender, EventArgs e)
|
|
{
|
|
SetForm("螺旋", Convert.ToInt32(Line.MCValue.ToString()));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 手动操作查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void ManualControlSelect(object sender, EventArgs e)
|
|
{
|
|
SetForm("手动");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 刷新日志按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void RefreshAction(object sender, EventArgs e)
|
|
{
|
|
SetForm("");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据文本模糊查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void SelectByTextAction(object sender, EventArgs e)
|
|
{
|
|
SetForm(SelectText.MCValue.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据文本查询绑定控件2
|
|
/// </summary>
|
|
/// <param name="key">文本</param>
|
|
private void SetForm(string key)
|
|
{
|
|
if (LogForm != null)
|
|
{
|
|
LogForm.BaseControl.BindDataSource = null;
|
|
LogForm.BaseControl.BindDataSource = LjLogControl.ManualLogSelect(key);
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据文本和设备编号查询绑定控件
|
|
/// </summary>
|
|
/// <param name="key">文本</param>
|
|
/// <param name="deviceNo">设备编号</param>
|
|
private void SetForm(string key, int deviceNo)
|
|
{
|
|
if (LogForm != null)
|
|
{
|
|
LogForm.BaseControl.BindDataSource = null;
|
|
LogForm.BaseControl.BindDataSource = LjLogControl.ManualLogSelect(key, deviceNo);
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据起始时间查询绑定控件
|
|
/// </summary>
|
|
/// <param name="startTime">开始时间</param>
|
|
/// <param name="endTime">结束时间</param>
|
|
private void SetForm(string startTime, string endTime)
|
|
{
|
|
if (LogForm != null)
|
|
{
|
|
LogForm.BaseControl.BindDataSource = null;
|
|
LogForm.BaseControl.BindDataSource = LjLogControl.ManualLogSelect(startTime, endTime);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|