Selaa lähdekoodia

小炒

master
NXX 1 vuosi sitten
vanhempi
commit
1e8d0aee3d
6 muutettua tiedostoa jossa 300 lisäystä ja 118 poistoa
  1. +112
    -26
      BPASmartClient.MorkF/Control_MorkF.cs
  2. +9
    -0
      BPASmartClient.MorkF/ML_MorkF.cs
  3. +43
    -33
      BPASmartClient.MorkF/View/LocalMenu.xaml
  4. +73
    -30
      BPASmartClient.MorkF/View/MaterialCalibration.xaml
  5. +62
    -29
      BPASmartClient.MorkF/ViewModel/MaterialCalibrationViewModel.cs
  6. +1
    -0
      BPASmartClient/MainWindow.xaml.cs

+ 112
- 26
BPASmartClient.MorkF/Control_MorkF.cs Näytä tiedosto

@@ -35,7 +35,7 @@ namespace BPASmartClient.MorkF
/// <summary>
/// 菜品库while循环最大sleep次数
/// </summary>
private const int materialSleepCount = 900;
private const int materialSleepCount = 600;

/// <summary>
/// 菜品库while循环每次sleep时间
@@ -61,7 +61,7 @@ namespace BPASmartClient.MorkF
/// <summary>
/// 菜品盒坐标系高度
/// </summary>
private const int materialBoxHeight = 9500;
private const int materialBoxHeight = 9700;

//传感器1到菜品库的高度(厘米)
private const int materialLaserHighCM_1 = 22;
@@ -346,7 +346,15 @@ namespace BPASmartClient.MorkF
ml_morkf.PawArrivePortThree = bools[2];
}
}), 2);

