Skip to content

Commit

Permalink
Merge pull request #111 from ziteh/develop
Browse files Browse the repository at this point in the history
Fix #108
  • Loading branch information
ziteh authored Aug 11, 2022
2 parents 547aab0 + b5eb514 commit 34b0437
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 deletions.
13 changes: 13 additions & 0 deletions RASDK.Arm.TestForms/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions RASDK.Arm.TestForms/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,29 @@ private void buttonHoming_Click(object sender, EventArgs e)
_message.Show("Homing done!");
}

private void buttonTest_Click(object sender, EventArgs e)
{
double[] position;
switch (comboBoxArmType.SelectedItem.ToString())
{
case "HIWIN":
position = Hiwin.Default.DescartesHomePosition;
break;

case "TM Robot":
position = TMRobot.Default.DescartesHomePosition;
break;

default:
throw new Exception("未知的手臂類型。");
}
position[0] += 50;
position[1] += 50;
position[2] -= 100;

_arm.MoveAbsolute(position, new AdditionalMotionParameters { NeedWait = true });
}

private void buttonMove1_Click(object sender, EventArgs e)
{
_arm.MoveRelative(-100,
Expand Down
9 changes: 9 additions & 0 deletions RASDK.Arm/AdditionalMotionParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,14 @@ public class AdditionalMotionParameters
/// 手臂平滑模式數值。
/// </summary>
public int SmoothValue = 50;

public override string ToString()
{
return $"NeedWait: {NeedWait}," +
$"CoordinatyType: {CoordinateType}," +
$"MotionType: {MotionType}," +
$"SmoothType: {SmoothType}, " +
$"SmoothValue: {SmoothValue}.";
}
}
}
8 changes: 6 additions & 2 deletions RASDK.Arm/Hiwin/RoboticArm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
Expand Down Expand Up @@ -390,6 +391,7 @@ private void WaitForMotionComplete()
_message.LogMethodStart(nameof(WaitForMotionComplete), "void", "void");

uint i = 0;
var stopWatch = Stopwatch.StartNew();
do
{
_receivedCallBack = false; // Clear received flag.
Expand All @@ -412,9 +414,11 @@ private void WaitForMotionComplete()
}
}
}
while (_moving && !_receivedCallBack);
while (_moving || !_receivedCallBack);
stopWatch.Stop();
var elapsed = stopWatch.ElapsedMilliseconds;

_message.LogMethodEnd(nameof(WaitForMotionComplete));
_message.LogMethodEnd(nameof(WaitForMotionComplete), $"Elapsed milliseconds: {elapsed}.", LoggingLevel.Trace);
}

#endregion Motion
Expand Down
4 changes: 2 additions & 2 deletions RASDK.Basic/LogHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public override void Write(string message, LoggingLevel loggingLevel)
{
if (loggingLevel >= _loggingLevel)
{
string text = DateTime.Now.ToString("HH:mm:ss") +
string text = DateTime.Now.ToString("HH:mm:ss.ffff") +
$"[{loggingLevel}]" +
$"{message.Replace("\r", "").Replace("\n", ";").Trim()}";

Expand Down Expand Up @@ -246,7 +246,7 @@ private void CreateFile()

var sw = MakeStreamWriter();
sw.WriteLine($"{dateTimeNow:yyyy-MM-dd_HH:mm:ss} " +
$"LogLv: {_loggingLevel}\r\n---");
$"Log Level: {_loggingLevel}\r\n---");
sw.Close();
}

Expand Down

0 comments on commit 34b0437

Please sign in to comment.