|
|
using AUCMA.STORE.Business.Implements;
|
|
|
using AUCMA.STORE.Business.Interface;
|
|
|
using AUCMA.STORE.Common;
|
|
|
using AUCMA.STORE.Entity.DAO;
|
|
|
using AUCMA.STORE.Entity.DTO;
|
|
|
using AUCMA.STORE.Entity.Enums;
|
|
|
using AUCMA.STORE.SqlSugar.serviceImpl;
|
|
|
using AutoMapper;
|
|
|
using HslCommunication;
|
|
|
using HslCommunication.Core;
|
|
|
using HslCommunication.Profinet.Siemens;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
|
using System.Linq;
|
|
|
using System.Linq.Expressions;
|
|
|
using System.Runtime.InteropServices;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Web.UI.WebControls;
|
|
|
using System.Windows.Forms;
|
|
|
using Button = System.Windows.Forms.Button;
|
|
|
using Label = System.Windows.Forms.Label;
|
|
|
|
|
|
namespace AUCMA.STORE
|
|
|
{
|
|
|
public partial class InStore : Form
|
|
|
{
|
|
|
SiemensS7Net s7;
|
|
|
SiemensS7Net RGV_s7;
|
|
|
private static PLCAddressTypeDTO[] WriteOnePilerPlcAddress = new PLCAddressTypeDTO[20];
|
|
|
private static PLCAddressTypeDTO[] ReadOnePilerPlcAddress = new PLCAddressTypeDTO[20];
|
|
|
private static PLCAddressTypeDTO[] WriteRGVPlcAddress = new PLCAddressTypeDTO[6];
|
|
|
//private static PLCAddressTypeDTO[] WriteSouthRGVPlcAddress = new PLCAddressTypeDTO[6];
|
|
|
private static PLCAddressTypeDTO[] ReadRGVPlcAddress = new PLCAddressTypeDTO[5];
|
|
|
//private static PLCAddressTypeDTO[] ReadSouthRGVPlcAddress = new PLCAddressTypeDTO[5];
|
|
|
private static PLCAddressTypeDTO[] UpLoadPilerPlcSignal = new PLCAddressTypeDTO[2];
|
|
|
private static PLCAddressTypeDTO[] UpLoadRGVPlcSignal = new PLCAddressTypeDTO[2];
|
|
|
private static PLCAddressTypeDTO[] UpLoadBarCodeSignal = new PLCAddressTypeDTO[2];
|
|
|
private static PLCAddressTypeDTO[] PLCHeartSendPackSignal = new PLCAddressTypeDTO[3];
|
|
|
private static PLCAlarmInfoDTO[] PilerPlcAlarmSignal = new PLCAlarmInfoDTO[32];
|
|
|
private static INIFile iNIFile = new INIFile(System.Environment.CurrentDirectory + "/PlcAddress/PlcAddress.InI");
|
|
|
public static string m_StoreCode = ConfigHelper.GetConfig("storeCode");
|
|
|
public String PilerInfo = "";
|
|
|
public TaskType TaskType = TaskType.InStore;
|
|
|
private System.Net.IPAddress address;
|
|
|
public InStoreForm inStoreForm = null;
|
|
|
private static IInStoreBusiness inStoreBusiness = new InStoreBusinessImpl();
|
|
|
private static IOutStoreBusiness outStoreBusiness = new OutStoreBusinessImpl();
|
|
|
private static IBaseTaskQueueBusiness baseTaskQueueBusiness = new BaseTaskQueueBusiness();
|
|
|
LocationArea locationArea = LocationArea.Location_NoCare;
|
|
|
private string Area = "";
|
|
|
private IByteTransform byteTransform = new RegularByteTransform();
|
|
|
public InStore()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
tabControl1.Font = new Font("宋体", 18);
|
|
|
this.StartPosition = FormStartPosition.CenterScreen;
|
|
|
this.WindowState = FormWindowState.Maximized; //最大化窗体
|
|
|
}
|
|
|
|
|
|
private async void CreateInStoreTask(string code,string materialType)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
//取库位
|
|
|
Expression<Func<BaseLocationInfo, bool>> exp = s1 => true;
|
|
|
exp = exp.And(s1 => s1.locationArea == locationArea && s1.locationStatus == LocationStatus.UnUsed && s1.storeCode == ConfigHelper.GetConfig("storeCode") && s1.locationCode == code);
|
|
|
BaseLocationInfo baseLocationInfo = await new BaseServices<BaseLocationInfo>().QuerySingle(exp);
|
|
|
//取物料类型
|
|
|
BaseMaterialDTO baseMaterialDTO = new BaseMaterialDTO();
|
|
|
baseMaterialDTO.materialCode = materialType;
|
|
|
baseMaterialDTO.materialName = materialType;
|
|
|
TaskDTO inStoreTask = new TaskDTO();
|
|
|
|
|
|
//创建入库任务
|
|
|
inStoreTask = await inStoreBusiness.CreateInStoreTask(baseLocationInfo, baseMaterialDTO,OperationType.ManualOperation);
|
|
|
|
|
|
if (inStoreTask.taskCode != null)
|
|
|
{
|
|
|
//inStoreTask.operationType = OperationType.ManualOperation;
|
|
|
InStoreForm.inStoreTaskList.Add(inStoreTask);
|
|
|
inStoreForm.RefreshMessageListBox("入库任务创建完成,任务号:" + inStoreTask.taskCode + ";物料类别:" + inStoreTask.materialCode + ";库位:" + inStoreTask.locationCode + ";库位区域:" + inStoreTask.locationArea);
|
|
|
inStoreForm.Fresh_TaskInfo_dgv(inStoreTask);
|
|
|
bool occupyLocation = await inStoreBusiness.updateLocationStatus(LocationStatus.Occupy, inStoreTask);
|
|
|
string info = "入库任务下发完成:" + inStoreTask.taskCode + ";PLC编号:" + inStoreTask.pilerCode;
|
|
|
//MessageListBox.BeginInvoke(new System.EventHandler(UpdateUIText), info);
|
|
|
////创建待入库记录
|
|
|
int createPrepareInStoreResult = await inStoreBusiness.CreatePrepareInStore(inStoreTask);
|
|
|
}
|
|
|
Mapper.Initialize(cret => cret.CreateMap<TaskDTO, PlcDirectiveDTO>());
|
|
|
PlcDirectiveDTO plcDirectiveDTO = Mapper.Map<PlcDirectiveDTO>(inStoreTask);
|
|
|
plcDirectiveDTO.plcCode =(ushort)Convert.ToUInt32(inStoreTask.pilerCode);
|
|
|
|
|
|
inStoreTask.plcCode = plcDirectiveDTO.plcCode;
|
|
|
|
|
|
|
|
|
//int key = Convert.ToInt32(DateTime.Now.ToString("MMddHHmmss"));
|
|
|
//if (CreateInStoreTasktoPLC(plcDirectiveDTO))
|
|
|
//if (TaskDictionary.writeOtherTask(key, plcDirectiveDTO))
|
|
|
LogHelper.Info("即将下发入库任务,记录时间:" + DateTime.Now);
|
|
|
if (await baseTaskQueueBusiness.WriteTaskQueue(inStoreTask) == 1)
|
|
|
{
|
|
|
LogHelper.Info("下发入库任务完成,记录时间:" + DateTime.Now);
|
|
|
|
|
|
//RecordDirectiveOperation recordDirectiveOperation = new RecordDirectiveOperation();
|
|
|
//recordDirectiveOperation.deviceCode = inStoreTask.pilerCode.ToString();
|
|
|
//recordDirectiveOperation.taskCode = plcDirectiveDTO.pilerTaskCode.ToString();
|
|
|
//recordDirectiveOperation.directiveAddress = "DB11.0";
|
|
|
//recordDirectiveOperation.directiveName = "";
|
|
|
//recordDirectiveOperation.operationValue = JsonChange.ModeToJson(inStoreTask);
|
|
|
////1写入;0读取
|
|
|
//recordDirectiveOperation.operationType = OperationType.Automatic;
|
|
|
//recordDirectiveOperation.taskType = (TaskType)plcDirectiveDTO.pilerTaskType;
|
|
|
//recordDirectiveOperation.recordTime = DateTime.Now;
|
|
|
//recordDirectiveOperation.storeCode = m_StoreCode;
|
|
|
//_ = inStoreBusiness.SaveInStoreDirecticeOperation(recordDirectiveOperation);
|
|
|
//改库位实时记录表信息
|
|
|
_ = Task.Run(async delegate
|
|
|
{
|
|
|
LogHelper.Info("即将入库记录,记录时间:" + DateTime.Now);
|
|
|
|
|
|
_ = UpdateStoreAreaMaterialTypeAsync();
|
|
|
LogHelper.Info("创建入库记录完成,记录时间:" + DateTime.Now);
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error("CreateInStoreTask方法异常" + ex.ToString());
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
private async Task UpdateStoreAreaMaterialTypeAsync()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
Expression<Func<RealStoreAreaMaterialTypeInfo, bool>> expinfo = s1 => true;
|
|
|
expinfo = expinfo.And(s1 => s1.storeCode == ConfigHelper.GetConfig("storeCode") && s1.locationArea == locationArea);
|
|
|
var StoreAreaMaterialTypeList = await new BaseServices<RealStoreAreaMaterialTypeInfo>().QuerySingle(expinfo);
|
|
|
|
|
|
//库表为0则新增
|
|
|
if (StoreAreaMaterialTypeList == null)
|
|
|
{
|
|
|
RealStoreAreaMaterialTypeInfo realStoreAreaMaterialTypeInfo = new RealStoreAreaMaterialTypeInfo();
|
|
|
realStoreAreaMaterialTypeInfo.uuid = Guid.NewGuid().ToString("N");
|
|
|
realStoreAreaMaterialTypeInfo.detialMaterialCode = label2.Text;
|
|
|
realStoreAreaMaterialTypeInfo.detialMaterialName = label3.Text;
|
|
|
realStoreAreaMaterialTypeInfo.recordTime = DateTime.Now;
|
|
|
realStoreAreaMaterialTypeInfo.storeCode = ConfigHelper.GetConfig("storeCode");
|
|
|
realStoreAreaMaterialTypeInfo.locationArea = locationArea;
|
|
|
|
|
|
await new BaseServices<RealStoreAreaMaterialTypeInfo>().Add(realStoreAreaMaterialTypeInfo);
|
|
|
}
|
|
|
//库表为1则更新
|
|
|
else if(StoreAreaMaterialTypeList != null)
|
|
|
{
|
|
|
StoreAreaMaterialTypeList.detialMaterialCode = label2.Text;
|
|
|
StoreAreaMaterialTypeList.detialMaterialName = label3.Text;
|
|
|
StoreAreaMaterialTypeList.recordTime = DateTime.Now;
|
|
|
await new BaseServices<RealStoreAreaMaterialTypeInfo>().Update(StoreAreaMaterialTypeList);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void btn_Cancle_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
//if (inStoreForm != null && inStoreForm.iFlag)
|
|
|
//{
|
|
|
// inStoreForm.iFlag = false;
|
|
|
//}
|
|
|
LogHelper.Info("即将断开PLC连接,记录时间:" + DateTime.Now);
|
|
|
s7.ConnectCloseAsync();
|
|
|
LogHelper.Info("完成断开PLC连接,记录时间:" + DateTime.Now);
|
|
|
//if (TaskType == TaskType.OutStore)
|
|
|
//{
|
|
|
// RGV_s7.ConnectCloseAsync();
|
|
|
//}
|
|
|
this.Close();
|
|
|
}
|
|
|
private async void LoadPilerInfo()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (!HslCommunication.Authorization.SetAuthorizationCode("30c15272-3960-4853-9fab-3087392ee5cd"))
|
|
|
{
|
|
|
Console.WriteLine("Authorization failed! The current program can only be used for 8 hours!");
|
|
|
return; // 激活失败应该退出系统
|
|
|
}
|
|
|
s7 = new SiemensS7Net(SiemensPLCS.S1200);
|
|
|
if (PilerInfo == "1")
|
|
|
{
|
|
|
locationArea = LocationArea.Location_Left;
|
|
|
Area = "左";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
locationArea = LocationArea.Location_Right;
|
|
|
Area = "右";
|
|
|
}
|
|
|
Expression<Func<BasePlcInfo, bool>> exp = s1 => true;
|
|
|
exp = exp.And(x => x.storeCode == m_StoreCode && x.plcArea == locationArea);
|
|
|
List<BasePlcInfo> basePlcInfos = new BaseServices<BasePlcInfo>().QueryList(exp);
|
|
|
string[] split = basePlcInfos[0].plcAddress.Split(new Char[] { ':' });
|
|
|
|
|
|
if (!System.Net.IPAddress.TryParse(split[0], out address))
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
string m_strIp = split[0];
|
|
|
s7.IpAddress = m_strIp;
|
|
|
OperateResult connect = await s7.ConnectServerAsync().ConfigureAwait(false);
|
|
|
if (connect.IsSuccess)
|
|
|
{
|
|
|
//Console.Write("");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//MessageBox.Show("1#堆垛机连接失败,请检查网络!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
return;
|
|
|
}
|
|
|
//await Task.Delay(10);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Console.Write("Failed:" + HslCommunication.BasicFramework.SoftBasic.GetExceptionMessage(ex));
|
|
|
}
|
|
|
}
|
|
|
private async void LoadRGVInfo()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
RGV_s7 = new SiemensS7Net(SiemensPLCS.S1500);
|
|
|
Expression<Func<BasePlcInfo, bool>> rgvexp = s1 => true;
|
|
|
rgvexp = rgvexp.And(x => x.storeCode == m_StoreCode && x.plcArea == LocationArea.Location_NoCare && x.plcType == "S1500");
|
|
|
List<BasePlcInfo> baseRGVPlcInfos = new BaseServices<BasePlcInfo>().QueryList(rgvexp);
|
|
|
string[] rgvsplit = baseRGVPlcInfos[0].plcAddress.Split(new Char[] { ':' });
|
|
|
string m_rgvstrIp = rgvsplit[0];
|
|
|
RGV_s7.IpAddress = m_rgvstrIp;
|
|
|
OperateResult connect = await RGV_s7.ConnectServerAsync().ConfigureAwait(false);
|
|
|
if (connect.IsSuccess)
|
|
|
{
|
|
|
//Console.Write("");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//MessageBox.Show("RGV连接失败,请检查网络!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
Console.Write("Failed:" + HslCommunication.BasicFramework.SoftBasic.GetExceptionMessage(ex));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void InStore_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
this.MaximizeBox = false;
|
|
|
this.MinimizeBox = false;
|
|
|
//inStoreForm.iFlag = true;
|
|
|
if (m_StoreCode != "A" && m_StoreCode != "B")
|
|
|
{
|
|
|
m_StoreCode = "A";
|
|
|
}
|
|
|
flowLayoutPanel1.AutoScroll = true;
|
|
|
flowLayoutPanel2.AutoScroll = true;
|
|
|
flowLayoutPanel1.BackColor = Color.FromArgb(3, 27, 61);
|
|
|
flowLayoutPanel2.BackColor = Color.FromArgb(3, 27, 61);
|
|
|
|
|
|
LoadPlcAddressInfo();
|
|
|
LoadPilerInfo();
|
|
|
LoadRGVInfo();
|
|
|
//if (TaskType == TaskType.OutStore)
|
|
|
//{
|
|
|
// LoadRGVInfo();
|
|
|
//}
|
|
|
LoadStoreInfo();
|
|
|
LoadStoreAreaMaterialType();
|
|
|
}
|
|
|
private async void LoadStoreAreaMaterialType()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
Expression<Func<RealStoreAreaMaterialTypeInfo, bool>> expinfo = s1 => true;
|
|
|
expinfo = expinfo.And(s1 => s1.storeCode == ConfigHelper.GetConfig("storeCode") && s1.locationArea == locationArea);
|
|
|
var StoreAreaMaterialTypeList = await new BaseServices<RealStoreAreaMaterialTypeInfo>().QuerySingle(expinfo);
|
|
|
if (StoreAreaMaterialTypeList != null)
|
|
|
{
|
|
|
label2.Text = StoreAreaMaterialTypeList.detialMaterialCode ;
|
|
|
label3.Text = StoreAreaMaterialTypeList.detialMaterialName;
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void LoadPlcAddressInfo()
|
|
|
{
|
|
|
#region PLC心跳监测地址
|
|
|
PLCHeartSendPackSignal[0] = new PLCAddressTypeDTO("RGVPLC心跳地址", iNIFile.IniReadValue("PLC心跳地址", "RGVPLC心跳地址"), false);
|
|
|
PLCHeartSendPackSignal[1] = new PLCAddressTypeDTO("堆垛机PLC心跳地址", iNIFile.IniReadValue("PLC心跳地址", "堆垛机PLC心跳地址"), false);
|
|
|
PLCHeartSendPackSignal[2] = new PLCAddressTypeDTO("机械手PLC心跳地址", iNIFile.IniReadValue("PLC心跳地址", "机械手PLC心跳地址"), false);
|
|
|
#endregion
|
|
|
#region 加载堆垛机写入信号表
|
|
|
WriteOnePilerPlcAddress[0] = new PLCAddressTypeDTO("1#堆垛机任务号", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#堆垛机任务号"), false);
|
|
|
WriteOnePilerPlcAddress[1] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#堆垛机任务类型"), false);
|
|
|
WriteOnePilerPlcAddress[2] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#入库站台号"), false);
|
|
|
WriteOnePilerPlcAddress[3] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#取货巷道"), false);
|
|
|
WriteOnePilerPlcAddress[4] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#卸货巷道"), false);
|
|
|
WriteOnePilerPlcAddress[5] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#出库站台号"), false);
|
|
|
WriteOnePilerPlcAddress[6] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#堆垛机取货排"), false);
|
|
|
WriteOnePilerPlcAddress[7] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#堆垛机取货列"), false);
|
|
|
WriteOnePilerPlcAddress[8] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#堆垛机取货层"), false);
|
|
|
WriteOnePilerPlcAddress[9] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#堆垛机卸货排"), false);
|
|
|
WriteOnePilerPlcAddress[10] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#堆垛机卸货列"), false);
|
|
|
WriteOnePilerPlcAddress[11] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#堆垛机卸货层"), false);
|
|
|
WriteOnePilerPlcAddress[12] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#货物尺寸"), false);
|
|
|
WriteOnePilerPlcAddress[13] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#货物高度"), false);
|
|
|
WriteOnePilerPlcAddress[14] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#货物重量"), false);
|
|
|
WriteOnePilerPlcAddress[15] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#托盘号"), false);
|
|
|
WriteOnePilerPlcAddress[16] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#取放车"), false);
|
|
|
WriteOnePilerPlcAddress[17] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#指令校验"), false);
|
|
|
WriteOnePilerPlcAddress[18] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "1#堆垛机可以出叉"), false);
|
|
|
WriteOnePilerPlcAddress[19] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#写入堆垛机PLC地址", "系统急停"), false);
|
|
|
#endregion
|
|
|
#region 加载堆垛机读取信号表
|
|
|
ReadOnePilerPlcAddress[0] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机反馈任务号"));
|
|
|
ReadOnePilerPlcAddress[1] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机反馈任务类型"));
|
|
|
ReadOnePilerPlcAddress[2] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机当前状态"));
|
|
|
ReadOnePilerPlcAddress[3] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机是否联机"), false);
|
|
|
ReadOnePilerPlcAddress[4] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机是否有货"), false);
|
|
|
ReadOnePilerPlcAddress[5] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机当前排"), false);
|
|
|
ReadOnePilerPlcAddress[6] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机当前列"), false);
|
|
|
ReadOnePilerPlcAddress[7] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机当前层"), false);
|
|
|
ReadOnePilerPlcAddress[8] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机准备就绪"), false);
|
|
|
ReadOnePilerPlcAddress[9] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机心跳"), false);
|
|
|
ReadOnePilerPlcAddress[10] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机申请出叉"), false);
|
|
|
ReadOnePilerPlcAddress[11] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#任务取消"), false);
|
|
|
ReadOnePilerPlcAddress[12] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机收叉到位"), false);
|
|
|
ReadOnePilerPlcAddress[13] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机所在巷道"), false);
|
|
|
ReadOnePilerPlcAddress[14] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#托盘号"), false);
|
|
|
ReadOnePilerPlcAddress[15] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#托盘长短"), false);
|
|
|
ReadOnePilerPlcAddress[16] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#托盘高度"), false);
|
|
|
ReadOnePilerPlcAddress[17] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#托盘重量"), false);
|
|
|
ReadOnePilerPlcAddress[18] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机故障码1"), false);
|
|
|
ReadOnePilerPlcAddress[19] = new PLCAddressTypeDTO("", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "堆垛机故障码2"), false);
|
|
|
#endregion
|
|
|
#region 加载RGV信号地址表
|
|
|
//0924测试B库,实际m_StoreCode:B;暂时修改m_StoreCode:A
|
|
|
if (m_StoreCode == "B")
|
|
|
{
|
|
|
#region 加载南库RGV写入信号表
|
|
|
WriteRGVPlcAddress[0] = new PLCAddressTypeDTO("D区进库到位上传反馈1", iNIFile.IniReadValue("南库写入RGVPLC地址", "D区进库到位上传反馈1"));
|
|
|
WriteRGVPlcAddress[1] = new PLCAddressTypeDTO("D区进库到位上传反馈2", iNIFile.IniReadValue("南库写入RGVPLC地址", "D区进库到位上传反馈2"));
|
|
|
WriteRGVPlcAddress[2] = new PLCAddressTypeDTO("D区出库皮带有料上传反馈1", iNIFile.IniReadValue("南库写入RGVPLC地址", "D区出库皮带有料上传反馈1"));
|
|
|
WriteRGVPlcAddress[3] = new PLCAddressTypeDTO("D区出库皮带有料上传反馈2", iNIFile.IniReadValue("南库写入RGVPLC地址", "D区出库皮带有料上传反馈2"));
|
|
|
WriteRGVPlcAddress[4] = new PLCAddressTypeDTO("D区下传出库任务号", iNIFile.IniReadValue("南库写入RGVPLC地址", "D区下传出库任务号"));
|
|
|
WriteRGVPlcAddress[5] = new PLCAddressTypeDTO("D区下传出库站号", iNIFile.IniReadValue("南库写入RGVPLC地址", "D区下传出库站号"));
|
|
|
#endregion
|
|
|
#region 加载南库RGV读取信号
|
|
|
ReadRGVPlcAddress[0] = new PLCAddressTypeDTO("D区进库到位上传1", iNIFile.IniReadValue("南库读取RGVPLC地址", "D区进库到位上传1"));
|
|
|
ReadRGVPlcAddress[1] = new PLCAddressTypeDTO("D区进库到位上传2", iNIFile.IniReadValue("南库读取RGVPLC地址", "D区进库到位上传2"));
|
|
|
ReadRGVPlcAddress[2] = new PLCAddressTypeDTO("D区出库皮带有料上传1", iNIFile.IniReadValue("南库读取RGVPLC地址", "D区出库皮带有料上传1"));
|
|
|
ReadRGVPlcAddress[3] = new PLCAddressTypeDTO("D区出库皮带有料上传2", iNIFile.IniReadValue("南库读取RGVPLC地址", "D区出库皮带有料上传2"));
|
|
|
ReadRGVPlcAddress[4] = new PLCAddressTypeDTO("D区下传出库任务号反馈", iNIFile.IniReadValue("南库读取RGVPLC地址", "D区下传出库任务号反馈"));
|
|
|
#endregion
|
|
|
#region 上传RGV信号
|
|
|
UpLoadRGVPlcSignal[0] = new PLCAddressTypeDTO("D区进库到位上传1", iNIFile.IniReadValue("南库读取RGVPLC地址", "D区进库到位上传1"));
|
|
|
UpLoadRGVPlcSignal[1] = new PLCAddressTypeDTO("D区进库到位上传2", iNIFile.IniReadValue("南库读取RGVPLC地址", "D区进库到位上传2"));
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
#region 加载北库RGV写入信号表
|
|
|
WriteRGVPlcAddress[0] = new PLCAddressTypeDTO("C区进库到位上传反馈1", iNIFile.IniReadValue("北库写入RGVPLC地址", "C区进库到位上传反馈1"));
|
|
|
WriteRGVPlcAddress[1] = new PLCAddressTypeDTO("C区进库到位上传反馈2", iNIFile.IniReadValue("北库写入RGVPLC地址", "C区进库到位上传反馈2"));
|
|
|
WriteRGVPlcAddress[2] = new PLCAddressTypeDTO("C区出库皮带有料上传反馈1", iNIFile.IniReadValue("北库写入RGVPLC地址", "C区出库皮带有料上传反馈1"));
|
|
|
WriteRGVPlcAddress[3] = new PLCAddressTypeDTO("C区出库皮带有料上传反馈2", iNIFile.IniReadValue("北库写入RGVPLC地址", "C区出库皮带有料上传反馈2"));
|
|
|
WriteRGVPlcAddress[4] = new PLCAddressTypeDTO("C区下传出库任务号", iNIFile.IniReadValue("北库写入RGVPLC地址", "C区下传出库任务号"));
|
|
|
WriteRGVPlcAddress[5] = new PLCAddressTypeDTO("C区下传出库站号", iNIFile.IniReadValue("北库写入RGVPLC地址", "C区下传出库站号"));
|
|
|
#endregion
|
|
|
#region 加载北库RGV读取信号表
|
|
|
ReadRGVPlcAddress[0] = new PLCAddressTypeDTO("C区进库到位上传1", iNIFile.IniReadValue("北库读取RGVPLC地址", "C区进库到位上传1"));
|
|
|
ReadRGVPlcAddress[1] = new PLCAddressTypeDTO("C区进库到位上传2", iNIFile.IniReadValue("北库读取RGVPLC地址", "C区进库到位上传2"));
|
|
|
ReadRGVPlcAddress[2] = new PLCAddressTypeDTO("C区出库皮带有料上传1", iNIFile.IniReadValue("北库读取RGVPLC地址", "C区出库皮带有料上传1"));
|
|
|
ReadRGVPlcAddress[3] = new PLCAddressTypeDTO("C区出库皮带有料上传2", iNIFile.IniReadValue("北库读取RGVPLC地址", "C区出库皮带有料上传2"));
|
|
|
ReadRGVPlcAddress[4] = new PLCAddressTypeDTO("C区下传出库任务号反馈", iNIFile.IniReadValue("北库读取RGVPLC地址", "C区下传出库任务号反馈"));
|
|
|
#endregion
|
|
|
#region 上传RGV信号
|
|
|
UpLoadRGVPlcSignal[0] = new PLCAddressTypeDTO("C区进库到位上传1", iNIFile.IniReadValue("北库读取RGVPLC地址", "C区进库到位上传1"));
|
|
|
UpLoadRGVPlcSignal[1] = new PLCAddressTypeDTO("C区进库到位上传2", iNIFile.IniReadValue("北库读取RGVPLC地址", "C区进库到位上传2"));
|
|
|
#endregion
|
|
|
}
|
|
|
#endregion
|
|
|
#region 上传RGV信号区分位置
|
|
|
//上传
|
|
|
UpLoadRGVPlcSignal[0].Area = 1;
|
|
|
UpLoadRGVPlcSignal[1].Area = 2;
|
|
|
#endregion
|
|
|
#region 上传堆垛机信号
|
|
|
UpLoadPilerPlcSignal[0] = new PLCAddressTypeDTO("1#堆垛机当前状态", iNIFile.IniReadValue("1#读取堆垛机PLC地址", "1#堆垛机当前状态"));
|
|
|
UpLoadPilerPlcSignal[1] = new PLCAddressTypeDTO("2#堆垛机当前状态", iNIFile.IniReadValue("2#读取堆垛机PLC地址", "2#堆垛机当前状态"));
|
|
|
#endregion
|
|
|
#region 1#箱体条码PLC
|
|
|
UpLoadBarCodeSignal[0] = new PLCAddressTypeDTO("1#获取箱体码", iNIFile.IniReadValue("1#箱体码PLC地址", "1#条码状态字"));
|
|
|
UpLoadBarCodeSignal[1] = new PLCAddressTypeDTO("1#获取箱体码", iNIFile.IniReadValue("1#箱体码PLC地址", "1#获取箱体码"));
|
|
|
#endregion
|
|
|
#region 堆垛机故障信号
|
|
|
PilerPlcAlarmSignal[0] = new PLCAlarmInfoDTO("行走限位", iNIFile.IniReadValue("堆垛机故障报警地址", "行走限位 "));
|
|
|
PilerPlcAlarmSignal[1] = new PLCAlarmInfoDTO("提升限位", iNIFile.IniReadValue("堆垛机故障报警地址", "提升限位"));
|
|
|
PilerPlcAlarmSignal[2] = new PLCAlarmInfoDTO("超高", iNIFile.IniReadValue("堆垛机故障报警地址", "超高"));
|
|
|
PilerPlcAlarmSignal[3] = new PLCAlarmInfoDTO("超宽", iNIFile.IniReadValue("堆垛机故障报警地址", "超宽"));
|
|
|
PilerPlcAlarmSignal[4] = new PLCAlarmInfoDTO("塌陷", iNIFile.IniReadValue("堆垛机故障报警地址", "塌陷"));
|
|
|
PilerPlcAlarmSignal[5] = new PLCAlarmInfoDTO("空出叉", iNIFile.IniReadValue("堆垛机故障报警地址", "空出叉"));
|
|
|
PilerPlcAlarmSignal[6] = new PLCAlarmInfoDTO("满叉", iNIFile.IniReadValue("堆垛机故障报警地址", "满叉"));
|
|
|
PilerPlcAlarmSignal[7] = new PLCAlarmInfoDTO("货叉运行超时", iNIFile.IniReadValue("堆垛机故障报警地址", "货叉运行超时"));
|
|
|
PilerPlcAlarmSignal[8] = new PLCAlarmInfoDTO("行走运行超时", iNIFile.IniReadValue("堆垛机故障报警地址", "行走运行超时"));
|
|
|
PilerPlcAlarmSignal[9] = new PLCAlarmInfoDTO("提升运行超时", iNIFile.IniReadValue("堆垛机故障报警地址", "提升运行超时"));
|
|
|
PilerPlcAlarmSignal[10] = new PLCAlarmInfoDTO("行走定位超差", iNIFile.IniReadValue("堆垛机故障报警地址", "行走定位超差"));
|
|
|
PilerPlcAlarmSignal[11] = new PLCAlarmInfoDTO("提升定位超差", iNIFile.IniReadValue("堆垛机故障报警地址", "提升定位超差"));
|
|
|
PilerPlcAlarmSignal[12] = new PLCAlarmInfoDTO("列设定超范围", iNIFile.IniReadValue("堆垛机故障报警地址", "列设定超范围"));
|
|
|
PilerPlcAlarmSignal[13] = new PLCAlarmInfoDTO("层设定超范围", iNIFile.IniReadValue("堆垛机故障报警地址", "层设定超范围"));
|
|
|
PilerPlcAlarmSignal[14] = new PLCAlarmInfoDTO("排设定超范围", iNIFile.IniReadValue("堆垛机故障报警地址", "排设定超范围"));
|
|
|
PilerPlcAlarmSignal[15] = new PLCAlarmInfoDTO("松绳", iNIFile.IniReadValue("堆垛机故障报警地址", "松绳"));
|
|
|
PilerPlcAlarmSignal[16] = new PLCAlarmInfoDTO("超重", iNIFile.IniReadValue("堆垛机故障报警地址", "超重"));
|
|
|
PilerPlcAlarmSignal[17] = new PLCAlarmInfoDTO("货叉限位", iNIFile.IniReadValue("堆垛机故障报警地址", "货叉限位"));
|
|
|
PilerPlcAlarmSignal[18] = new PLCAlarmInfoDTO("紧急停止", iNIFile.IniReadValue("堆垛机故障报警地址", "紧急停止"));
|
|
|
PilerPlcAlarmSignal[19] = new PLCAlarmInfoDTO("货叉间距不对", iNIFile.IniReadValue("堆垛机故障报警地址", "货叉间距不对"));
|
|
|
PilerPlcAlarmSignal[20] = new PLCAlarmInfoDTO("升降失重", iNIFile.IniReadValue("堆垛机故障报警地址", "升降失重"));
|
|
|
PilerPlcAlarmSignal[21] = new PLCAlarmInfoDTO("提升激光丢失", iNIFile.IniReadValue("堆垛机故障报警地址", "提升激光丢失"));
|
|
|
PilerPlcAlarmSignal[22] = new PLCAlarmInfoDTO("行走激光丢失", iNIFile.IniReadValue("堆垛机故障报警地址", "行走激光丢失"));
|
|
|
|
|
|
PilerPlcAlarmSignal[23] = new PLCAlarmInfoDTO("上叉检测故障", iNIFile.IniReadValue("堆垛机故障报警地址", "上叉检测故障"));
|
|
|
PilerPlcAlarmSignal[24] = new PLCAlarmInfoDTO("起落叉超时故障", iNIFile.IniReadValue("堆垛机故障报警地址", "起落叉超时故障"));
|
|
|
PilerPlcAlarmSignal[25] = new PLCAlarmInfoDTO("给定位置错误", iNIFile.IniReadValue("堆垛机故障报警地址", "给定位置错误"));
|
|
|
PilerPlcAlarmSignal[26] = new PLCAlarmInfoDTO("行走变频器故障", iNIFile.IniReadValue("堆垛机故障报警地址", "行走变频器故障"));
|
|
|
PilerPlcAlarmSignal[27] = new PLCAlarmInfoDTO("提升变频器故障", iNIFile.IniReadValue("堆垛机故障报警地址", "提升变频器故障"));
|
|
|
PilerPlcAlarmSignal[28] = new PLCAlarmInfoDTO("货叉变频器故障", iNIFile.IniReadValue("堆垛机故障报警地址", "货叉变频器故障"));
|
|
|
PilerPlcAlarmSignal[29] = new PLCAlarmInfoDTO("在非对点位置伸叉", iNIFile.IniReadValue("堆垛机故障报警地址", "在非对点位置伸叉"));
|
|
|
PilerPlcAlarmSignal[30] = new PLCAlarmInfoDTO("货叉变频器故障", iNIFile.IniReadValue("堆垛机故障报警地址", "与地面站失联"));
|
|
|
PilerPlcAlarmSignal[31] = new PLCAlarmInfoDTO("料箱遮挡故障", iNIFile.IniReadValue("堆垛机故障报警地址", "料箱遮挡故障"));
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 向堆垛机下发入库任务
|
|
|
/// </summary>
|
|
|
/// <param name="taskDTO"></param>
|
|
|
/// <returns></returns>
|
|
|
private bool CreateInStoreTasktoPLC(PlcDirectiveDTO taskDTO)
|
|
|
{
|
|
|
bool bflag = false;
|
|
|
try
|
|
|
{
|
|
|
#region 将出库任务转换成字节发送
|
|
|
byte[] buffer = new byte[42];
|
|
|
taskDTO.inStorePlatformCode = 0;
|
|
|
taskDTO.claimGoods = 0;
|
|
|
taskDTO.unload = 0;
|
|
|
taskDTO.outStorePlatformCode = 0;
|
|
|
taskDTO.goodsSize = 0;
|
|
|
taskDTO.goodsHeight = 0;
|
|
|
taskDTO.goodsWeight = 0;
|
|
|
taskDTO.trayCode = 0;
|
|
|
taskDTO.takePutTheCar = 0;
|
|
|
taskDTO.verify = 0;
|
|
|
taskDTO.exitFork = 1;
|
|
|
byte[] taskNo = StringChange.intToBytesBig(taskDTO.pilerTaskCode);
|
|
|
taskNo.CopyTo(buffer, 0);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerTaskType).CopyTo(buffer, 4);
|
|
|
Array.Reverse(buffer, 4, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.inStorePlatformCode).CopyTo(buffer, 6);
|
|
|
Array.Reverse(buffer, 6, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.claimGoods).CopyTo(buffer, 8);
|
|
|
Array.Reverse(buffer, 8, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.unload).CopyTo(buffer, 10);
|
|
|
Array.Reverse(buffer, 10, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.outStorePlatformCode).CopyTo(buffer, 12);
|
|
|
Array.Reverse(buffer, 12, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerClaimGoodsRows).CopyTo(buffer, 14);
|
|
|
Array.Reverse(buffer, 14, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerClaimGoodsLine).CopyTo(buffer, 16);
|
|
|
Array.Reverse(buffer, 16, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerClaimGoodsTier).CopyTo(buffer, 18);
|
|
|
Array.Reverse(buffer, 18, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerUnloadRows).CopyTo(buffer, 20);
|
|
|
Array.Reverse(buffer, 20, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerUnloadLine).CopyTo(buffer, 22);
|
|
|
Array.Reverse(buffer, 22, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerUnloadTier).CopyTo(buffer, 24);
|
|
|
Array.Reverse(buffer, 24, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.goodsSize).CopyTo(buffer, 26);
|
|
|
Array.Reverse(buffer, 26, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.goodsHeight).CopyTo(buffer, 28);
|
|
|
Array.Reverse(buffer, 28, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.goodsWeight).CopyTo(buffer, 30);
|
|
|
Array.Reverse(buffer, 30, 2);
|
|
|
byteTransform.TransByte((int)taskDTO.trayCode).CopyTo(buffer, 32);
|
|
|
Array.Reverse(buffer, 32, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.takePutTheCar).CopyTo(buffer, 36);
|
|
|
Array.Reverse(buffer, 36, 2);
|
|
|
byteTransform.TransByte((byte)taskDTO.verify).CopyTo(buffer, 38);
|
|
|
Array.Reverse(buffer, 38, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.exitFork).CopyTo(buffer, 40);
|
|
|
Array.Reverse(buffer, 40, 2);
|
|
|
OperateResult write = s7.Write("DB11.0", buffer);
|
|
|
if (write.IsSuccess)
|
|
|
{
|
|
|
bflag = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
bflag = false;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
bflag = false;
|
|
|
}
|
|
|
return bflag;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 库位展示
|
|
|
/// </summary>
|
|
|
private async void LoadStoreInfo()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
Expression<Func<BaseLocationInfo, bool>> exp = s1 => true;
|
|
|
Expression<Func<BaseLocationInfo, object>> order = (x) => x.Ordernum;
|
|
|
exp = exp.And(s1 =>s1.locationArea == locationArea && s1.storeCode == ConfigHelper.GetConfig("storeCode"));
|
|
|
List<BaseLocationInfo> locations = await new BaseServices<BaseLocationInfo>().Query(exp,order,true);
|
|
|
LogHelper.Info(JsonChange.ModeToJson($"查询参数:{ConfigHelper.GetConfig("storeCode")};结果:{JsonChange.ModeToJson(locations)}"));
|
|
|
//var info = locations.OrderBy(x => x.remark).ToList();
|
|
|
locations.Add(new BaseLocationInfo("1-1-1",1, 1,1));
|
|
|
locations.Add(new BaseLocationInfo("1-1-2", 1,1,2));
|
|
|
locations.Add(new BaseLocationInfo("2-1-1",2, 1, 1));
|
|
|
locations.Add(new BaseLocationInfo("2-1-2",2, 1, 2));
|
|
|
//将list中的每列数据进行反转倒序
|
|
|
List<BaseLocationInfo> baseLocationsDesc1 = new List<BaseLocationInfo>();
|
|
|
List<BaseLocationInfo> baseLocationsDesc2 = new List<BaseLocationInfo>();
|
|
|
List<int> locationLine = new List<int>();
|
|
|
var info = locations.GroupBy(x => x.locationLine).ToList();
|
|
|
foreach (var item in info)
|
|
|
{
|
|
|
locationLine.Add(item.Key);
|
|
|
}
|
|
|
|
|
|
locationLine.ForEach( x =>
|
|
|
{
|
|
|
var list = locations.Where(y => y.locationLine == x && y.locationRow == 1).ToList();
|
|
|
baseLocationsDesc1.AddRange(list.OrderByDescending(z => z.Ordernum).ToList());
|
|
|
var list2 = locations.Where(y => y.locationLine == x && y.locationRow == 2).ToList();
|
|
|
baseLocationsDesc2.AddRange(list2.OrderByDescending(z => z.Ordernum).ToList());
|
|
|
});
|
|
|
|
|
|
baseLocationsDesc1.ForEach(x =>
|
|
|
{
|
|
|
Button button = new Button();
|
|
|
if (x.locationLine == 2 || x.locationLine == 3 || x.locationLine == 4)
|
|
|
{
|
|
|
if (x.locationTier == 16)
|
|
|
{
|
|
|
this.flowLayoutPanel1.SetFlowBreak(button, true);
|
|
|
}
|
|
|
}
|
|
|
button = buttonStyle(x.locationCode, x.Ordernum, x.materialType, x.locationStatus);
|
|
|
flowLayoutPanel1.Controls.Add(button);
|
|
|
});
|
|
|
|
|
|
baseLocationsDesc2.ForEach(x =>
|
|
|
{
|
|
|
Button button = new Button();
|
|
|
if (x.locationLine == 2 || x.locationLine == 3 || x.locationLine == 4)
|
|
|
{
|
|
|
if (x.locationTier == 16)
|
|
|
{
|
|
|
this.flowLayoutPanel2.SetFlowBreak(button, true);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
button = buttonStyle(x.locationCode, x.Ordernum, x.materialType, x.locationStatus);
|
|
|
flowLayoutPanel2.Controls.Add(button);
|
|
|
});
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
MessageBox.Show("未查询到库位!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
this.Close();
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private async void numberButton_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
Button btn = sender as Button;
|
|
|
string locationStatus = "";
|
|
|
string materialType = "";
|
|
|
if (btn == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
foreach (Control a in btn.Controls)
|
|
|
{
|
|
|
if (a is Label)
|
|
|
{
|
|
|
if (a.Name.Equals("locationStatus"))
|
|
|
{
|
|
|
locationStatus = a.Text;
|
|
|
}
|
|
|
if (a.Name.Equals("materialType"))
|
|
|
{
|
|
|
materialType = a.Text.Substring(5);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//label2 = sender as Label;
|
|
|
//入库业务
|
|
|
if (TaskType == TaskType.InStore)
|
|
|
{
|
|
|
if (locationStatus != "空闲")
|
|
|
{
|
|
|
//String message = "库位状态:" + locationStatus + ",请重新选择库位!";
|
|
|
//MessageBox.Show(message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (label2.Text == "------")
|
|
|
{
|
|
|
MessageBox.Show("入库物料型号为空,请更改物料型号!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
return;
|
|
|
}
|
|
|
//判断入库口是否有物料
|
|
|
//if (ReadOutForkSignal())
|
|
|
//{
|
|
|
// MessageBox.Show("当前入库口无物料,请重试!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
// return;
|
|
|
//}
|
|
|
if (MessageBox.Show("请您确认是否入库(Y/N)", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
|
|
|
{
|
|
|
string materialTypeCode = label2.Text;
|
|
|
CreateInStoreTask(btn.Text, materialTypeCode);
|
|
|
LogHelper.Info("即将断开PLC连接,记录时间:" + DateTime.Now);
|
|
|
s7.ConnectCloseAsync();
|
|
|
LogHelper.Info("完成断开PLC连接,记录时间:" + DateTime.Now);
|
|
|
this.Close();
|
|
|
//btn_Cancle_Click(null, null);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//出库业务
|
|
|
else
|
|
|
{
|
|
|
if (locationStatus != "占用")
|
|
|
{
|
|
|
//String message = "库位状态:"+ locationStatus + ",请重新选择库位!";
|
|
|
//MessageBox.Show(message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (MessageBox.Show("请您确认是否出库(Y/N)", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
|
|
|
{
|
|
|
string code = materialType;
|
|
|
BaseMaterialInfo baseMaterialInfo = new BaseMaterialInfo();
|
|
|
baseMaterialInfo.materialCode = materialType;
|
|
|
baseMaterialInfo.materialType = materialType;
|
|
|
CreatOutStoreTask(btn.Text, baseMaterialInfo);
|
|
|
btn_Cancle_Click(null, null);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
}
|
|
|
private async void CreatOutStoreTask(string LocationCode, BaseMaterialInfo baseMaterialInfo)
|
|
|
{
|
|
|
PilerStatusDTO pilerStatus = new PilerStatusDTO();
|
|
|
pilerStatus.pilerCode = "1003";
|
|
|
pilerStatus.locationArea = locationArea;
|
|
|
Expression<Func<BaseLocationInfo, bool>> exp = s1 => true;
|
|
|
exp = exp.And(s1 => s1.materialType == baseMaterialInfo.materialCode && s1.locationArea == locationArea && s1.locationStatus == LocationStatus.InUse && s1.storeCode == ConfigHelper.GetConfig("storeCode") && s1.locationCode == LocationCode);
|
|
|
BaseLocationInfo LocationInfo = await new BaseServices<BaseLocationInfo>().QuerySingle(exp);
|
|
|
List<PilerStatusDTO> pilerStatusDTOs = new List<PilerStatusDTO>();
|
|
|
pilerStatusDTOs.Add(pilerStatus);
|
|
|
|
|
|
TaskDTO outStoreTask = await outStoreBusiness.CreateTask(LocationInfo, baseMaterialInfo,OperationType.ManualOperation);
|
|
|
//outStoreTask.operationType = OperationType.ManualOperation;
|
|
|
if (outStoreTask.taskCode != null)
|
|
|
{
|
|
|
InStoreForm.outStoreTaskList.Add(outStoreTask);
|
|
|
inStoreForm.Fresh_TaskInfo_dgv(outStoreTask);
|
|
|
Expression<Func<BasePlcInfo, bool>> exp1 = s1 => true;
|
|
|
exp1 = exp1.And(s1 => s1.plcArea == locationArea && s1.storeCode == ConfigHelper.GetConfig("storeCode") && s1.deleteFlag == DeleteFlag.No);
|
|
|
List<BasePlcInfo> basePlcInfos = await new BaseServices<BasePlcInfo>().Query(exp1);
|
|
|
outStoreTask.pilerCode = basePlcInfos.FirstOrDefault().plcCode.ToString();
|
|
|
Mapper.Initialize(cret => cret.CreateMap<TaskDTO, PlcDirectiveDTO>());
|
|
|
PlcDirectiveDTO plcDirectiveDTO = Mapper.Map<PlcDirectiveDTO>(outStoreTask);
|
|
|
|
|
|
if (CreateOutStoreTask(plcDirectiveDTO))
|
|
|
{
|
|
|
//CreateRGVTask();
|
|
|
|
|
|
inStoreForm.RefreshMessageListBox("出库任务下发完成:" + outStoreTask.taskCode + ";PLC编号:" + basePlcInfos.FirstOrDefault().plcCode);
|
|
|
|
|
|
//创建待出库记录
|
|
|
int createPrepareOutStoreResult = await outStoreBusiness.CreatePrepareOutStore(outStoreTask);
|
|
|
//task.taskStatus = Entity.Enums.TaskStatus.Being;
|
|
|
//FreshOutstoreTaskListView(task);
|
|
|
//更新出库任务状态
|
|
|
//InStoreListViewUpdate(task);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
private bool ReadOutForkSignal()
|
|
|
{
|
|
|
bool bflag = false;
|
|
|
try
|
|
|
{
|
|
|
OperateResult<short> ReadOutForkSignal = new OperateResult<short>();
|
|
|
if (PilerInfo == "1")
|
|
|
{
|
|
|
ReadOutForkSignal = RGV_s7.ReadInt16(ReadRGVPlcAddress[0].PLCAddress);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ReadOutForkSignal = RGV_s7.ReadInt16(ReadRGVPlcAddress[1].PLCAddress);
|
|
|
}
|
|
|
if (ReadOutForkSignal.IsSuccess)
|
|
|
{
|
|
|
if (ReadOutForkSignal.Content == 0)
|
|
|
{
|
|
|
bflag = true;
|
|
|
}
|
|
|
}
|
|
|
return bflag;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
return bflag;
|
|
|
}
|
|
|
}
|
|
|
private void CreateRGVTask()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
OperateResult writeTaskInfo = RGV_s7.Write(WriteRGVPlcAddress[4].PLCAddress, short.Parse("1"));
|
|
|
if (locationArea == LocationArea.Location_Left)
|
|
|
{
|
|
|
OperateResult writeStationID = RGV_s7.Write(WriteRGVPlcAddress[5].PLCAddress, short.Parse("1"));
|
|
|
inStoreForm.RefreshMessageListBox("站号:1,RGV取货任务下发完成!");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
OperateResult writeStationID = RGV_s7.Write(WriteRGVPlcAddress[5].PLCAddress, short.Parse("2"));
|
|
|
inStoreForm.RefreshMessageListBox("站号:2,RGV取货任务下发完成!");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 下发出库任务
|
|
|
/// </summary>
|
|
|
/// <param name="taskDTO"></param>
|
|
|
/// <returns></returns>
|
|
|
private bool CreateOutStoreTask(PlcDirectiveDTO taskDTO)
|
|
|
{
|
|
|
bool bflag = false;
|
|
|
try
|
|
|
{
|
|
|
#region 将出库任务转换成字节发送
|
|
|
byte[] buffer = new byte[42];
|
|
|
taskDTO.inStorePlatformCode = 0;
|
|
|
taskDTO.claimGoods = 0;
|
|
|
taskDTO.unload = 0;
|
|
|
taskDTO.outStorePlatformCode = 0;
|
|
|
taskDTO.goodsSize = 0;
|
|
|
taskDTO.goodsHeight = 0;
|
|
|
taskDTO.goodsWeight = 0;
|
|
|
taskDTO.trayCode = 0;
|
|
|
taskDTO.takePutTheCar = 0;
|
|
|
taskDTO.verify = 0;
|
|
|
taskDTO.exitFork = 1;
|
|
|
byte[] taskNo = StringChange.intToBytesBig(taskDTO.pilerTaskCode);
|
|
|
taskNo.CopyTo(buffer, 0);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerTaskType).CopyTo(buffer, 4);
|
|
|
Array.Reverse(buffer, 4, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.inStorePlatformCode).CopyTo(buffer, 6);
|
|
|
Array.Reverse(buffer, 6, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.claimGoods).CopyTo(buffer, 8);
|
|
|
Array.Reverse(buffer, 8, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.unload).CopyTo(buffer, 10);
|
|
|
Array.Reverse(buffer, 10, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.outStorePlatformCode).CopyTo(buffer, 12);
|
|
|
Array.Reverse(buffer, 12, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerClaimGoodsRows).CopyTo(buffer, 14);
|
|
|
Array.Reverse(buffer, 14, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerClaimGoodsLine).CopyTo(buffer, 16);
|
|
|
Array.Reverse(buffer, 16, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerClaimGoodsTier).CopyTo(buffer, 18);
|
|
|
Array.Reverse(buffer, 18, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerUnloadRows).CopyTo(buffer, 20);
|
|
|
Array.Reverse(buffer, 20, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerUnloadLine).CopyTo(buffer, 22);
|
|
|
Array.Reverse(buffer, 22, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.pilerUnloadTier).CopyTo(buffer, 24);
|
|
|
Array.Reverse(buffer, 24, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.goodsSize).CopyTo(buffer, 26);
|
|
|
Array.Reverse(buffer, 26, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.goodsHeight).CopyTo(buffer, 28);
|
|
|
Array.Reverse(buffer, 28, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.goodsWeight).CopyTo(buffer, 30);
|
|
|
Array.Reverse(buffer, 30, 2);
|
|
|
byteTransform.TransByte((int)taskDTO.trayCode).CopyTo(buffer, 32);
|
|
|
Array.Reverse(buffer, 32, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.takePutTheCar).CopyTo(buffer, 36);
|
|
|
Array.Reverse(buffer, 36, 2);
|
|
|
byteTransform.TransByte((byte)taskDTO.verify).CopyTo(buffer, 38);
|
|
|
Array.Reverse(buffer, 38, 2);
|
|
|
byteTransform.TransByte((short)taskDTO.exitFork).CopyTo(buffer, 40);
|
|
|
Array.Reverse(buffer, 40, 2);
|
|
|
OperateResult write = s7.Write("DB11.0", buffer);
|
|
|
if (write.IsSuccess)
|
|
|
{
|
|
|
bflag = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
bflag = false;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
bflag = false;
|
|
|
}
|
|
|
return bflag;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 利用button按钮实现仓库库位样式
|
|
|
/// </summary>
|
|
|
/// <param name="locationCode"></param>
|
|
|
/// <param name="ordernum"></param>
|
|
|
/// <param name="materialType"></param>
|
|
|
/// <param name="locationStatus"></param>
|
|
|
/// <returns></returns>
|
|
|
private Button buttonStyle(string locationCode, int ordernum, string materialType, LocationStatus locationStatus)
|
|
|
{
|
|
|
Label label1 = new Label();
|
|
|
Label label2 = new Label();
|
|
|
Rectangle ScreenArea = System.Windows.Forms.Screen.GetWorkingArea(this);
|
|
|
int width1 = ScreenArea.Width / 5 - 30; //屏幕宽度
|
|
|
int height1 = ScreenArea.Height / 21; //屏幕高度
|
|
|
|
|
|
Button button = new Button();
|
|
|
button.Margin = new Padding(5);
|
|
|
button.FlatStyle = FlatStyle.Flat;
|
|
|
button.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
|
|
|
button.Location = new System.Drawing.Point(3, 0);
|
|
|
button.Name = locationCode;
|
|
|
button.Size = new System.Drawing.Size(width1, height1);
|
|
|
button.TabIndex = 0;
|
|
|
|
|
|
button.Font = new Font("宋体", 15, FontStyle.Bold);
|
|
|
button.BackColor = Color.FromArgb(3, 27, 61);
|
|
|
button.ForeColor = Color.FromArgb(106, 203, 254);
|
|
|
button.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
|
|
button.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
|
|
|
|
Label label = new Label();
|
|
|
label.Font = new Font("宋体", 9, FontStyle.Regular);
|
|
|
label.Size = new System.Drawing.Size(130, 23);
|
|
|
label.Name = "materialType";
|
|
|
if (ordernum > 2)
|
|
|
{
|
|
|
button.Text = locationCode;
|
|
|
if (materialType.Length > 15)
|
|
|
{
|
|
|
label.Text = "物料型号:\r\n" + materialType;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
label.Text = "物料型号:" + materialType;
|
|
|
}
|
|
|
//button.Text = "型号:" + materialType + " " + locationCode;
|
|
|
button.Text = locationCode;
|
|
|
if (locationStatus == LocationStatus.InUse)
|
|
|
{
|
|
|
label2 = new Label();
|
|
|
label2.Font = new Font("宋体", 10, FontStyle.Regular);
|
|
|
label2.Size = new System.Drawing.Size(40, 15);
|
|
|
label2.Name = "locationStatus";
|
|
|
label2.BackColor = Color.Red;
|
|
|
label2.Text = "占用";
|
|
|
label2.Location = new Point(width1 - 100, 15);
|
|
|
}
|
|
|
else if (locationStatus == LocationStatus.UnUsed)
|
|
|
{
|
|
|
label2 = new Label();
|
|
|
label2.Font = new Font("宋体", 10, FontStyle.Regular);
|
|
|
label2.Size = new System.Drawing.Size(40, 15);
|
|
|
label2.Name = "locationStatus";
|
|
|
label2.BackColor = Color.Green;
|
|
|
label2.Text = "空闲";
|
|
|
label2.Location = new Point(width1 - 100, 15);
|
|
|
}
|
|
|
else if (locationStatus == LocationStatus.Occupy)
|
|
|
{
|
|
|
label2 = new Label();
|
|
|
label2.Font = new Font("宋体", 10, FontStyle.Regular);
|
|
|
label2.Size = new System.Drawing.Size(40, 15);
|
|
|
label2.Name = "locationStatus";
|
|
|
label2.BackColor = Color.Red;
|
|
|
label2.Text = "锁库";
|
|
|
label2.Location = new Point(width1 - 100, 15);
|
|
|
}
|
|
|
else if (locationStatus == LocationStatus.Anomaly)
|
|
|
{
|
|
|
label2 = new Label();
|
|
|
label2.Font = new Font("宋体", 10, FontStyle.Regular);
|
|
|
label2.Size = new System.Drawing.Size(40, 15);
|
|
|
label2.Name = "locationStatus";
|
|
|
label2.BackColor = Color.Red;
|
|
|
label2.Text = "异常";
|
|
|
label2.Location = new Point(width1 - 100, 15);
|
|
|
}
|
|
|
label.Location = new Point(12, 10);
|
|
|
label.BringToFront();
|
|
|
label2.BringToFront();
|
|
|
button.Click += numberButton_Click;
|
|
|
button.Controls.Add(label);
|
|
|
button.Controls.Add(label2);
|
|
|
|
|
|
}
|
|
|
return button;
|
|
|
}
|
|
|
public void RefreshMaterialType(string MaterialTypeCode,string MaterialTypeName)
|
|
|
{
|
|
|
label2.Text = MaterialTypeCode;
|
|
|
label3.Text = MaterialTypeName;
|
|
|
}
|
|
|
|
|
|
private void btn_MaterialType_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
ChangeMaterialType changeMaterialType = new ChangeMaterialType();
|
|
|
changeMaterialType.RecAutoDataAction = RefreshMaterialType;
|
|
|
changeMaterialType.ShowDialog(this);
|
|
|
}
|
|
|
}
|
|
|
}
|