using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Module.DB.Model; using Module.Common; namespace Module.Plc.Profinet.Tool { /// /// 匀胶单元应用 /// public class PlcCotManualUtils { private string FormatData(double number) { return Math.Round(Convert.ToDecimal(number), 2).ToString("#0.00"); } /// /// 保留一位小数 /// /// /// private string FormatDataOne(double number) { return Math.Round(Convert.ToDecimal(number), 1).ToString("#0.0"); } /// /// PLC读取通道1匀胶信息 /// /// public CotModel ReadT1CotModelInfo() { try { CotModel t1CotModelResult = null; if (PublicParams.T1ConnectPlc) { HslCommunication.OperateResult d1Result = PlcCommon.DeltaTcpNetClient01.Read("D20", 30); if (d1Result.IsSuccess) { t1CotModelResult = new CotModel(); t1CotModelResult.cotGuleArmBackHome = ByteConvert.ToInt16(d1Result.Content, 2) == 1; //PlcCommon.DeltaTcpNetClient01.ReadInt16("D21").Content == 1; t1CotModelResult.cotGuleArmPostionBackHome = ByteConvert.ToInt16(d1Result.Content, 56) == 1; //PlcCommon.DeltaTcpNetClient01.ReadInt16("D48").Content == 1; } HslCommunication.OperateResult d2Result = PlcCommon.DeltaTcpNetClient01.Read("D1710", 80); if (d2Result.IsSuccess) { if (t1CotModelResult == null) { t1CotModelResult = new CotModel(); } t1CotModelResult.cotSpindleBackHome = ByteConvert.ToInt16(d2Result.Content, 2); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1711").Content; t1CotModelResult.cotGlueArmBackHome = ByteConvert.ToInt16(d2Result.Content, 8); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1714").Content; t1CotModelResult.cotGuleArmManual = ByteConvert.ToInt16(d2Result.Content, 10); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1715").Content; t1CotModelResult.cotSpindleDisabled = ByteConvert.ToInt16(d2Result.Content, 12); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1716").Content; t1CotModelResult.cotVacuoSuction = ByteConvert.ToInt16(d2Result.Content, 20); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1720").Content; t1CotModelResult.cotHighSts = ByteConvert.ToInt16(d2Result.Content, 22); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1721").Content; t1CotModelResult.cotCenterSts = ByteConvert.ToInt16(d2Result.Content, 24); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1722").Content; t1CotModelResult.cotLowSts = ByteConvert.ToInt16(d2Result.Content, 26); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1723").Content; t1CotModelResult.cotSupportPieces = ByteConvert.ToInt16(d2Result.Content, 28); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1724").Content; t1CotModelResult.cotCentering = ByteConvert.ToInt16(d2Result.Content, 30); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1725").Content; t1CotModelResult.cotDropHeadDown = ByteConvert.ToInt16(d2Result.Content, 32); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1726").Content; t1CotModelResult.cotGuleCover = ByteConvert.ToInt16(d2Result.Content, 34); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1727").Content; t1CotModelResult.cotEbrSts = ByteConvert.ToInt16(d2Result.Content, 36); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1728").Content; t1CotModelResult.cotBsrSts = ByteConvert.ToInt16(d2Result.Content, 38); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1729").Content; t1CotModelResult.cotBsgr = ByteConvert.ToInt16(d2Result.Content, 40); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1730").Content; t1CotModelResult.cotCcr1 = ByteConvert.ToInt16(d2Result.Content, 42); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1731").Content; t1CotModelResult.cotCcr2 = ByteConvert.ToInt16(d2Result.Content, 44); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1732").Content; t1CotModelResult.cotRecipeleapfrog = ByteConvert.ToInt16(d2Result.Content, 62); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1741").Content; t1CotModelResult.cotWordAction = ByteConvert.ToInt16(d2Result.Content, 64); //PlcCommon.DeltaTcpNetClient01.ReadInt16("D1742").Content; t1CotModelResult.spindleCurrSpeed = ByteConvert.ToInt32(d2Result.Content, 80).ToString("0.0"); //D1750 t1CotModelResult.glueArmCurrPosition = Math.Round(Convert.ToDecimal(ByteConvert.ToInt32(d2Result.Content, 84) * 0.6 / 100.00), 2).ToString("#0.00"); //D1752 t1CotModelResult.spindleJogSpeed = FormatDataOne(ByteConvert.ToInt32(d2Result.Content, 104)); //D1760 t1CotModelResult.spindleBackHomeSpeed = FormatDataOne(ByteConvert.ToInt32(d2Result.Content, 108)); t1CotModelResult.spindleBackHomeOffset = FormatData(ByteConvert.ToInt32(d2Result.Content, 112) * 1 / 100.00); t1CotModelResult.glueArmSpeed = FormatData(ByteConvert.ToInt32(d2Result.Content, 116) * 1 / 1.00); t1CotModelResult.glueArmBackHomeSpeed = FormatData(ByteConvert.ToInt32(d2Result.Content, 120) * 1 / 1.00); t1CotModelResult.guleArmManualNote = FormatData(ByteConvert.ToInt32(d2Result.Content, 28) * 0.6 / 100.00); t1CotModelResult.guleArmManualNoteSpeed = FormatData(ByteConvert.ToInt32(d2Result.Content, 132) * 1 / 1.00); } HslCommunication.OperateResult x1Results = PlcCommon.DeltaTcpNetClient01.ReadBool("X0.0", 42); if (x1Results.IsSuccess) { if (t1CotModelResult == null) { t1CotModelResult = new CotModel(); } t1CotModelResult.cotSpindleAlarm = x1Results.Content[27]; t1CotModelResult.cotVacuumSignal = x1Results.Content[28]; t1CotModelResult.cotHigh = x1Results.Content[29]; t1CotModelResult.cotCenter = x1Results.Content[30]; t1CotModelResult.cotLow = x1Results.Content[31]; t1CotModelResult.cotSupportPiecesOriginal = x1Results.Content[32]; t1CotModelResult.cotSupportPiecesWork = x1Results.Content[33]; t1CotModelResult.cotCenteringWork = x1Results.Content[34]; t1CotModelResult.cotDropHeadDownHigh = x1Results.Content[35]; t1CotModelResult.cotDropHeadDownLow = x1Results.Content[36]; t1CotModelResult.cotRubberHigh = x1Results.Content[37]; t1CotModelResult.cotRubberLow = x1Results.Content[38]; } HslCommunication.OperateResult y1Results = PlcCommon.DeltaTcpNetClient01.ReadBool("Y0.0", 50); if (y1Results.IsSuccess) { if (t1CotModelResult == null) { t1CotModelResult = new CotModel(); } t1CotModelResult.cotSpindleParking = y1Results.Content[33]; t1CotModelResult.cotVacuumValve = y1Results.Content[34]; t1CotModelResult.cotHighValue = y1Results.Content[35]; t1CotModelResult.cotCenterValue = y1Results.Content[36]; t1CotModelResult.cotLowValue = y1Results.Content[37]; t1CotModelResult.cotSupportPiecesValue = y1Results.Content[38]; t1CotModelResult.cotCenteringValue = y1Results.Content[39]; t1CotModelResult.cotDropHeadDownValue = y1Results.Content[40]; t1CotModelResult.cotRubberValue = y1Results.Content[41]; t1CotModelResult.cotEbr = y1Results.Content[42]; t1CotModelResult.cotBsr = y1Results.Content[43]; t1CotModelResult.cotCcr = y1Results.Content[44]; t1CotModelResult.cotGuleArmJobA = y1Results.Content[45]; t1CotModelResult.cotGuleArmJobS = y1Results.Content[46]; t1CotModelResult.cotGuleArmHome = y1Results.Content[47]; t1CotModelResult.cotGuleArmCtrg = y1Results.Content[48]; t1CotModelResult.bsgr = PlcCommon.DeltaTcpNetClient01.ReadBool("Y2.12").Content; t1CotModelResult.ccr1 = PlcCommon.DeltaTcpNetClient01.ReadBool("Y4.14").Content; t1CotModelResult.ccr2 = PlcCommon.DeltaTcpNetClient01.ReadBool("Y4.15").Content; } } return t1CotModelResult; } catch (Exception ex) { ex.ToString(); return null; } } /// /// PLC读取通道2匀胶信息 /// /// public CotModel ReadT2CotModelInfo() { try { CotModel t2CotModelResult = null; if (PublicParams.T2ConnectPlc) { HslCommunication.OperateResult d1Result = PlcCommon.DeltaTcpNetClient02.Read("D20", 30); if (d1Result.IsSuccess) { t2CotModelResult = new CotModel(); t2CotModelResult.cotGuleArmBackHome = ByteConvert.ToInt16(d1Result.Content, 2) == 1; //PlcCommon.DeltaTcpNetClient02.ReadInt16("D21").Content == 1; t2CotModelResult.cotGuleArmPostionBackHome = ByteConvert.ToInt16(d1Result.Content, 56) == 1; //PlcCommon.DeltaTcpNetClient02.ReadInt16("D48").Content == 1; } HslCommunication.OperateResult d2Result = PlcCommon.DeltaTcpNetClient02.Read("D1710", 80); if (d2Result.IsSuccess) { if (t2CotModelResult == null) { t2CotModelResult = new CotModel(); } t2CotModelResult.cotSpindleBackHome = ByteConvert.ToInt16(d2Result.Content, 2); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1711").Content; t2CotModelResult.cotGlueArmBackHome = ByteConvert.ToInt16(d2Result.Content, 8); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1714").Content; t2CotModelResult.cotGuleArmManual = ByteConvert.ToInt16(d2Result.Content, 10); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1715").Content; t2CotModelResult.cotSpindleDisabled = ByteConvert.ToInt16(d2Result.Content, 12); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1716").Content; t2CotModelResult.cotVacuoSuction = ByteConvert.ToInt16(d2Result.Content, 20); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1720").Content; t2CotModelResult.cotHighSts = ByteConvert.ToInt16(d2Result.Content, 22); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1721").Content; t2CotModelResult.cotCenterSts = ByteConvert.ToInt16(d2Result.Content, 24); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1722").Content; t2CotModelResult.cotLowSts = ByteConvert.ToInt16(d2Result.Content, 26); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1723").Content; t2CotModelResult.cotSupportPieces = ByteConvert.ToInt16(d2Result.Content, 28); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1724").Content; t2CotModelResult.cotCentering = ByteConvert.ToInt16(d2Result.Content, 30); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1725").Content; t2CotModelResult.cotDropHeadDown = ByteConvert.ToInt16(d2Result.Content, 32); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1726").Content; t2CotModelResult.cotGuleCover = ByteConvert.ToInt16(d2Result.Content, 34); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1727").Content; t2CotModelResult.cotEbrSts = ByteConvert.ToInt16(d2Result.Content, 36); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1728").Content; t2CotModelResult.cotBsrSts = ByteConvert.ToInt16(d2Result.Content, 38); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1729").Content; t2CotModelResult.cotBsgr = ByteConvert.ToInt16(d2Result.Content, 40); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1730").Content; t2CotModelResult.cotCcr1 = ByteConvert.ToInt16(d2Result.Content, 42); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1731").Content; t2CotModelResult.cotCcr2 = ByteConvert.ToInt16(d2Result.Content, 44); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1732").Content; t2CotModelResult.cotRecipeleapfrog = ByteConvert.ToInt16(d2Result.Content, 62); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1741").Content; t2CotModelResult.cotWordAction = ByteConvert.ToInt16(d2Result.Content, 64); //PlcCommon.DeltaTcpNetClient02.ReadInt16("D1742").Content; t2CotModelResult.spindleCurrSpeed = ByteConvert.ToInt32(d2Result.Content, 80).ToString("0.0"); //D1750 t2CotModelResult.glueArmCurrPosition = Math.Round(Convert.ToDecimal(ByteConvert.ToInt32(d2Result.Content, 84) * 0.6 / 100.00), 2).ToString("#0.00"); //D1752 t2CotModelResult.spindleJogSpeed = FormatDataOne(ByteConvert.ToInt32(d2Result.Content, 104)); //D1760 t2CotModelResult.spindleBackHomeSpeed = FormatDataOne(ByteConvert.ToInt32(d2Result.Content, 108)); t2CotModelResult.spindleBackHomeOffset = FormatData(ByteConvert.ToInt32(d2Result.Content, 112) * 1 / 100.00); t2CotModelResult.glueArmSpeed = FormatData(ByteConvert.ToInt32(d2Result.Content, 116) * 1 / 1.00); t2CotModelResult.glueArmBackHomeSpeed = FormatData(ByteConvert.ToInt32(d2Result.Content, 120) * 1 / 1.00); t2CotModelResult.guleArmManualNote = FormatData(ByteConvert.ToInt32(d2Result.Content, 28) * 0.6 / 100.00); t2CotModelResult.guleArmManualNoteSpeed = FormatData(ByteConvert.ToInt32(d2Result.Content, 132) * 1 / 1.00); } HslCommunication.OperateResult x1Results = PlcCommon.DeltaTcpNetClient02.ReadBool("X0.0", 42); if (x1Results.IsSuccess) { if (t2CotModelResult == null) { t2CotModelResult = new CotModel(); } t2CotModelResult.cotSpindleAlarm = x1Results.Content[27]; t2CotModelResult.cotVacuumSignal = x1Results.Content[28]; t2CotModelResult.cotHigh = x1Results.Content[29]; t2CotModelResult.cotCenter = x1Results.Content[30]; t2CotModelResult.cotLow = x1Results.Content[31]; t2CotModelResult.cotSupportPiecesOriginal = x1Results.Content[32]; t2CotModelResult.cotSupportPiecesWork = x1Results.Content[33]; t2CotModelResult.cotCenteringWork = x1Results.Content[34]; t2CotModelResult.cotDropHeadDownHigh = x1Results.Content[35]; t2CotModelResult.cotDropHeadDownLow = x1Results.Content[36]; t2CotModelResult.cotRubberHigh = x1Results.Content[37]; t2CotModelResult.cotRubberLow = x1Results.Content[38]; } HslCommunication.OperateResult y1Results = PlcCommon.DeltaTcpNetClient02.ReadBool("Y0.0", 50); if (y1Results.IsSuccess) { if (t2CotModelResult == null) { t2CotModelResult = new CotModel(); } t2CotModelResult.cotSpindleParking = y1Results.Content[33]; t2CotModelResult.cotVacuumValve = y1Results.Content[34]; t2CotModelResult.cotHighValue = y1Results.Content[35]; t2CotModelResult.cotCenterValue = y1Results.Content[36]; t2CotModelResult.cotLowValue = y1Results.Content[37]; t2CotModelResult.cotSupportPiecesValue = y1Results.Content[38]; t2CotModelResult.cotCenteringValue = y1Results.Content[39]; t2CotModelResult.cotDropHeadDownValue = y1Results.Content[40]; t2CotModelResult.cotRubberValue = y1Results.Content[41]; t2CotModelResult.cotEbr = y1Results.Content[42]; t2CotModelResult.cotBsr = y1Results.Content[43]; t2CotModelResult.cotCcr = y1Results.Content[44]; t2CotModelResult.cotGuleArmJobA = y1Results.Content[45]; t2CotModelResult.cotGuleArmJobS = y1Results.Content[46]; t2CotModelResult.cotGuleArmHome = y1Results.Content[47]; t2CotModelResult.cotGuleArmCtrg = y1Results.Content[48]; t2CotModelResult.bsgr = PlcCommon.DeltaTcpNetClient02.ReadBool("Y2.12").Content; t2CotModelResult.ccr1 = PlcCommon.DeltaTcpNetClient02.ReadBool("Y4.14").Content; t2CotModelResult.ccr2 = PlcCommon.DeltaTcpNetClient02.ReadBool("Y4.15").Content; } } return t2CotModelResult; } catch (Exception ex) { ex.ToString(); return null; } } } }