Commit 0817341e LN

板卡连接方式修改。bug修改

1 个父辈 c4988849
...@@ -55,9 +55,6 @@ ...@@ -55,9 +55,6 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup /> <PropertyGroup />
<ItemGroup> <ItemGroup>
<Reference Include="Asa.RFID">
<HintPath>..\..\dll\RFID\Asa.RFID.dll</HintPath>
</Reference>
<Reference Include="Client"> <Reference Include="Client">
<HintPath>..\..\dll\Client.dll</HintPath> <HintPath>..\..\dll\Client.dll</HintPath>
</Reference> </Reference>
...@@ -79,7 +76,6 @@ ...@@ -79,7 +76,6 @@
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
...@@ -88,6 +84,12 @@ ...@@ -88,6 +84,12 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="FrmBase.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmBase.Designer.cs">
<DependentUpon>FrmBase.cs</DependentUpon>
</Compile>
<Compile Include="FrmHYEquip.cs"> <Compile Include="FrmHYEquip.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
...@@ -112,12 +114,6 @@ ...@@ -112,12 +114,6 @@
<Compile Include="useControl\AxisMoveControl.Designer.cs"> <Compile Include="useControl\AxisMoveControl.Designer.cs">
<DependentUpon>AxisMoveControl.cs</DependentUpon> <DependentUpon>AxisMoveControl.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="FrmBase.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmBase.Designer.cs">
<DependentUpon>FrmBase.cs</DependentUpon>
</Compile>
<Compile Include="FrmEquipBase.cs"> <Compile Include="FrmEquipBase.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
...@@ -169,6 +165,9 @@ ...@@ -169,6 +165,9 @@
<Compile Include="useControl\EquipControl.Designer.cs"> <Compile Include="useControl\EquipControl.Designer.cs">
<DependentUpon>EquipControl.cs</DependentUpon> <DependentUpon>EquipControl.cs</DependentUpon>
</Compile> </Compile>
<EmbeddedResource Include="FrmBase.resx">
<DependentUpon>FrmBase.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmHYEquip.resx"> <EmbeddedResource Include="FrmHYEquip.resx">
<DependentUpon>FrmHYEquip.cs</DependentUpon> <DependentUpon>FrmHYEquip.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
...@@ -181,9 +180,6 @@ ...@@ -181,9 +180,6 @@
<EmbeddedResource Include="useControl\AxisMoveControl.resx"> <EmbeddedResource Include="useControl\AxisMoveControl.resx">
<DependentUpon>AxisMoveControl.cs</DependentUpon> <DependentUpon>AxisMoveControl.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="FrmBase.resx">
<DependentUpon>FrmBase.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmEquipBase.resx"> <EmbeddedResource Include="FrmEquipBase.resx">
<DependentUpon>FrmEquipBase.cs</DependentUpon> <DependentUpon>FrmEquipBase.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.BackColor = System.Drawing.Color.White; this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(300, 300); this.ClientSize = new System.Drawing.Size(293, 273);
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FrmBase"; this.Name = "FrmBase";
......
...@@ -120,19 +120,19 @@ namespace OnlineStore.AssemblyLine ...@@ -120,19 +120,19 @@ namespace OnlineStore.AssemblyLine
if (LineManager.Line.IOValue(IO_Type.HY_TopCylinder_Up).Equals(IO_VALUE.HIGH)) if (LineManager.Line.IOValue(IO_Type.HY_TopCylinder_Up).Equals(IO_VALUE.HIGH))
{ {
HY_TopCylinder_Up.ForeColor = Color.LawnGreen; HY_TopCylinder_Up.BackColor = Color.LawnGreen;
} }
else else
{ {
HY_TopCylinder_Up.ForeColor = Color.White ; HY_TopCylinder_Up.BackColor = Color.White ;
} }
if (LineManager.Line.IOValue(IO_Type.HY_TopCylinder_Down).Equals(IO_VALUE.HIGH)) if (LineManager.Line.IOValue(IO_Type.HY_TopCylinder_Down).Equals(IO_VALUE.HIGH))
{ {
HY_TopCylinder_Down.ForeColor = Color.LawnGreen; HY_TopCylinder_Down.BackColor = Color.LawnGreen;
} }
else else
{ {
HY_TopCylinder_Down.ForeColor = Color.White; HY_TopCylinder_Down.BackColor = Color.White;
} }
} }
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.groupAxis = new System.Windows.Forms.GroupBox(); this.groupAxis = new System.Windows.Forms.GroupBox();
this.lblStatus = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox(); this.groupBox2 = new System.Windows.Forms.GroupBox();
this.lblAlarmcode = new System.Windows.Forms.Label(); this.lblAlarmcode = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label();
...@@ -100,7 +101,7 @@ ...@@ -100,7 +101,7 @@
this.btnAxisVMove = new System.Windows.Forms.Button(); this.btnAxisVMove = new System.Windows.Forms.Button();
this.btnReadPosition = new System.Windows.Forms.Button(); this.btnReadPosition = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components); this.timer1 = new System.Windows.Forms.Timer(this.components);
this.lblStatus = new System.Windows.Forms.Label(); this.lblAxisType = new System.Windows.Forms.Label();
this.groupAxis.SuspendLayout(); this.groupAxis.SuspendLayout();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
...@@ -112,6 +113,7 @@ ...@@ -112,6 +113,7 @@
this.groupAxis.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.groupAxis.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupAxis.Controls.Add(this.lblAxisType);
this.groupAxis.Controls.Add(this.lblStatus); this.groupAxis.Controls.Add(this.lblStatus);
this.groupAxis.Controls.Add(this.groupBox2); this.groupAxis.Controls.Add(this.groupBox2);
this.groupAxis.Controls.Add(this.btnComAlarmClear); this.groupAxis.Controls.Add(this.btnComAlarmClear);
...@@ -128,6 +130,15 @@ ...@@ -128,6 +130,15 @@
this.groupAxis.TabStop = false; this.groupAxis.TabStop = false;
this.groupAxis.Text = "伺服运动"; this.groupAxis.Text = "伺服运动";
// //
// lblStatus
//
this.lblStatus.AutoSize = true;
this.lblStatus.Location = new System.Drawing.Point(8, 376);
this.lblStatus.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblStatus.Name = "lblStatus";
this.lblStatus.Size = new System.Drawing.Size(0, 17);
this.lblStatus.TabIndex = 305;
//
// groupBox2 // groupBox2
// //
this.groupBox2.Controls.Add(this.lblAlarmcode); this.groupBox2.Controls.Add(this.lblAlarmcode);
...@@ -953,14 +964,14 @@ ...@@ -953,14 +964,14 @@
// //
this.timer1.Tick += new System.EventHandler(this.timer1_Tick); this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
// //
// lblStatus // lblAxisType
// //
this.lblStatus.AutoSize = true; this.lblAxisType.AutoSize = true;
this.lblStatus.Location = new System.Drawing.Point(8, 380); this.lblAxisType.Location = new System.Drawing.Point(8, 398);
this.lblStatus.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); this.lblAxisType.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblStatus.Name = "lblStatus"; this.lblAxisType.Name = "lblAxisType";
this.lblStatus.Size = new System.Drawing.Size(0, 17); this.lblAxisType.Size = new System.Drawing.Size(0, 17);
this.lblStatus.TabIndex = 305; this.lblAxisType.TabIndex = 306;
// //
// AxisMoveControl // AxisMoveControl
// //
...@@ -1055,5 +1066,6 @@ ...@@ -1055,5 +1066,6 @@
private System.Windows.Forms.Label lblAlarmcode; private System.Windows.Forms.Label lblAlarmcode;
private System.Windows.Forms.LinkLabel linkLabel1; private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.Label lblStatus; private System.Windows.Forms.Label lblStatus;
private System.Windows.Forms.Label lblAxisType;
} }
} }
...@@ -328,6 +328,7 @@ namespace OnlineStore.AssemblyLine ...@@ -328,6 +328,7 @@ namespace OnlineStore.AssemblyLine
short value = HCBoardManager.GetHomeStatus(axisNo); short value = HCBoardManager.GetHomeStatus(axisNo);
string homesstr = HCBoardManager.AxisHomeSts(value); string homesstr = HCBoardManager.AxisHomeSts(value);
lblhomeSts.Text = homesstr; lblhomeSts.Text = homesstr;
lblAxisType.Text = HCBoardManager.GetAxType(axisNo);
//lblCountPulse.Text = AxisManager.instance.GetActualtPosition(PortName, SlvAddr).ToString(); //lblCountPulse.Text = AxisManager.instance.GetActualtPosition(PortName, SlvAddr).ToString();
} }
......
...@@ -73,7 +73,7 @@ DI,217,HY17接驳台气缸取料端,HY_MoveCylinder_Take,11,HC,X11 ...@@ -73,7 +73,7 @@ DI,217,HY17接驳台气缸取料端,HY_MoveCylinder_Take,11,HC,X11
DI,217,HY17接驳台气缸放料端,HY_MoveCylinder_Give,12,HC,X12 DI,217,HY17接驳台气缸放料端,HY_MoveCylinder_Give,12,HC,X12
DI,217,HY17夹料气缸料盘检测,HY_ClampCylinder_Check,13,HC,X13 DI,217,HY17夹料气缸料盘检测,HY_ClampCylinder_Check,13,HC,X13
DI,217,HY17夹料气缸放松端,HY_ClampCylinder_Relax,14,HC,X14 DI,217,HY17夹料气缸放松端,HY_ClampCylinder_Relax,14,HC,X14
,0,,,15,HC,X15 DI,217,C9-HY14满料托盘检测,HY_OL_Full_Check,15,HC,X15
,,,,,, ,,,,,,
DO,0,待机状态(指示灯),AutoRun_HddLed,0,HC,Y00 DO,0,待机状态(指示灯),AutoRun_HddLed,0,HC,Y00
DO,0,运行状态(指示灯),RunSign_HddLed,1,HC,Y01 DO,0,运行状态(指示灯),RunSign_HddLed,1,HC,Y01
...@@ -136,7 +136,7 @@ DI,216,HY16横移顶升上升端,HY_TopCylinder_Up,54,HC,X54 ...@@ -136,7 +136,7 @@ DI,216,HY16横移顶升上升端,HY_TopCylinder_Up,54,HC,X54
DI,216,HY16横移顶升下降端,HY_TopCylinder_Down,55,HC,X55 DI,216,HY16横移顶升下降端,HY_TopCylinder_Down,55,HC,X55
DI,216,HY16-C7阻挡上升端,HY_OL_StopCylinder_Up,56,HC,X56 DI,216,HY16-C7阻挡上升端,HY_OL_StopCylinder_Up,56,HC,X56
DI,216,HY16-C7阻挡下降端,HY_OL_StopCylinder_Down,57,HC,X57 DI,216,HY16-C7阻挡下降端,HY_OL_StopCylinder_Down,57,HC,X57
DI,217,C7-HY17满料检测,HY_OL_Full_Check,58,HC,X58 DI,216,C7-HY17满料检测,HY_OL_Full_Check,58,HC,X58
,,,,59,HC,X59 ,,,,59,HC,X59
,,,,60,HC,X60 ,,,,60,HC,X60
,,,,61,HC,X61 ,,,,61,HC,X61
...@@ -1025,7 +1025,7 @@ DI,207,HY7横移顶升下降端,HY_TopCylinder_Down,487,HC,X487 ...@@ -1025,7 +1025,7 @@ DI,207,HY7横移顶升下降端,HY_TopCylinder_Down,487,HC,X487
DI,207,C3-HY7短线前阻挡托盘检测,HY_ShortL_StopCheck,488,HC,X488 DI,207,C3-HY7短线前阻挡托盘检测,HY_ShortL_StopCheck,488,HC,X488
DI,207,C8-HY7长线前阻挡托盘检测,HY_LongL_StopCheck,489,HC,X489 DI,207,C8-HY7长线前阻挡托盘检测,HY_LongL_StopCheck,489,HC,X489
DI,207,C8线体HY7侧满料检测,HY_OL_Full_Check,490,HC,X490 DI,207,C8线体HY7侧满料检测,HY_OL_Full_Check,490,HC,X490
DI,209,C4-HY9满料检测,HY_OL_Full_Check,491,HC,X491 DI,210,C4-HY9满料检测,HY_OL_Full_Check,491,HC,X491
DI,210,HY10前阻挡托盘检测,HY_FrontStopCheck,492,HC,X492 DI,210,HY10前阻挡托盘检测,HY_FrontStopCheck,492,HC,X492
DI,210,HY10横移托盘检测,HY_TrayCheck,493,HC,X493 DI,210,HY10横移托盘检测,HY_TrayCheck,493,HC,X493
DI,210,HY10横移顶升上升端,HY_TopCylinder_Up,494,HC,X494 DI,210,HY10横移顶升上升端,HY_TopCylinder_Up,494,HC,X494
...@@ -1192,7 +1192,7 @@ DI,214,HY14横移托盘检测,HY_TrayCheck,561,HC,X561 ...@@ -1192,7 +1192,7 @@ DI,214,HY14横移托盘检测,HY_TrayCheck,561,HC,X561
DI,214,C9-HY14长线前阻挡托盘检测,HY_LongL_StopCheck,562,HC,X562 DI,214,C9-HY14长线前阻挡托盘检测,HY_LongL_StopCheck,562,HC,X562
DI,214,HY14横移顶升上升端,HY_TopCylinder_Up,563,HC,X563 DI,214,HY14横移顶升上升端,HY_TopCylinder_Up,563,HC,X563
DI,214,HY14横移顶升下降端,HY_TopCylinder_Down,564,HC,X564 DI,214,HY14横移顶升下降端,HY_TopCylinder_Down,564,HC,X564
DI,211,C5-HY11满料检测,HY_OL_Full_Check,565,HC,X565 DI,212,C5-HY11满料检测,HY_OL_Full_Check,565,HC,X565
DI,212,C9-HY12前阻挡托盘检测,HY_FrontStopCheck,566,HC,X566 DI,212,C9-HY12前阻挡托盘检测,HY_FrontStopCheck,566,HC,X566
DI,212,HY12横移托盘检测,HY_TrayCheck,567,HC,X567 DI,212,HY12横移托盘检测,HY_TrayCheck,567,HC,X567
DI,212,HY12横移顶升上升端,HY_TopCylinder_Up,568,HC,X568 DI,212,HY12横移顶升上升端,HY_TopCylinder_Up,568,HC,X568
...@@ -1209,7 +1209,7 @@ DI,212,HY12接驳台料盘检测7寸,HY_TrayCheck1,578,HC,X578 ...@@ -1209,7 +1209,7 @@ DI,212,HY12接驳台料盘检测7寸,HY_TrayCheck1,578,HC,X578
DI,212,HY12接驳台料盘检测11寸,HY_TrayCheck2,579,HC,X579 DI,212,HY12接驳台料盘检测11寸,HY_TrayCheck2,579,HC,X579
DI,212,HY12接驳台料盘检测13寸,HY_TrayCheck3,580,HC,X580 DI,212,HY12接驳台料盘检测13寸,HY_TrayCheck3,580,HC,X580
DI,212,HY12接驳台料盘检测15寸,HY_TrayCheck4,581,HC,X581 DI,212,HY12接驳台料盘检测15寸,HY_TrayCheck4,581,HC,X581
,,,,582,HC,X582 DI,214,C9-HY12满料托盘检测,HY_OL_Full_Check,582,HC,X582
,,,,583,HC,X583 ,,,,583,HC,X583
,,,,584,HC,X584 ,,,,584,HC,X584
,,,,585,HC,X585 ,,,,585,HC,X585
......
...@@ -91,7 +91,7 @@ namespace HuichuanLibrary ...@@ -91,7 +91,7 @@ namespace HuichuanLibrary
} }
private void btnInitBoard_Click(object sender, EventArgs e) private void btnInitBoard_Click(object sender, EventArgs e)
{ {
bool result = HCBoardManager.OpenCard(); bool result = HCBoardManager.OpenCard(1);
if (result) if (result)
{ {
cmbAxisIndex.Items.Clear(); cmbAxisIndex.Items.Clear();
......
...@@ -12,11 +12,10 @@ namespace HuichuanLibrary ...@@ -12,11 +12,10 @@ namespace HuichuanLibrary
{ {
public partial class HCBoardManager public partial class HCBoardManager
{ {
//private static UInt32 ret = 0; // 用于接收API返回值
private static Int32 nCardNo = 0; // 默认要打开的卡号 private static Int32 nCardNo = 0; // 默认要打开的卡号
private static UInt64 nCardHandle = 0; // 卡句柄 private static UInt64 nCardHandle = 0; // 卡句柄
private static bool CardIsOk = false; private static bool CardIsOk = false;
//private static Int16 nTempAxNo = 0;
public static List<int> AxisList = new List<int>(); public static List<int> AxisList = new List<int>();
public static ImcApi.TRsouresNum tResource = new ImcApi.TRsouresNum();//实例化板卡外设硬件资源 public static ImcApi.TRsouresNum tResource = new ImcApi.TRsouresNum();//实例化板卡外设硬件资源
private static string DeviceConfigPath = ""; private static string DeviceConfigPath = "";
...@@ -55,11 +54,18 @@ namespace HuichuanLibrary ...@@ -55,11 +54,18 @@ namespace HuichuanLibrary
#region 板卡操作,初始化,关闭,急停 #region 板卡操作,初始化,关闭,急停
private static bool IsInScanECAT = false;
private static System.Timers.Timer scanEcatTimer = null;
private static DateTime startTime = DateTime.Now;
public static string CardMsg = "板卡还未初始化";
/// <summary> /// <summary>
/// 初始化板卡 /// 初始化板卡
/// </summary> /// </summary>
/// <param name="blockFlag">是否阻塞,1=阻塞,0=不阻塞</param>
/// <returns></returns> /// <returns></returns>
public static bool OpenCard() public static bool OpenCard(int blockFlag=0)
{ {
try try
{ {
...@@ -67,19 +73,30 @@ namespace HuichuanLibrary ...@@ -67,19 +73,30 @@ namespace HuichuanLibrary
{ {
return true; return true;
} }
DateTime startTime = DateTime.Now; if (IsInScanECAT)
{
return false;
}
if (scanEcatTimer == null)
{
scanEcatTimer = new System.Timers.Timer();
scanEcatTimer.AutoReset = true;
scanEcatTimer.Interval = 500;
scanEcatTimer.Elapsed += ScanEcatTimer_Elapsed;
scanEcatTimer.Enabled = false;
}
if (!File.Exists(DeviceConfigPath)) if (!File.Exists(DeviceConfigPath))
{ {
HCLogUtil.error("InitCard FAIL, 【" + DeviceConfigPath + "】not exists"); HCLogUtil.error("InitCard FAIL,DeviceConfigPath 【" + DeviceConfigPath + "】not exists");
return false; return false;
} }
if (!File.Exists(SystemConfigPath)) if (!File.Exists(SystemConfigPath))
{ {
HCLogUtil.error("InitCard FAIL, 【" + SystemConfigPath + "】not exists"); HCLogUtil.error("InitCard FAIL, SystemConfigPath【" + SystemConfigPath + "】not exists");
return false; return false;
} }
startTime = DateTime.Now;
//【1】获取卡 //【1】获取卡
Int32 nCardNum = 0; Int32 nCardNum = 0;
UInt32 ret = ImcApi.IMC_GetCardsNum(ref nCardNum); UInt32 ret = ImcApi.IMC_GetCardsNum(ref nCardNum);
...@@ -97,7 +114,7 @@ namespace HuichuanLibrary ...@@ -97,7 +114,7 @@ namespace HuichuanLibrary
} }
else else
{ {
ShowLog("GetCardsNum = "+nCardNum+", 将默认打开第0号卡"); ShowLog("GetCardsNum = " + nCardNum + ", 将默认打开第0号卡");
} }
} }
...@@ -126,8 +143,9 @@ namespace HuichuanLibrary ...@@ -126,8 +143,9 @@ namespace HuichuanLibrary
} }
//【4】启动主站 //【4】启动主站
ShowLog("Begin ScanCardECAT... ...");
ShowLog("Begin ScanCardECAT... ...IsInScanECAT=true");
IsInScanECAT = true;
uint masterStatus = 0; uint masterStatus = 0;
ret = ImcApi.IMC_GetECATMasterSts(nCardHandle, ref masterStatus); ret = ImcApi.IMC_GetECATMasterSts(nCardHandle, ref masterStatus);
if (ret != 0) if (ret != 0)
...@@ -139,7 +157,15 @@ namespace HuichuanLibrary ...@@ -139,7 +157,15 @@ namespace HuichuanLibrary
{ {
if (masterStatus != ImcApi.EC_MASTER_OP) if (masterStatus != ImcApi.EC_MASTER_OP)
{ {
ret = ImcApi.IMC_ScanCardECAT(nCardHandle, 1); //默认阻塞式启动EtherCAT // [2020 - 12 - 03 16:32:37,124][1]INFO HCH[0][0] GetCardsNum = 1, 将默认打开第0号卡
// [2020 - 12 - 03 16:32:37, 126][1]INFO HCH[0][479296224] OpenCardHandle OK
// [2020 - 12 - 03 16:32:37,537][1]INFO HCH[0][479296224] DownLoadDeviceConfig OK
// [2020 - 12 - 03 16:32:37,537][1]INFO HCH[0][479296224] Begin ScanCardECAT... ...
//[2020 - 12 - 03 16:33:02,925][1]INFO HCH[0][479296224] ScanCardECAT OK
// [2020 - 12 - 03 16:33:03,107][1]INFO HCH[0][479296224] DownLoadSystemConfig OK
// [2020 - 12 - 03 16:33:03,111][1]INFO HCH[0][479296224] Axis[22],DI[592],DO[528]
ret = ImcApi.IMC_ScanCardECAT(nCardHandle, blockFlag);
if (ret != 0) if (ret != 0)
{ {
ShowErrorLog(" ScanCardECAT FAIL, ErrorCode=0x" + ret.ToString("x8")); ShowErrorLog(" ScanCardECAT FAIL, ErrorCode=0x" + ret.ToString("x8"));
...@@ -147,10 +173,38 @@ namespace HuichuanLibrary ...@@ -147,10 +173,38 @@ namespace HuichuanLibrary
} }
} }
} }
if (blockFlag == 1)// 默认阻塞式启动EtherCAT
{
ShowLog("ScanCardECAT OK"); ShowLog("ScanCardECAT OK");
//【5】下载系统参数
if (!LoadSystemConfig())
{
IsInScanECAT = false;
return false;
}
//【6】扫描卡内资源,初始化ComboBox
return GetCardResource();
}
else
{
CardMsg = "ECAT总线扫描和配置中................";
scanEcatTimer.Enabled = true;
ShowLog("start scanEcatTimer ...............");
return false;
}
}
catch (Exception ex)
{
ShowErrorLog(ex.ToString());
}
return false;
}
private static bool LoadSystemConfig()
{
//【5】下载系统参数 //【5】下载系统参数
ret = ImcApi.IMC_DownLoadSystemConfig(nCardHandle, SystemConfigPath); uint ret = ImcApi.IMC_DownLoadSystemConfig(nCardHandle, SystemConfigPath);
if (ret != 0) if (ret != 0)
{ {
ShowErrorLog(" DownLoadSystemConfig FAIL, ErrorCode=0x" + ret.ToString("x8") + ",请检查是否有" + SystemConfigPath + "文件"); ShowErrorLog(" DownLoadSystemConfig FAIL, ErrorCode=0x" + ret.ToString("x8") + ",请检查是否有" + SystemConfigPath + "文件");
...@@ -160,11 +214,15 @@ namespace HuichuanLibrary ...@@ -160,11 +214,15 @@ namespace HuichuanLibrary
{ {
ShowLog("DownLoadSystemConfig OK"); ShowLog("DownLoadSystemConfig OK");
} }
return true;
}
private static bool GetCardResource()
{
IsInScanECAT = false;
tResource = new ImcApi.TRsouresNum();//实例化板卡外设硬件资源 tResource = new ImcApi.TRsouresNum();//实例化板卡外设硬件资源
//【6】扫描卡内资源,初始化ComboBox //【6】扫描卡内资源,初始化ComboBox
ret = ImcApi.IMC_GetCardResource(nCardHandle, ref tResource); uint ret = ImcApi.IMC_GetCardResource(nCardHandle, ref tResource);
if (ret != 0) if (ret != 0)
{ {
ShowErrorLog(" GetCardResource FAIL, ErrorCode=0x" + ret.ToString("x8")); ShowErrorLog(" GetCardResource FAIL, ErrorCode=0x" + ret.ToString("x8"));
...@@ -182,19 +240,198 @@ namespace HuichuanLibrary ...@@ -182,19 +240,198 @@ namespace HuichuanLibrary
AxisList.Add(i); AxisList.Add(i);
} }
} }
CardMsg = "板卡初始化完成";
CardIsOk = true; CardIsOk = true;
TimeSpan span = DateTime.Now - startTime; TimeSpan span = DateTime.Now - startTime;
ShowLog("OpenCard end ," + Convert.ToDateTime(span.ToString()).ToString("HH:mm:ss")); ShowLog("OpenCard end ," + Convert.ToDateTime(span.ToString()).ToString("HH:mm:ss"));
return true; return true;
//IO
} }
} }
catch (Exception ex)
private static void ScanEcatTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{ {
ShowErrorLog(ex.ToString()); uint pStatus = 0;
uint ret = ImcApi.IMC_GetECATMasterSts(nCardHandle, ref pStatus);
if (ret != 0)
{
ShowErrorLog(" GetECATMasterSts FAIL, ErrorCode=0x" + ret.ToString("x8") + " ");
} }
return false; else if (pStatus.Equals(6))
{
scanEcatTimer.Stop();
ShowLog(" GetECATMasterSts OK, pStatus= " + pStatus + " ");
ShowLog("ScanCardECAT OK");
//【5】下载系统参数
if (!LoadSystemConfig())
{
IsInScanECAT = false;
return;
}
//【6】扫描卡内资源,初始化ComboBox
GetCardResource();
return;
}
else
{
ShowLog(" GetECATMasterSts OK, pStatus= " + pStatus + " ");
} }
//判断是否超时
TimeSpan span = DateTime.Now - startTime;
if (span.TotalMinutes > 2)
{
CardMsg = "ECAT总线连接失败,超时未进入OP模式";
ShowErrorLog(CardMsg + ",停止主站状态查询");
IsInScanECAT = false;
scanEcatTimer.Stop();
}
}
//public static bool OpenCard()
//{
// try
// {
// if (CardIsOk)
// {
// return true;
// }
// if (IsInScanECAT)
// {
// return false ;
// }
// DateTime startTime = DateTime.Now;
// if (!File.Exists(DeviceConfigPath))
// {
// HCLogUtil.error("InitCard FAIL, 【" + DeviceConfigPath + "】not exists");
// return false;
// }
// if (!File.Exists(SystemConfigPath))
// {
// HCLogUtil.error("InitCard FAIL, 【" + SystemConfigPath + "】not exists");
// return false;
// }
// //【1】获取卡
// Int32 nCardNum = 0;
// UInt32 ret = ImcApi.IMC_GetCardsNum(ref nCardNum);
// if (ret != 0)
// {
// ShowErrorLog(" GetCardsNum FAIL, ErrorCode=0x" + ret.ToString("x8"));
// return false;
// }
// else
// {
// if (nCardNum <= 0)
// {
// ShowErrorLog(" Not Find Card");
// return false;
// }
// else
// {
// ShowLog("GetCardsNum = " + nCardNum + ", 将默认打开第0号卡");
// }
// }
// //【2】打开卡句柄
// ret = ImcApi.IMC_OpenCardHandle(nCardNo, ref nCardHandle);
// if (ret != 0)
// {
// ShowErrorLog(" OpenCardHandle FAIL, ErrorCode=0x" + ret.ToString("x8"));
// return false;
// }
// else
// {
// ShowLog("OpenCardHandle OK");
// }
// //【3】下载设备参数
// ret = ImcApi.IMC_DownLoadDeviceConfig(nCardHandle, DeviceConfigPath);
// if (ret != 0)
// {
// ShowErrorLog(" DownLoadDeviceConfig FAIL, ErrorCode=0x" + ret.ToString("x8") + ",请检查是否有" + DeviceConfigPath + "文件");
// return false;
// }
// else
// {
// ShowLog("DownLoadDeviceConfig OK");
// }
// //【4】启动主站
// ShowLog("Begin ScanCardECAT... ...");
// uint masterStatus = 0;
// ret = ImcApi.IMC_GetECATMasterSts(nCardHandle, ref masterStatus);
// if (ret != 0)
// {
// ShowErrorLog(" GetECATMasterSts FAIL, ErrorCode=0x" + ret.ToString("x8"));
// return false;
// }
// else
// {
// if (masterStatus != ImcApi.EC_MASTER_OP)
// {
// ret = ImcApi.IMC_ScanCardECAT(nCardHandle, 1); //默认阻塞式启动EtherCAT
// if (ret != 0)
// {
// ShowErrorLog(" ScanCardECAT FAIL, ErrorCode=0x" + ret.ToString("x8"));
// return false;
// }
// }
// }
// ShowLog("ScanCardECAT OK");
// //【5】下载系统参数
// ret = ImcApi.IMC_DownLoadSystemConfig(nCardHandle, SystemConfigPath);
// if (ret != 0)
// {
// ShowErrorLog(" DownLoadSystemConfig FAIL, ErrorCode=0x" + ret.ToString("x8") + ",请检查是否有" + SystemConfigPath + "文件");
// return false;
// }
// else
// {
// ShowLog("DownLoadSystemConfig OK");
// }
// tResource = new ImcApi.TRsouresNum();//实例化板卡外设硬件资源
// //【6】扫描卡内资源,初始化ComboBox
// ret = ImcApi.IMC_GetCardResource(nCardHandle, ref tResource);
// if (ret != 0)
// {
// ShowErrorLog(" GetCardResource FAIL, ErrorCode=0x" + ret.ToString("x8"));
// return false;
// }
// else
// {
// ShowLog("Axis [" + tResource.axNum + "],DI [" + tResource.diNum + "],DO [" + tResource.doNum + "]");
// //轴
// AxisList = new List<int>();
// if (tResource.axNum > 0)
// {
// for (int i = 0; i < tResource.axNum; i++)
// {
// AxisList.Add(i);
// }
// }
// CardIsOk = true;
// TimeSpan span = DateTime.Now - startTime;
// ShowLog("OpenCard end ," + Convert.ToDateTime(span.ToString()).ToString("HH:mm:ss"));
// return true;
// //IO
// }
// }
// catch (Exception ex)
// {
// ShowErrorLog(ex.ToString());
// }
// return false;
//}
/// <summary> /// <summary>
/// 关闭板卡 /// 关闭板卡
/// </summary> /// </summary>
...@@ -418,6 +655,7 @@ namespace HuichuanLibrary ...@@ -418,6 +655,7 @@ namespace HuichuanLibrary
private static void ShowErrorLog(string msg) private static void ShowErrorLog(string msg)
{ {
CardMsg = BoardName() + msg;
Console.WriteLine(BoardName() + msg); Console.WriteLine(BoardName() + msg);
HCLogUtil.error(BoardName() + msg); HCLogUtil.error(BoardName() + msg);
} }
...@@ -471,10 +709,13 @@ namespace HuichuanLibrary ...@@ -471,10 +709,13 @@ namespace HuichuanLibrary
/// 负限位信号 /// 负限位信号
/// </summary> /// </summary>
public int NEL = -1; public int NEL = -1;
/// <summary>
/// 总线轴标志
/// </summary>
public int ECAT = -1;
public string ToStr() public string ToStr()
{ {
return "ALM=" + ALM + ";WARN=" + WARN + "EMG=" + EMG + "ServoOn=" + ServoOn + "BUSY=" + BUSY + "INP=" + INP + "PEL=" + PEL + "ORG=" + ORG + ";NEL="+ NEL; return "ALM=" + ALM + ",WARN=" + WARN + ",EMG=" + EMG + ",ServoOn=" + ServoOn + ",BUSY=" + BUSY + ",INP=" + INP + ",PEL=" + PEL + ",ORG=" + ORG + ",NEL=" + NEL+ ",ECAT=" + ECAT;
} }
} }
......
...@@ -435,8 +435,9 @@ namespace HuichuanLibrary ...@@ -435,8 +435,9 @@ namespace HuichuanLibrary
sts.ServoOn = ((axisState & 0x02) == 0x02) ? 1 : 0; //使能信号 sts.ServoOn = ((axisState & 0x02) == 0x02) ? 1 : 0; //使能信号
sts.BUSY = ((axisState & 0x04) == 0x04) ? 1 : 0; //轴忙信号 sts.BUSY = ((axisState & 0x04) == 0x04) ? 1 : 0; //轴忙信号
sts.INP = ((axisState & 0x08) == 0x08) ? 1 : 0; //轴到位信号 sts.INP = ((axisState & 0x08) == 0x08) ? 1 : 0; //轴到位信号
sts.WARN = ((axisState & 0x1000) == 0x1000) ? 1 : 0; //警告信号
sts.EMG = ((axisState & 0x200) == 0x200) ? 1 : 0; //急停信号 sts.EMG = ((axisState & 0x200) == 0x200) ? 1 : 0; //急停信号
sts.WARN = ((axisState & 0x1000) == 0x1000) ? 1 : 0; //警告信号
sts.ECAT = ((axisState & ImcApi.AX_ECAT_BIT) == ImcApi.AX_ECAT_BIT) ? 1 : 0;//总线轴标志
Int16 nTimerAxInput = 0; Int16 nTimerAxInput = 0;
ret = ImcApi.IMC_GetAxEcatDigitalInput(nCardHandle, axisNo, ref nTimerAxInput); ret = ImcApi.IMC_GetAxEcatDigitalInput(nCardHandle, axisNo, ref nTimerAxInput);
...@@ -591,6 +592,26 @@ namespace HuichuanLibrary ...@@ -591,6 +592,26 @@ namespace HuichuanLibrary
} }
return outV; return outV;
} }
public static string GetAxType(short axisNo )
{
string res = "";
if (!CardInitOk())
{
return res;
}
short pAxType = -1;
short pOutChn = -1;
UInt32 ret = ImcApi.IMC_GetAxType(nCardHandle, axisNo, ref pAxType,ref pOutChn);
res = "轴类型["+pAxType+ "],物理通道[" + pOutChn + "]";
if (ret != 0)
{
ShowErrorLog(" Axis[" + axisNo + "] GetAxType FAIL, ErrorCode=0x" + ret.ToString("x8"));
}
return res;
}
#endregion #endregion
#region 轴状态 #region 轴状态
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!