//获取爪子伸出退回到位
GetStatus("M10.6", new Action<object>((objects) =>
{
if (objects is bool[] bools && bools.Length == 2)
{
ml_morkf.PawOutComplete = bools[0];
ml_morkf.PawInComplete = bools[1];
}
}), 2);
//获取总初始化完成
GetStatus("M10.2", new Action<object>((objects) =>
{
@@ -478,8 +486,21 @@ namespace BPASmartClient.MorkF
GetDistance_3();
}), "GetDistance_3");
}), "GetDistance_3");
ActionManage.GetInstance.Register(PawExtend, "PawTurnFront");
ActionManage.GetInstance.Register(PawShrink, "PawTurnBack");
ActionManage.GetInstance.Register(new Action(() =>
{
ThreadManage.GetInstance().Start(new Action(() =>
{
PawExtend();
}), "PawTurnFront");
}), "PawTurnFront");
ActionManage.GetInstance.Register(new Action(() =>
{
ThreadManage.GetInstance().Start(new Action(() =>
{
PawShrink();
}), "PawTurnBack");
}), "PawTurnBack");
ActionManage.GetInstance.Register(new Action<object>((list) =>
{
ThreadManage.GetInstance().Start(new Action(() =>
@@ -968,33 +989,54 @@ namespace BPASmartClient.MorkF
/// 爪子伸出
/// </summary>
/// <param name="o">电磁阀启停:true:启动。false:停止。</param>
public void PawExtend()
public bool PawExtend()
{
if (!ml_morkf.InitialComplete)
{
MessageLog.GetInstance.ShowEx("爪子伸出错误,菜品库未初始化");
return;
return false;
}
Thread.Sleep(500);
MaterailLibrary_Write("M0.6", true);
//等待爪子伸出延时4s
Thread.Sleep(6000);
for (int i = 0; i < materialSleepCount && !ml_morkf.PawOutComplete; i++)//潘华小炒没有夹爪到位功能
{
Thread.Sleep(materialSleepTime);
if (i >= materialSleepCount - 1)
{
MessageLog.GetInstance.ShowEx("爪子伸出超时");
return false;
}
}
return true;
////等待爪子伸出延时4s
//Thread.Sleep(6000);
}
/// <summary>
/// 爪子收缩
/// </summary>
/// <param name="o">电磁阀启停:true:启动。false:停止。</param>
public void PawShrink()
public bool PawShrink()
{
if (!ml_morkf.InitialComplete)
{
MessageLog.GetInstance.ShowEx("爪子伸出错误,菜品库未初始化");
return;
return false;
}

MaterailLibrary_Write("M0.7", true);
Thread.Sleep(500);
for (int i = 0; i < materialSleepCount && !ml_morkf.PawInComplete; i++)//潘华小炒没有夹爪到位功能
{
Thread.Sleep(materialSleepTime);
if (i >= materialSleepCount - 1)
{
MessageLog.GetInstance.ShowEx("爪子伸出超时");
return false;
}
}
return true;
//等待爪子收缩延时4s
Thread.Sleep(6000);
//Thread.Sleep(6000);
}
/// <summary>
/// 电磁阀启停
@@ -1033,6 +1075,10 @@ namespace BPASmartClient.MorkF
Thread.Sleep(materialSleepTime);
if (i >= materialSleepCount - 1)
{
if (i == 10)
{
MaterailLibrary_Write("M1.0", true);
}
MessageLog.GetInstance.ShowEx("爪子去到1号位超时");
return false;
}
@@ -1063,6 +1109,10 @@ namespace BPASmartClient.MorkF
Thread.Sleep(materialSleepTime);
if (i >= materialSleepCount - 1)
{
if (i == 10)
{
MaterailLibrary_Write("M1.1", true);
}
MessageLog.GetInstance.ShowEx("爪子去到2号位超时");
return false;
}
@@ -1090,10 +1140,14 @@ namespace BPASmartClient.MorkF
for (int i = 0; i < materialSleepCount && !ml_morkf.PawArrivePortThree; i++)
{
Thread.Sleep(materialSleepTime);
if(i == 30)
{
MaterailLibrary_Write("M1.2", true);
}
if (i >= materialSleepCount - 1)
{
MessageLog.GetInstance.ShowEx("爪子去到3号位超时");
return false;
}
}
if (!ml_morkf.PawPositon_3)
@@ -1243,6 +1297,12 @@ namespace BPASmartClient.MorkF
return false;
}

if (x>212000|| y >240000)
{
MessageLog.GetInstance.ShowEx("机械臂移动超出范围");
return false;
}

//取反
x = 0 - Math.Abs(x);
y = 0 - Math.Abs(y);
@@ -1374,9 +1434,9 @@ namespace BPASmartClient.MorkF
Thread.Sleep(1000);

//获取传感器的距离,转换成坐标系的点
//int laserHigh = ml_morkf.LaserDistance;
int laserHigh = ml_morkf.LaserDistance;

int laserHigh = 400;
//秦工要求读取后置0
WriteDistance(0);

@@ -1396,7 +1456,7 @@ namespace BPASmartClient.MorkF
}

//设置到传感器感应的距离处
if (!SetArmPosition(x, y))
if (!SetArmPosition(x - moveX, y))
{
return false;
}
@@ -1414,7 +1474,11 @@ namespace BPASmartClient.MorkF
}

//伸出爪子
PawExtend();
if (!PawExtend())
{
return false;
}

//移动前开启电磁阀
Electromagnetism(new List<bool> { false });
@@ -1467,10 +1531,12 @@ namespace BPASmartClient.MorkF
// //收缩爪子
// PawShrink();
//}), "GetMaterialPawShrink");
PawShrink();

//收缩爪子
if (!PawShrink()) return false;

//判断炒锅是否可以放盒
for (int i = 0; materialSleepCount > i && !morkFs[fryIndex].FryPot1_HOBTPut; i++)
for (int i = 0; materialSleepCount > i && !morkFs[fryNum].FryPot1_HOBTPut; i++)
{
Thread.Sleep(materialSleepTime);
if (i >= materialSleepCount - 1)
@@ -1520,8 +1586,12 @@ namespace BPASmartClient.MorkF
return false;
}

//伸出爪子
PawExtend();
if (!PawExtend())
{
return false;
}

Thread.Sleep(300);

@@ -1530,7 +1600,7 @@ namespace BPASmartClient.MorkF
Thread.Sleep(300);

//收缩爪子
PawShrink();
if (!PawShrink()) return false;

//设置到炒锅i出菜处
if (!SetArmPosition(x + materialToFryDistance, y))
@@ -1578,10 +1648,13 @@ namespace BPASmartClient.MorkF
Electromagnetism(new List<bool> { true });

//爪子收回
PawShrink();
if (!PawShrink())
{
return false;
}

//爪子去2号点位
if(!PawToPoint2())
if (!PawToPoint2())
{
return false;
}
@@ -1670,8 +1743,10 @@ namespace BPASmartClient.MorkF
Laser2CoordinateState laser2CoordinateState = LaserDistance2MaterialCount(distance, x, out boxCount);
if (laser2CoordinateState == Laser2CoordinateState.MaterialNormal)
{
int compensateHeight = boxCount > 1 ? 500 : 0;//补偿高度,超过1层盒子增加补偿
//盒子高度计算除去起始位置的那个盒子
x_high = (boxCount - 1) * materialBoxHeight;
x_high = (boxCount - 1) * materialBoxHeight + compensateHeight;
}
return laser2CoordinateState;

@@ -1722,6 +1797,7 @@ namespace BPASmartClient.MorkF
if(heightDifferent < 0)
{
MessageLog.GetInstance.ShowEx($"菜品库检测{x}处的菜品量时,传感器获取的高度差为负数,请校准该层高度");
return Laser2CoordinateState.MaterialEmpty; ;
}

//盒子高度为45,但是需要考虑到误差,不足35,则认为为空
@@ -2542,7 +2618,7 @@ namespace BPASmartClient.MorkF

//更新
morkFs[i].UpdateProcess(potActions);
switch (potActions.Actions)
{
case nameof(StirFryPotActionEnum.加热开启):
@@ -2608,6 +2684,16 @@ namespace BPASmartClient.MorkF
MessageLog.GetInstance.Show(potActions.Actions);
break;
case nameof(StirFryPotActionEnum.取原料):
if(potActions.SeasoningLists[0].Loc == 1 ||
potActions.SeasoningLists[0].Loc == 9 ||
potActions.SeasoningLists[0].Loc == 10 ||
potActions.SeasoningLists[0].Loc == 18 ||
potActions.SeasoningLists[0].Loc == 19 ||
potActions.SeasoningLists[0].Loc == 27 )
{
MessageLog.GetInstance.ShowEx("该取料位置禁止使用");
return;
}
//炒锅取菜状态置为未取到
morkFs[i].GetMaterialComplete = false;



+ 9
- 0
BPASmartClient.MorkF/ML_MorkF.cs Näytä tiedosto

@@ -35,6 +35,15 @@ namespace BPASmartClient.MorkF
/// </summary>
public bool InitialComplete { get; set; }

/// <summary>
/// 爪子伸出到位
/// </summary>
public bool PawOutComplete { get; set; }
/// <summary>
/// 爪子缩回到位
/// </summary>
public bool PawInComplete { get; set; }

private bool _ArriveComplete = false;
/// <summary>
/// 定位到达,上升沿捕获需要特殊处理


+ 43
- 33
BPASmartClient.MorkF/View/LocalMenu.xaml Näytä tiedosto

@@ -7,50 +7,61 @@
xmlns:local="clr-namespace:BPASmartClient.MorkF.View"
xmlns:vm="clr-namespace:BPASmartClient.MorkF.ViewModel"
mc:Ignorable="d"
Title="LocalMenu" Height="800" Width="800" WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="True" MouseLeftButtonDown="Window_MouseLeftButtonDown">
Title="LocalMenu" Height="800" Width="800" WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="True" MouseLeftButtonDown="Window_MouseLeftButtonDown" Background="Gray"
>
<Window.DataContext>
<vm:LocalMenuViewModel/>
</Window.DataContext>
<Window.Resources>
<Style TargetType="ListBoxItem" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border BorderBrush="Black" BorderThickness="0" Background="White">
<Grid Width="600" HorizontalAlignment="Center" VerticalAlignment="Center" >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Text="{Binding FryTime}" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Text="{Binding During}" Margin="10,0"/>
<ComboBox Grid.Column="2" Width="120" ItemsSource="{Binding DataContext.strPotActions , RelativeSource={RelativeSource AncestorType=Window,Mode=FindAncestor}}"
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/GenricStyle.xaml" />
<ResourceDictionary Source="/BPASmartClient.CustomResource;component/Themes/MyStyle.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="ListBoxItem" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border BorderBrush="Black" BorderThickness="0" Background="Transparent">
<Grid Width="600" HorizontalAlignment="Center" VerticalAlignment="Center" >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Text="{Binding FryTime}" HorizontalAlignment="Center" VerticalAlignment="Center" />
<TextBox Grid.Column="1" Text="{Binding During}" Margin="10,0"/>
<ComboBox Grid.Column="2" Width="120" ItemsSource="{Binding DataContext.strPotActions , RelativeSource={RelativeSource AncestorType=Window,Mode=FindAncestor}}"
SelectedValue="{Binding Actions}" Margin="10,0"/>
<TextBox Grid.Column="3" Text="{Binding SeasoningLists[0].Loc}" Margin="10,0"/>
<TextBox Grid.Column="4" Text="{Binding SeasoningLists[0].Qty}" Margin="10,0"/>
<Button Grid.Column="5" Content="删除" Margin="10,0" HorizontalAlignment="Center"
<TextBox Grid.Column="3" Text="{Binding SeasoningLists[0].Loc}" Margin="10,0"/>
<TextBox Grid.Column="4" Text="{Binding SeasoningLists[0].Qty}" Margin="10,0"/>
<Button Grid.Column="5" Content="删除" Margin="10,0" HorizontalAlignment="Center"
Command="{Binding DataContext.Delete, RelativeSource={RelativeSource AncestorType=Window,Mode=FindAncestor}}"
CommandParameter="{Binding DataContext, RelativeSource={RelativeSource AncestorType=ListBoxItem,Mode=FindAncestor}}"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid>
</Border>

</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid >
<Grid.Background>
<ImageBrush ImageSource="/BPASmartClient.CustomResource;component/Image/窗体样式/From/内部背景.png"/>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="80"/>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<ComboBox Name="Materials" SelectionChanged="Materials_SelectionChanged" ItemsSource="{Binding MaterialNames}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<StackPanel Margin="10,20,10,0" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<ComboBox Name="Materials" Width="100" Height="40" SelectionChanged="Materials_SelectionChanged" ItemsSource="{Binding MaterialNames}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox Text="{Binding MaterialName}" Width="80" Height="40" Margin="10,0"/>
<Button Content="增加菜谱" Command="{Binding AddMaterial}" Width="80" Height="40" Margin="10,0"/>
<Button Content="下单" Command="{Binding NewStartLocalMaterial}" Width="80" Height="40" Margin="10,0"/>
@@ -79,7 +90,6 @@
</Grid>
<ListBox x:Name="listview1" Grid.Row="2" BorderBrush="Black" BorderThickness="0" HorizontalAlignment="Center" AllowDrop="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding PotActionStep}" Margin=" 10" Background="Transparent"
>
</ListBox>


+ 73
- 30
BPASmartClient.MorkF/View/MaterialCalibration.xaml Näytä tiedosto

@@ -82,6 +82,10 @@
<Grid>
<ScrollViewer>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="0.4*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
@@ -627,7 +631,7 @@
<TextBlock Text="x轴:" Margin="10,0"/>
<TextBox Grid.Column="1" Text="{Binding TwentySixX}" Width="100"/>
<TextBlock Grid.Column="2" Text="Y轴:" Margin="10,0"/>
<TextBox Grid.Column="3" Text="{Binding SeventeenY}" Width="100"/>
<TextBox Grid.Column="3" Text="{Binding TwentySixY}" Width="100"/>
</Grid>
</Grid>
<Grid>
@@ -657,6 +661,8 @@
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<WrapPanel>
<Grid>
@@ -725,6 +731,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<RadioButton Content="第二层菜品库出菜位置" Margin="5,0" IsEnabled="True" IsChecked="{Binding PositionMaterialTwo}" GroupName="MaterialPosition" HorizontalAlignment="Center"/>
<Grid Grid.Row="1">
@@ -740,6 +747,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<RadioButton Content="第三层菜品库出菜位置" Margin="5,0" IsEnabled="True" IsChecked="{Binding PositionMaterialThree}" GroupName="MaterialPosition" HorizontalAlignment="Center"/>
<Grid Grid.Row="1">
@@ -749,56 +757,91 @@
<TextBlock Grid.Column="2" Text="Y轴:" Margin="10,0"/>
<TextBox Grid.Column="3" Text="0" IsEnabled="False" Width="100"/>
</WrapPanel>
</Grid>
</Grid>

</WrapPanel>
<WrapPanel Grid.Row="2" Margin="10,10">
<Button Content="感应器1标准位置" Margin="10,0,10,0" Command="{Binding GetDistance_1}" Cursor="Hand"/>
<TextBox Grid.Column="1" Text="{Binding Distance_1}" Margin="10,0,10,0" Width="100"/>
<Button Content="感应器2标准位置" Margin="10,0,10,0" Command="{Binding GetDistance_2}"/>
<TextBox Grid.Column="1" Text="{Binding Distance_2}" Margin="10,0,10,0" Width="100"/>
<Button Content="感应器3标准位置" Margin="10,0,10,0" Command="{Binding GetDistance_3}"/>
<TextBox Grid.Column="1" Text="{Binding Distance_3}" Margin="10,0,10,0" Width="100"/>
</WrapPanel>
<WrapPanel Grid.Row="3">
<Button Content="全部位置保存" Margin="10,0,50,0" Height="40" Command="{Binding SaveCoordinate}" Cursor="Hand"/>
<Button Content="全部位置读取" Height="40" Command="{Binding ReadCoordinate}"/>
</WrapPanel>
</Grid>
</GroupBox>
<GroupBox Grid.Row="4" Header="操作" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<WrapPanel>
<GroupBox Grid.Row="0" Grid.RowSpan="3" Grid.Column="1" Header="操作" FontSize="15" Foreground="Aqua" VerticalAlignment="Center" >
<StackPanel >
<WrapPanel Margin="10,10">
<Button Content="菜品库初始化" Margin="10,0,5,0" Command="{Binding FoodLibInit}"/>
</WrapPanel>
<WrapPanel Grid.Row="1" Margin="10,10">
<Button Content="电磁阀启动" Margin="10,0,5,0" Command="{Binding StartElectromagnetism}"/>
<Button Content="电磁阀停止" Margin="10,0,5,0" Command="{Binding StopElectromagnetism}"/>
<Button Content="夹爪伸出" Command="{Binding PawTurnFront}" Margin="5,0" Cursor="Hand"/>
<Button Content="夹爪收缩" Command="{Binding PawTurnBack}" Margin="5,0" Cursor="Hand"/>
</WrapPanel>
<WrapPanel Grid.Row="2" Margin="10,10">
<Button Content="夹爪伸出" Command="{Binding PawTurnFront}" Margin="10,0,5,0" Cursor="Hand"/>
<Button Content="夹爪收缩" Command="{Binding PawTurnBack}" Margin="10,0,5,0" Cursor="Hand"/>
</WrapPanel>
<WrapPanel Grid.Row="3" Margin="10,10">
<TextBlock Text="夹爪位置:" Margin="10,0,5,0" />
<RadioButton Content="位置1" Margin="5,0" IsEnabled="True" IsChecked="{Binding PawPositon1}" Command="{Binding PawToPoint1}" GroupName="PawTurn"/>
<RadioButton Content="位置2" Margin="5,0" IsEnabled="True" IsChecked="{Binding PawPositon2}" Command="{Binding PawToPoint2}" GroupName="PawTurn"/>
<RadioButton Content="位置3" Margin="5,0 " IsEnabled="True" IsChecked="{Binding PawPositon3}" Command="{Binding PawToPoint3}" GroupName="PawTurn"/>
</WrapPanel>
<WrapPanel Grid.Row="1">
<Button Content="感应器1测距" Margin="5,0" Command="{Binding GetDistance_1}" Cursor="Hand"/>
<TextBox Grid.Column="1" Text="{Binding Distance_1}" Width="100"/>
<Button Content="感应器2测距" Margin="5,0" Command="{Binding GetDistance_2}"/>
<TextBox Grid.Column="1" Text="{Binding Distance_2}" Width="100"/>
<Button Content="感应器3测距" Margin="5,0" Command="{Binding GetDistance_3}"/>
<TextBox Grid.Column="1" Text="{Binding Distance_3}" Width="100"/>
</WrapPanel>
<WrapPanel Grid.Row="2">
<TextBlock Text="移动系数:"></TextBlock>
<WrapPanel Grid.Row="4" Margin="10,10">
<TextBlock Text="移动系数:" Margin="10,0,0,0"></TextBlock>
<TextBox
Style="{DynamicResource UserTextBoxStyle}"
Foreground="#a2c2e8" Text="{Binding Str}"/>
<TextBlock Text="移动方式:" Margin="50,0,0,0"></TextBlock>
Style="{DynamicResource UserTextBoxStyle}"
Foreground="#a2c2e8" Text="{Binding Str}"/>
</WrapPanel>
<WrapPanel Grid.Row="5" Margin="10,10">
<TextBlock Text="移动方式:" Margin="10,0,0,0"></TextBlock>
<RadioButton Content="上" Margin="5,0" IsChecked="{Binding Up}" GroupName="ArmRun"/>
<RadioButton Content="下" Margin="5,0" IsChecked="{Binding Down}" GroupName="ArmRun"/>
<RadioButton Content="左" Margin="5,0 " IsChecked="{Binding Left}" GroupName="ArmRun"/>
<RadioButton Content="右" Margin="5,0 " IsChecked="{Binding Right}" GroupName="ArmRun"/>
<RadioButton Content="定点" Margin="5,0 " IsChecked="{Binding Point}" GroupName="ArmRun"/>
<Button Content="移动" Command="{Binding SetNowPosition}"/>

</WrapPanel>
<WrapPanel Grid.Row="3" Cursor="">
<Button Content="自动计算" Margin="20,0,50,0" Command="{Binding AutoCalculation}"/>
<Button Content="保存" Margin="20,0,50,0" Command="{Binding SaveCoordinate}"/>
<Button Content="读取" Command="{Binding ReadCoordinate}"/>
<WrapPanel Grid.Row="6" Margin="10,10">
<Button Content="自动计算" Margin="10,0,50,0" Command="{Binding AutoCalculation}"/>

</WrapPanel >
<WrapPanel Grid.Row="7" Margin="10,10">
<TextBlock Text="取料手臂设定位置" Margin="10,0,10,10"/>
<TextBlock Text="X:" Margin="5,0"/>
<TextBox Text="{Binding SettingX}" Width="70" Margin="5,0" VerticalAlignment="Center" />
<TextBlock Text="Y:" Margin="5,0"/>
<TextBox Text="{Binding SettingY}" Width="70" Margin="5,0" VerticalAlignment="Center" />
<Button Content="移动" Command="{Binding SetArmPosition}" Margin="5,0,10,0" Cursor="Hand"/>
<TextBlock Text="移动速度:" Margin="5,0"/>
<TextBox Text="{Binding MoveSpeed}" Width="70" Margin="5,0" VerticalAlignment="Center" />
<Button Content="设定" Command="{Binding SetSpeed}" Cursor="Hand" Margin="5,0,10,0" />
</WrapPanel>
</Grid>
<!--<WrapPanel Margin="10">
<Button Content="感应器1测距" Margin="5,0" Command="{Binding GetTestDistance_1}" Cursor="Hand"/>
<TextBox Text="{Binding SensingDistance_1}" Margin="5,0" Width="60" IsReadOnly="True"/>
<Button Content="感应器2测距" Margin="5,0" Command="{Binding GetTestDistance_2}"/>
<TextBox Text="{Binding SensingDistance_2}" Margin="5,0" Width="60" IsReadOnly="True"/>
<Button Content="感应器3测距" Margin="5,0" Command="{Binding GetTestDistance_3}"/>
<TextBox Text="{Binding SensingDistance_3}" Margin="5,0" Width="60" IsReadOnly="True"/>
</WrapPanel>-->
</StackPanel>
</GroupBox>
</Grid>
</ScrollViewer>


+ 62
- 29
BPASmartClient.MorkF/ViewModel/MaterialCalibrationViewModel.cs Näytä tiedosto

@@ -280,6 +280,30 @@ namespace BPASmartClient.MorkF.ViewModel
private int _Distance_2;
public int Distance_3 { get { return _Distance_3; } set { _Distance_3 = value; OnPropertyChanged(); } }
private int _Distance_3;
#endregion

#region 控制
public int SettingX { get { return _settingX; } set { _settingX = value; OnPropertyChanged(); } }
private int _settingX = 0;
public int SettingY { get { return _settingY; } set { _settingY = value; OnPropertyChanged(); } }
private int _settingY = 0;
public int MoveSpeed { get { return _moveSpeed; } set { _moveSpeed = value; OnPropertyChanged(); } }
private int _moveSpeed;

public int SensingDistance_1 { get { return _sensingDistance_1; } set { _sensingDistance_1 = value; OnPropertyChanged(); } }
private int _sensingDistance_1;
public int SensingDistance_2 { get { return _sensingDistance_2; } set { _sensingDistance_2 = value; OnPropertyChanged(); } }
private int _sensingDistance_2;
public int SensingDistance_3 { get { return _sensingDistance_3; } set { _sensingDistance_3 = value; OnPropertyChanged(); } }
private int _sensingDistance_3;

public RelayCommand SetSpeed { get; set; }//速度设定
public RelayCommand SetArmPosition { get; set; }//机器臂位置设定

public RelayCommand GetTestDistance_1 { get; set; }//获取感应器距离1
public RelayCommand GetTestDistance_2 { get; set; }//获取感应器距离2
public RelayCommand GetTestDistance_3 { get; set; }//获取感应器距离3

#endregion
public bool Up { get { return _Up; } set { _Up = value; OnPropertyChanged(); } }
private bool _Up;
@@ -355,9 +379,9 @@ namespace BPASmartClient.MorkF.ViewModel
public RelayCommand StopElectromagnetism { get; set; }
public RelayCommand PawTurnFront { get; set; }//夹爪正转
public RelayCommand PawTurnBack { get; set; }//夹爪反转
public RelayCommand PawToPoint1 { get; set; }//感应测距1
public RelayCommand PawToPoint2 { get; set; }//感应测距2
public RelayCommand PawToPoint3 { get; set; }//感应测距3
public RelayCommand PawToPoint1 { get; set; }//夹爪位置1
public RelayCommand PawToPoint2 { get; set; }//夹爪位置2
public RelayCommand PawToPoint3 { get; set; }//夹爪位置3
public RelayCommand GetDistance_1 { get; set; }//感应测距1
public RelayCommand GetDistance_2 { get; set; }//感应测距2
public RelayCommand GetDistance_3 { get; set; }//感应测距3
@@ -844,10 +868,10 @@ namespace BPASmartClient.MorkF.ViewModel
return;
}

if (PositionOne)
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> {"1", OneX + OperationX, OneY + OperationY });//设定机械臂当前位置
}
//if (PositionOne)
//{
// ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> {"1", OneX + OperationX, OneY + OperationY });//设定机械臂当前位置
//}
if (PositionTwo)
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "2", TwoX + OperationX, TwoY + OperationY });//设定机械臂当前位置
@@ -876,14 +900,14 @@ namespace BPASmartClient.MorkF.ViewModel
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "8", EightX + OperationX, EightY + OperationY });//设定机械臂当前位置
}
if (PositionNine)
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "9", NineX + OperationX, NineY + OperationY });//设定机械臂当前位置
}
if (PositionTen)
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "10", TenX + OperationX, TenY + OperationY });//设定机械臂当前位置
}
//if (PositionNine)
//{
// ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "9", NineX + OperationX, NineY + OperationY });//设定机械臂当前位置
//}
//if (PositionTen)
//{
// ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "10", TenX + OperationX, TenY + OperationY });//设定机械臂当前位置
//}
if (PositionEleven)
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "11", ElevenX + OperationX, ElevenY + OperationY });//设定机械臂当前位置
@@ -912,14 +936,14 @@ namespace BPASmartClient.MorkF.ViewModel
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "17", SeventeenX + OperationX, SeventeenY + OperationY });//设定机械臂当前位置
}
if (PositionEighteen)
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "18", EighteenX + OperationX, EighteenY + OperationY });//设定机械臂当前位置
}
if (PositionNineteen)
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "19", NineteenX + OperationX, NineteenY + OperationY });//设定机械臂当前位置
}
//if (PositionEighteen)
//{
// ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "18", EighteenX + OperationX, EighteenY + OperationY });//设定机械臂当前位置
//}
//if (PositionNineteen)
//{
// ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "19", NineteenX + OperationX, NineteenY + OperationY });//设定机械臂当前位置
//}
if (PositionTwenty)
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "20", TwentyX + OperationX, TwentyY + OperationY });//设定机械臂当前位置
@@ -948,10 +972,10 @@ namespace BPASmartClient.MorkF.ViewModel
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "26", TwentySixX + OperationX, TwentySixY + OperationY });//设定机械臂当前位置
}
if (PositionTwentySeven)
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "27", TwentySevenX + OperationX, TwentySevenY + OperationY });//设定机械臂当前位置
}
//if (PositionTwentySeven)
//{
// ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "27", TwentySevenX + OperationX, TwentySevenY + OperationY });//设定机械臂当前位置
//}
if (PositionMaterialHeight)
{
ActionManage.GetInstance.Send("CalibrationCoordination", new List<object> { "MaterialHeight", MaterialHeightX + OperationX, MaterialHeightY + OperationY });//设定机械臂当前位置
@@ -987,12 +1011,21 @@ namespace BPASmartClient.MorkF.ViewModel
PawToPoint1 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint1"); });//爪子去1号位
PawToPoint2 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint2"); });//爪子去2号位
PawToPoint3 = new RelayCommand(() => { ActionManage.GetInstance.Send("PawToPoint3"); });//爪子去3号位
PawTurnFront = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnFront"); });//夹爪正转
PawTurnBack = new RelayCommand(() => { ActionManage.GetInstance.Send("PawTurnBack"); });//夹爪反转
PawTurnFront = new RelayCommand(() => {
ActionManage.GetInstance.Send("PawTurnFront");
});//夹爪伸出
PawTurnBack = new RelayCommand(() => {
ActionManage.GetInstance.Send("PawTurnBack");
});//夹爪收缩
GetDistance_1 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_1"); });//感应距离1
GetDistance_2 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_2"); });//感应距离2
GetDistance_3 = new RelayCommand(() => { ActionManage.GetInstance.Send("GetDistance_3"); });//感应距离3

SetSpeed = new RelayCommand(() => { ActionManage.GetInstance.Send("SetSpeed", new List<int> { MoveSpeed }); });//速度设定
SetArmPosition = new RelayCommand(() => {
ActionManage.GetInstance.Send("SetArmPosition", new List<int> { SettingX, SettingY });
});//设定移动位置

PhysicalMaterialCoordinate();
ActionManage.GetInstance.Register(new Action<object>((o) =>
{


+ 1
- 0
BPASmartClient/MainWindow.xaml.cs Näytä tiedosto

@@ -66,6 +66,7 @@ namespace BPASmartClient
if(res == MessageBoxResult.OK)
{
this.Close();
Application.Current.Shutdown();
}
};


Ladataan…
Peruuta
Tallenna