锁存器

This commit is contained in:
Admin 2026-12-04 00:02:16 +08:00
parent 0ef6af34bb
commit 7f169537a7
4 changed files with 189 additions and 25 deletions

View File

@ -24,21 +24,49 @@
<mah:WindowCommands> <mah:WindowCommands>
<!--<CheckBox Content="空跑模式" IsChecked="{Binding RunningMode}" />--> <!--<CheckBox Content="空跑模式" IsChecked="{Binding RunningMode}" />-->
<!--<ComboBox Grid.Row="4" Grid.Column="5" VerticalContentAlignment="Center" Margin="1" Text="请选择串口" ItemsSource="{Binding LightCOM.ComPortList}" SelectedItem="{Binding SerialProt}"/>--> <!--<ComboBox Grid.Row="4" Grid.Column="5" VerticalContentAlignment="Center" Margin="1" Text="请选择串口" ItemsSource="{Binding LightCOM.ComPortList}" SelectedItem="{Binding SerialProt}"/>-->
<TextBlock Text="{Binding LatchPos}" />
<Button Content="启动锁存器" Command="{Binding SoftltcInit}"/>
<Button Content="复位锁存器" Command="{Binding SoftltcReset}"/>
<Button Content="读取锁存器" Command="{Binding SoftltcRead}"/>
<Button Click="SubjectSwitch" Content="切换主题" /> <Button Click="SubjectSwitch" Content="切换主题" />
<Button Click="BackgroundSwitch" Content="切换背景" /> <Button Click="BackgroundSwitch" Content="切换背景" />
<Menu Background="{x:Null}"> <Menu Background="{x:Null}">
<MenuItem Background="{x:Null}" FontFamily="楷体" Foreground="White" Header="帮助"> <MenuItem Background="{x:Null}"
<MenuItem Name="menSystemSet" Background="AliceBlue" Click="menSystemSet_Click" Foreground="Black" Header="{Binding PermissionButtonName}" /> FontFamily="楷体" Foreground="White" Header="帮助">
<MenuItem Name="menPwdAlter" Background="AliceBlue" Click="menPwdAlter_Click" Foreground="Black" Header="修改密码" Visibility="{Binding AllVis}" /> <MenuItem Name="menSystemSet" Background="AliceBlue"
<MenuItem Background="AliceBlue" Visibility="{Binding AllVis}" Command="{Binding CountClearedCommand}" Foreground="Black" Header="生产数据清零" /> Click="menSystemSet_Click" Foreground="Black"
<MenuItem Background="AliceBlue" Visibility="{Binding AllVis}" Command="{Binding ManulTest}" CommandParameter="手动贴左" Foreground="Black" Header="手动贴左" /> Header="{Binding PermissionButtonName}" />
<MenuItem Background="AliceBlue" Visibility="{Binding AllVis}" Command="{Binding ManulTest}" CommandParameter="手动贴右" Foreground="Black" Header="手动贴右" /> <MenuItem Name="menPwdAlter" Background="AliceBlue"
<MenuItem Background="AliceBlue" Visibility="{Binding AllVis}" Command="{Binding ManulTest}" CommandParameter="手动检右" Foreground="Black" Header="手动检右" /> Click="menPwdAlter_Click" Foreground="Black" Header="修改密码"
<MenuItem Background="AliceBlue" Visibility="{Binding AllVis}" Command="{Binding ManulTest}" CommandParameter="手动压合" Foreground="Black" Header="手动压合" /> Visibility="{Binding AllVis}" />
<MenuItem Background="AliceBlue" Command="{Binding ManulTest}" CommandParameter="手动测试轴" Foreground="Black" Header="手动测试轴" /> <MenuItem Background="AliceBlue"
Command="{Binding CountClearedCommand}"
<CheckBox Content="启用安全门" FontFamily="楷体" IsChecked="{Binding EnableAnquanmen}" Visibility="{Binding AllVis}" /> Foreground="Black" Header="生产数据清零"
Visibility="{Binding AllVis}" />
<MenuItem Background="AliceBlue"
Command="{Binding ManulTest}"
CommandParameter="手动贴左" Foreground="Black" Header="手动贴左"
Visibility="{Binding AllVis}" />
<MenuItem Background="AliceBlue"
Command="{Binding ManulTest}"
CommandParameter="手动贴右" Foreground="Black" Header="手动贴右"
Visibility="{Binding AllVis}" />
<MenuItem Background="AliceBlue"
Command="{Binding ManulTest}"
CommandParameter="手动检右" Foreground="Black" Header="手动检右"
Visibility="{Binding AllVis}" />
<MenuItem Background="AliceBlue"
Command="{Binding ManulTest}"
CommandParameter="手动压合" Foreground="Black" Header="手动压合"
Visibility="{Binding AllVis}" />
<MenuItem Background="AliceBlue"
Command="{Binding ManulTest}"
CommandParameter="手动测试轴" Foreground="Black" Header="手动测试轴" />
<CheckBox Content="启用安全门" FontFamily="楷体"
IsChecked="{Binding EnableAnquanmen}"
Visibility="{Binding AllVis}" />
<ComboBox Height="26" VerticalAlignment="Center" <ComboBox Height="26" VerticalAlignment="Center"
HorizontalContentAlignment="Center" Background="#4CFFFFFF" HorizontalContentAlignment="Center" Background="#4CFFFFFF"
@ -59,7 +87,9 @@
<ColumnDefinition Width="{Binding GridWidth}" /> <ColumnDefinition Width="{Binding GridWidth}" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TabControl Background="Transparent" ItemsSource="{Binding TabItemList}" SelectedItem="{Binding SelectTabItem}" /> <TabControl Background="Transparent"
ItemsSource="{Binding TabItemList}"
SelectedItem="{Binding SelectTabItem}" />
<!--<GridSplitter Grid.Column="1" Background="Transparent"></GridSplitter>--> <!--<GridSplitter Grid.Column="1" Background="Transparent"></GridSplitter>-->
<Border Grid.Column="2"> <Border Grid.Column="2">
<MyNamespace:ControlPanel /> <MyNamespace:ControlPanel />

