Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
李娜
/
HuichuanLibrary
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 8566b42c
由
LN
编写于
2021-02-19 15:22:53 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加模拟量查询代码
1 个父辈
1c0fb29d
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
146 行增加
和
3 行删除
DemoTest/DemoTest.csproj
DemoTest/packages.config
HuichuanLibrary/FrmHuiChuanTest.Designer.cs
HuichuanLibrary/FrmHuiChuanTest.cs
HuichuanLibrary/HCBoardManager.cs
DemoTest/DemoTest.csproj
查看文件 @
8566b42
...
@@ -37,12 +37,13 @@
...
@@ -37,12 +37,13 @@
<ApplicationIcon>DfIcon.ico</ApplicationIcon>
<ApplicationIcon>DfIcon.ico</ApplicationIcon>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference Include="log4net">
<Reference Include="log4net
, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL
">
<HintPath>..\
dll
\log4net.dll</HintPath>
<HintPath>..\
packages\log4net.2.0.12\lib\net45
\log4net.dll</HintPath>
</Reference>
</Reference>
<Reference Include="System" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data.DataSetExtensions" />
...
@@ -66,6 +67,7 @@
...
@@ -66,6 +67,7 @@
<AutoGen>True</AutoGen>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
...
...
DemoTest/packages.config
0 → 100644
查看文件 @
8566b42
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"log4net"
version
=
"2.0.12"
targetFramework
=
"net461"
/>
</
packages
>
\ No newline at end of file
\ No newline at end of file
HuichuanLibrary/FrmHuiChuanTest.Designer.cs
查看文件 @
8566b42
此文件的差异被折叠,
点击展开。
HuichuanLibrary/FrmHuiChuanTest.cs
查看文件 @
8566b42
...
@@ -87,7 +87,18 @@ namespace HuichuanLibrary
...
@@ -87,7 +87,18 @@ namespace HuichuanLibrary
FormStatus
(
false
);
FormStatus
(
false
);
timerIO
.
Start
();
timerIO
.
Start
();
timerMain
.
Start
();
timerMain
.
Start
();
HCLogUtil
.
logBox
=
richTextBox1
;
lblAdSts
.
Text
=
"状态说明:\r\n"
+
"Bit0 ,负载电压故障,0:正常,1:未接入外部电源\r\n"
+
"Bit1 ,模拟芯片连接错误,0:正常,1:数字版与模拟板通讯错误\r\n"
+
"Bit2:通道故障\r\n"
+
"Bit3:通道上溢\r\n"
+
"Bit4:通道下溢\r\n"
+
"Bit5:通道超上限\r\n"
+
"Bit6:通道超下限\r\n"
+
"Bit7:通道断线\r\n"
;
HCLogUtil
.
logBox
=
richTextBox1
;
}
}
private
void
btnInitBoard_Click
(
object
sender
,
EventArgs
e
)
private
void
btnInitBoard_Click
(
object
sender
,
EventArgs
e
)
{
{
...
@@ -611,6 +622,31 @@ namespace HuichuanLibrary
...
@@ -611,6 +622,31 @@ namespace HuichuanLibrary
timerIO
.
Enabled
=
isOk
;
timerIO
.
Enabled
=
isOk
;
axStsMonitor_timer
.
Enabled
=
isOk
;
axStsMonitor_timer
.
Enabled
=
isOk
;
groupBox5
.
Enabled
=
isOk
;
}
private
void
btnAdGet_Click
(
object
sender
,
EventArgs
e
)
{
if
(!
HCBoardManager
.
CardInitOk
())
{
MessageBox
.
Show
(
"板卡未初始化完成!"
);
return
;
}
txtAd1
.
Text
=
HCBoardManager
.
GetAdVal
(
0
).
ToString
();
txtAd2
.
Text
=
HCBoardManager
.
GetAdVal
(
1
).
ToString
();
txtAd3
.
Text
=
HCBoardManager
.
GetAdVal
(
2
).
ToString
();
txtAd4
.
Text
=
HCBoardManager
.
GetAdVal
(
3
).
ToString
();
txtAdSts1
.
Text
=
ConSts
(
HCBoardManager
.
GetAdSts
(
0
));
txtAdSts2
.
Text
=
ConSts
(
HCBoardManager
.
GetAdSts
(
1
));
txtAdSts3
.
Text
=
ConSts
(
HCBoardManager
.
GetAdSts
(
2
));
txtAdSts4
.
Text
=
ConSts
(
HCBoardManager
.
GetAdSts
(
3
));
}
private
string
ConSts
(
short
input
)
{
string
output
=
Convert
.
ToString
(
input
,
2
).
ToString
().
PadLeft
(
8
,
'0'
);
return
output
;
}
}
}
}
}
}
HuichuanLibrary/HCBoardManager.cs
查看文件 @
8566b42
...
@@ -544,6 +544,65 @@ namespace HuichuanLibrary
...
@@ -544,6 +544,65 @@ namespace HuichuanLibrary
#
endregion
#
endregion
#
region
AD
/
DA
控制
/// <summary>
/// 获取EtherCAT 第 adNo号的ad值
/// </summary>
/// <param name="adNo">ad的通道:0~配置个数</param>
/// <returns>获取AD的输入值</returns>
public
static
short
GetAdVal
(
short
adNo
)
{
if
(!
CardInitOk
())
{
return
0
;
}
Int16
adVal
=
0
;
UInt32
ret
=
ImcApi
.
IMC_GetEcatAdVal
(
nCardHandle
,
adNo
,
ref
adVal
);
if
(
ret
!=
0
)
{
ShowErrorLog
(
" adNo["
+
adNo
+
"] IMC_GetEcatAdVal FAIL, ErrorCode=0x"
+
ret
.
ToString
(
"x8"
));
return
0
;
}
return
adVal
;
}
/// <summary>
/// 获取EtherCAT 第 adNo号的状态
/// </summary>
/// <param name="adNo">ad的通道:0~配置个数</param>
/// <returns>获取AD的状态值</returns>
public
static
short
GetAdSts
(
short
adNo
)
{
if
(!
CardInitOk
())
{
return
0
;
}
Int16
adSts
=
0
;
UInt32
ret
=
ImcApi
.
IMC_GetEcatAdSts
(
nCardHandle
,
adNo
,
ref
adSts
);
if
(
ret
!=
0
)
{
ShowErrorLog
(
" adNo["
+
adNo
+
"] IMC_GetEcatAdSts FAIL, ErrorCode=0x"
+
ret
.
ToString
(
"x8"
));
return
0
;
}
return
adSts
;
}
public
static
AdStsInfo
GetAdStsInfo
(
short
sts
)
{
//【3】更新界面显示
AdStsInfo
stsInfo
=
new
AdStsInfo
();
stsInfo
.
VoltageSts
=
((
sts
&
0x01
)
==
0x01
)
?
1
:
0
;
//负载电压故障
stsInfo
.
ConnectSts
=
((
sts
&
0x02
)
==
0x02
)
?
1
:
0
;
//模拟芯片连接错误
stsInfo
.
NoSts
=
((
sts
&
0x04
)
==
0x04
)
?
1
:
0
;
//通道故障
stsInfo
.
Overflow
=
((
sts
&
0x08
)
==
0x08
)
?
1
:
0
;
//通道上溢
stsInfo
.
Underflow
=
((
sts
&
0x10
)
==
0x10
)
?
1
:
0
;
//通道下溢
stsInfo
.
PEL
=
((
sts
&
0x20
)
==
0x20
)
?
1
:
0
;
//通道超上限
stsInfo
.
NEL
=
((
sts
&
0x40
)
==
0x40
)
?
1
:
0
;
//通道超下限
stsInfo
.
OffLine
=
((
sts
&
0x80
)
==
0x80
)
?
1
:
0
;
//通道断线
return
stsInfo
;
}
#
endregion
private
static
void
ShowErrorLog
(
string
msg
)
private
static
void
ShowErrorLog
(
string
msg
)
{
{
CardMsg
=
BoardName
()
+
msg
;
CardMsg
=
BoardName
()
+
msg
;
...
@@ -562,6 +621,48 @@ namespace HuichuanLibrary
...
@@ -562,6 +621,48 @@ namespace HuichuanLibrary
HCLogUtil
.
debug
(
BoardName
()
+
msg
);
HCLogUtil
.
debug
(
BoardName
()
+
msg
);
}
}
}
}
public
class
AdStsInfo
{
/// <summary>
/// Bit0 ,负载电压故障,0:接入外部电源,1:未接入外部电源
/// </summary>
public
int
VoltageSts
=
-
1
;
/// <summary>
/// Bit1 ,模拟芯片连接错误,0:数字版与模拟板通讯正常,1:数字版与模拟板通讯错误
/// </summary>
public
int
ConnectSts
=
-
1
;
/// <summary>
/// Bit2:通道故障
/// </summary>
public
int
NoSts
=
-
1
;
/// <summary>
/// Bit3:通道上溢
/// </summary>
public
int
Overflow
=
-
1
;
/// <summary>
/// Bit4:通道下溢
/// </summary>
public
int
Underflow
=
-
1
;
/// <summary>
/// Bit5:通道超上限
/// </summary>
public
int
PEL
=
-
1
;
/// <summary>
/// Bit6:通道超下限
/// </summary>
public
int
NEL
=
-
1
;
/// <summary>
/// Bit7:通道断线
/// </summary>
public
int
OffLine
=
-
1
;
public
string
ToStr
()
{
return
"VoltageSts="
+
VoltageSts
+
",ConnectSts="
+
ConnectSts
+
",NoSts="
+
NoSts
+
",Overflow="
+
Overflow
+
",Underflow="
+
Underflow
+
",PEL="
+
PEL
+
",NEL="
+
NEL
+
",OffLine="
+
OffLine
;
}
}
public
class
AxisSts
public
class
AxisSts
{
{
/// <summary>
/// <summary>
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论