xml - Jog Button
Code: Select all
<Button
Grid.Row="0"
Grid.Column="1"
Width="170"
Margin="5"
Content="Jog +"
FontSize="30"
Style="{DynamicResource myButton}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown">
<ei:CallMethodAction MethodName="JogPlusRunSend" TargetObject="{Binding}" />
</i:EventTrigger>
<i:EventTrigger EventName="PreviewMouseUp">
<ei:CallMethodAction MethodName="JogStopSend" TargetObject="{Binding}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
Code: Select all
public void JogPlusRunSend(object sender, MouseButtonEventArgs e)
{ model.kflop.JogRun(currAxis, 1, currRB); }
public void JogMinusRunSend(object sender, MouseButtonEventArgs e)
{ model.kflop.JogRun(currAxis, -1, currRB); }
public void JogStopSend(object sender, MouseButtonEventArgs e)
{ model.kflop.JogStop(currAxis); }
Code: Select all
//model.kflop
/************************************************************************************************************************/
// Jog Run
/************************************************************************************************************************/
public void JogRun(Axis axes, int curDir, int curStep)
{
if (!Excecute)
{
Excecute = true;
// определяем направление
string dir = string.Empty;
if (curDir == -1)
dir = "-";
// определяем шаг
string vel = string.Empty;
if (curStep == 1)
vel = Jog.JogVel[0].ToString();
if (curStep == 2)
vel = Jog.JogVel[1].ToString();
if (curStep == 3)
vel = Jog.JogVel[2].ToString();
if (curStep == 4)
vel = Jog.JogVel[3].ToString();
if (curStep == 5)
vel = Jog.JogVel[4].ToString();
if (curStep == 6)
vel = Jog.JogVel[4].ToString();
int ch = AxesToChanel(axes);
string command = "Jog" + ch.ToString() + "=" + dir + vel;
WriteLine(command);
}
}
/************************************************************************************************************************/
// Jog Stop
/************************************************************************************************************************/
public void JogStop(Axis axes)
{
int ch = AxesToChanel(axes);
string command = "Jog" + ch.ToString() + "=0";
WriteLine(command);
Excecute = false;
}