View File

@ -524,7 +524,47 @@ namespace Model.MotionControl
} }
/// <summary>
/// 锁存初始化完成
/// </summary>
public bool SoftltcInited { get; set; }
/// <summary>
/// 锁存初始化
/// </summary>
/// <param name="_Latch">锁存器号</param>
/// <param name="_InBit">输入位</param>
/// <param name="_Logic">逻辑 0 下降 1上升</param>
public virtual void SoftltcInit(ushort _Latch, ushort _InBit, ushort _Logic)
{
}
/// <summary>
/// 锁存重置
/// </summary>
/// <param name="_Latch">锁存器号</param>
public virtual void SoftltcReset(ushort _Latch)
{
}
/// <summary>
/// 锁存读取
/// </summary>
public virtual bool SoftltcRead(ushort _Latch, ref double _LatchPos)
{
return false;
}
/// <summary> /// <summary>
/// 初始化当前轴信息 /// 初始化当前轴信息
/// </summary> /// </summary>
@ -579,7 +619,7 @@ namespace Model.MotionControl
return true; return true;
} }
public virtual bool TorquemoveStart(int torque,double speed) public virtual bool TorquemoveStart(int torque, double speed)
{ {
return true; return true;
@ -591,7 +631,8 @@ namespace Model.MotionControl
return true; return true;
} }
public virtual void Reset() { public virtual void Reset()
{
} }

View File

@ -1,5 +1,6 @@
using Community; using Community;
using System; using System;
using System.Text.RegularExpressions;
namespace Model.MotionControl namespace Model.MotionControl
{ {
@ -526,24 +527,58 @@ namespace Model.MotionControl
#endregion #endregion
public override void Reset() public override void Reset()
{ {
if (MyCard != null) if (MyCard != null)
{ {
if (MyCard.InterfaceType == 2) if (MyCard.InterfaceType == 2)
{ {
} }
else if (MyCard.InterfaceType == 0) else if (MyCard.InterfaceType == 0)
{ {
HomeStep = GengralProcessEnum.Start; HomeStep = GengralProcessEnum.Start;
org_Successful = false; org_Successful = false;
LTDMC.dmc_clear_stop_reason(MyCard.CardID, this.Axis ); LTDMC.dmc_clear_stop_reason(MyCard.CardID, this.Axis);
LTDMC.nmc_clear_axis_errcode(MyCard.CardID, this.Axis ); LTDMC.nmc_clear_axis_errcode(MyCard.CardID, this.Axis);
} }
} }
} }
public override void SoftltcInit(ushort _Latch, ushort _InBit, ushort _Logic)
{
if (SoftltcInited == false)
{
// 配置锁存器: 上升沿触发,锁存"轴 Axis 的指令位置"
var r = LTDMC.dmc_softltc_set_mode(MyCard.CardID, _Latch, 1, 0, _InBit, _Logic, 0);
LTDMC.dmc_softltc_set_source(MyCard.CardID, _Latch, Axis, 0);
SoftltcInited = true;
}
}
public override void SoftltcReset(ushort _Latch)
{
LTDMC.dmc_softltc_reset(MyCard.CardID, _Latch);
}
public override bool SoftltcRead(ushort _Latch, ref double _LatchPos)
{
int number = 0;
LTDMC.dmc_softltc_get_number(MyCard.CardID, _Latch, Axis, ref number);
if(number>0)
{
_LatchPos = 0;
LTDMC.dmc_softltc_get_value_unit(MyCard.CardID, _Latch, Axis, ref _LatchPos);
return true;
}
return false;
}
} }
} }

View File

@ -7036,6 +7036,64 @@ namespace ViewModel
} }
#endregion #endregion
private DelegateCommand _SoftltcInit;
public DelegateCommand SoftltcInit =>
_SoftltcInit = _SoftltcInit ?? new DelegateCommand() { ExecuteAction = ExecuteSoftltcInit };
void ExecuteSoftltcInit(object obj)
{
var shaft = MCVM.AllShaftList.Where(w => w.ShaftName == "上料盘Z").FirstOrDefault();
if(shaft != null)
{
shaft.SoftltcInit(0, 5, 1);
}
}
private DelegateCommand _SoftltcReset;
public DelegateCommand SoftltcReset =>
_SoftltcReset = _SoftltcReset ?? new DelegateCommand() { ExecuteAction = ExecuteSoftltcReset };
void ExecuteSoftltcReset(object obj)
{
var shaft = MCVM.AllShaftList.Where(w => w.ShaftName == "上料盘Z").FirstOrDefault();
if (shaft != null)
{
shaft.SoftltcReset(0);
LatchPos = 0;
}
}
private DelegateCommand _SoftltcRead;
public DelegateCommand SoftltcRead =>
_SoftltcRead = _SoftltcRead ?? new DelegateCommand() { ExecuteAction = ExecuteSoftltcRead };
void ExecuteSoftltcRead(object obj)
{
var shaft = MCVM.AllShaftList.Where(w => w.ShaftName == "上料盘Z").FirstOrDefault();
if (shaft != null)
{
double latchPos = 0;
if (shaft.SoftltcRead(0, ref latchPos)) {
LatchPos = latchPos;
}
}
}
private double _LatchPos;
public double LatchPos
{
get { return _LatchPos; }
set
{
_LatchPos = value;
this.RaisePropertyChanged("LatchPos");
}
}
} }
} }