Commit 1c0fb29d LN

1

1 个父辈 136299d3
...@@ -23,9 +23,9 @@ namespace HuichuanLibrary ...@@ -23,9 +23,9 @@ namespace HuichuanLibrary
/// <summary> /// <summary>
/// 初始化配置信息,初始化板卡之前,先初始化配置 /// 初始化配置信息,初始化板卡之前,先初始化配置
/// </summary> /// </summary>
/// <param name="deviceConfigPath"></param> /// <param name="deviceConfigPath">设备配置文件</param>
/// <param name="systemConfigPath"></param> /// <param name="systemConfigPath">系统配置文件</param>
/// <param name="logName"></param> /// <param name="logName">日志名称</param>
public static void InitConfig(string deviceConfigPath="",string systemConfigPath="", string logName = "RollingLogFileAppender") public static void InitConfig(string deviceConfigPath="",string systemConfigPath="", string logName = "RollingLogFileAppender")
{ {
if (deviceConfigPath.Equals("")) if (deviceConfigPath.Equals(""))
...@@ -64,7 +64,7 @@ namespace HuichuanLibrary ...@@ -64,7 +64,7 @@ namespace HuichuanLibrary
/// 初始化板卡 /// 初始化板卡
/// </summary> /// </summary>
/// <param name="blockFlag">是否阻塞,1=阻塞,0=不阻塞</param> /// <param name="blockFlag">是否阻塞,1=阻塞,0=不阻塞</param>
/// <returns></returns> /// <returns>true=成功</returns>
public static bool OpenCard(int blockFlag=0) public static bool OpenCard(int blockFlag=0)
{ {
try try
...@@ -289,146 +289,6 @@ namespace HuichuanLibrary ...@@ -289,146 +289,6 @@ namespace HuichuanLibrary
} }
//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;
//}
...@@ -466,8 +326,8 @@ namespace HuichuanLibrary ...@@ -466,8 +326,8 @@ namespace HuichuanLibrary
/// <summary> /// <summary>
/// 板卡是否已经初始化OK /// 板卡是否已经初始化OK
/// </summary> /// </summary>
/// <param name="isShowLog"></param> /// <param name="isShowLog">未初始化完成时是否打印日志</param>
/// <returns></returns> /// <returns>true=OK</returns>
public static bool CardInitOk(bool isShowLog = false) public static bool CardInitOk(bool isShowLog = false)
{ {
if (CardIsOk) if (CardIsOk)
...@@ -484,7 +344,10 @@ namespace HuichuanLibrary ...@@ -484,7 +344,10 @@ namespace HuichuanLibrary
} }
} }
/// <summary>
/// 紧急停止
/// </summary>
/// <returns></returns>
public static bool EmgStop() public static bool EmgStop()
{ {
if (!CardInitOk()) if (!CardInitOk())
...@@ -504,7 +367,10 @@ namespace HuichuanLibrary ...@@ -504,7 +367,10 @@ namespace HuichuanLibrary
return true; return true;
} }
} }
/// <summary>
/// 取消急停
/// </summary>
/// <returns></returns>
public static bool CancelEmg() public static bool CancelEmg()
{ {
if (!CardInitOk()) if (!CardInitOk())
...@@ -529,7 +395,12 @@ namespace HuichuanLibrary ...@@ -529,7 +395,12 @@ namespace HuichuanLibrary
#region IO控制 #region IO控制
/// <summary>
/// 按位设置DO的值
/// </summary>
/// <param name="bitNo">DO索引,从0开始</param>
/// <param name="bitValue">DO值</param>
/// <returns></returns>
public static bool SetBitDO(short bitNo, short bitValue) public static bool SetBitDO(short bitNo, short bitValue)
{ {
if (!CardInitOk()) if (!CardInitOk())
...@@ -545,7 +416,11 @@ namespace HuichuanLibrary ...@@ -545,7 +416,11 @@ namespace HuichuanLibrary
} }
return true; return true;
} }
/// <summary>
/// 按位获取DO的值
/// </summary>
/// <param name="bitNo">DO索引,从0开始</param>
/// <returns></returns>
public static short GetBitDO(short bitNo) public static short GetBitDO(short bitNo)
{ {
if (!CardInitOk()) if (!CardInitOk())
...@@ -563,7 +438,11 @@ namespace HuichuanLibrary ...@@ -563,7 +438,11 @@ namespace HuichuanLibrary
return bitValue; return bitValue;
} }
/// <summary>
/// 按位获取DI的值
/// </summary>
/// <param name="bitNo">DI索引,从0开始</param>
/// <returns></returns>
public static short GetBitDI(short bitNo) public static short GetBitDI(short bitNo)
{ {
if (!CardInitOk()) if (!CardInitOk())
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\HuichuanLibrary.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!