锁存器
This commit is contained in:
parent
0ef6af34bb
commit
7f169537a7
@ -24,20 +24,48 @@
|
||||
<mah:WindowCommands>
|
||||
<!--<CheckBox Content="空跑模式" IsChecked="{Binding RunningMode}" />-->
|
||||
<!--<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="BackgroundSwitch" Content="切换背景" />
|
||||
<Menu Background="{x:Null}">
|
||||
<MenuItem Background="{x:Null}" FontFamily="楷体" Foreground="White" Header="帮助">
|
||||
<MenuItem Name="menSystemSet" Background="AliceBlue" Click="menSystemSet_Click" Foreground="Black" Header="{Binding PermissionButtonName}" />
|
||||
<MenuItem Name="menPwdAlter" Background="AliceBlue" Click="menPwdAlter_Click" Foreground="Black" Header="修改密码" Visibility="{Binding AllVis}" />
|
||||
<MenuItem Background="AliceBlue" Visibility="{Binding AllVis}" Command="{Binding CountClearedCommand}" Foreground="Black" Header="生产数据清零" />
|
||||
<MenuItem Background="AliceBlue" Visibility="{Binding AllVis}" Command="{Binding ManulTest}" CommandParameter="手动贴左" Foreground="Black" Header="手动贴左" />
|
||||
<MenuItem Background="AliceBlue" Visibility="{Binding AllVis}" Command="{Binding ManulTest}" CommandParameter="手动贴右" Foreground="Black" Header="手动贴右" />
|
||||
<MenuItem Background="AliceBlue" Visibility="{Binding AllVis}" Command="{Binding ManulTest}" CommandParameter="手动检右" Foreground="Black" Header="手动检右" />
|
||||
<MenuItem Background="AliceBlue" Visibility="{Binding AllVis}" Command="{Binding ManulTest}" CommandParameter="手动压合" Foreground="Black" Header="手动压合" />
|
||||
<MenuItem Background="AliceBlue" Command="{Binding ManulTest}" CommandParameter="手动测试轴" Foreground="Black" Header="手动测试轴" />
|
||||
<MenuItem Background="{x:Null}"
|
||||
FontFamily="楷体" Foreground="White" Header="帮助">
|
||||
<MenuItem Name="menSystemSet" Background="AliceBlue"
|
||||
Click="menSystemSet_Click" Foreground="Black"
|
||||
Header="{Binding PermissionButtonName}" />
|
||||
<MenuItem Name="menPwdAlter" Background="AliceBlue"
|
||||
Click="menPwdAlter_Click" Foreground="Black" Header="修改密码"
|
||||
Visibility="{Binding AllVis}" />
|
||||
<MenuItem Background="AliceBlue"
|
||||
Command="{Binding CountClearedCommand}"
|
||||
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}" />
|
||||
<CheckBox Content="启用安全门" FontFamily="楷体"
|
||||
IsChecked="{Binding EnableAnquanmen}"
|
||||
Visibility="{Binding AllVis}" />
|
||||
|
||||
|
||||
<ComboBox Height="26" VerticalAlignment="Center"
|
||||
@ -59,7 +87,9 @@
|
||||
<ColumnDefinition Width="{Binding GridWidth}" />
|
||||
|
||||
</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>-->
|
||||
<Border Grid.Column="2">
|
||||
<MyNamespace:ControlPanel />
|
||||
|
||||
@ -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>
|
||||
@ -579,7 +619,7 @@ namespace Model.MotionControl
|
||||
|
||||
return true;
|
||||
}
|
||||
public virtual bool TorquemoveStart(int torque,double speed)
|
||||
public virtual bool TorquemoveStart(int torque, double speed)
|
||||
{
|
||||
|
||||
return true;
|
||||
@ -591,7 +631,8 @@ namespace Model.MotionControl
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Reset() {
|
||||
public virtual void Reset()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Community;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Model.MotionControl
|
||||
{
|
||||
@ -539,11 +540,45 @@ namespace Model.MotionControl
|
||||
{
|
||||
HomeStep = GengralProcessEnum.Start;
|
||||
org_Successful = false;
|
||||
LTDMC.dmc_clear_stop_reason(MyCard.CardID, this.Axis );
|
||||
LTDMC.nmc_clear_axis_errcode(MyCard.CardID, this.Axis );
|
||||
LTDMC.dmc_clear_stop_reason(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7036,6 +7036,64 @@ namespace ViewModel
|
||||
}
|
||||
|
||||
#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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user