Skip to content

Commit

Permalink
Merge pull request #1 from nfu-irs-lab/iss133
Browse files Browse the repository at this point in the history
Remove contest files
  • Loading branch information
ziteh authored Jan 21, 2022
2 parents 992b52c + ed0bfad commit 910669a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 64 deletions.
28 changes: 19 additions & 9 deletions Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,51 @@
/// <summary>
/// 可調整之設定。
/// </summary>
public static class Config
public class Config
{
/// <summary>
/// 手臂連線IP位置。<br/>
/// 設定錯誤將會無法連線。
/// </summary>
public const string ArmIp = "192.168.100.126";
//public const string ArmIp = "169.254.119.180";
public virtual string ArmIp => "127.0.0.1";

/// <summary>
/// 手臂連線Port。<br/>
/// 設定錯誤將會無法連線。
/// 設定錯誤將會無法連線。<br/>
/// 上銀手臂無需設定該項。
/// </summary>
public virtual int ArmPort => 3000;

/// <summary>
/// 啓用手臂。
/// </summary>
public const int ArmPort = 3000;
public virtual bool ArmEnable => true;

/// <summary>
/// 夾爪連線COM Port。<br/>
/// 設定錯誤將會無法連線。
/// </summary>
public const string GripperComPort = "COM12";
public virtual string GripperComPort => "COM1";

/// <summary>
/// 啓用夾爪。
/// </summary>
public virtual bool GripperEnable => false;

/// <summary>
/// 藍牙連線COM Port。<br/>
/// 設定錯誤將會無法連線。
/// </summary>
public const string BluetoothComPort = "COM21";
public virtual string BluetoothComPort => "COM2";

/// <summary>
/// CSV 檔案儲存路徑。
/// </summary>
public const string CsvFilePath = "../../../../csv/";
public virtual string CsvFilePath => @"../../../../csv/";

/// <summary>
/// Log 檔案儲存路徑。
/// </summary>
public const string LogFilePath = "../../../../log/";
public virtual string LogFilePath => @"../../../../log/";
}
}
35 changes: 0 additions & 35 deletions Contest.cs

This file was deleted.

3 changes: 3 additions & 0 deletions ExclusiveControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ namespace MainForm
public partial class ExclusiveControl : UserControl
{
public RASDK.Arm.RoboticArm Arm;
public RASDK.Gripper.IGripperController Gripper;
public RASDK.Basic.ILogHandler LogHandler;
public RASDK.Basic.Message.IMessage MessageHandler;

public Config Config { get; protected set; } = new Config();

public ExclusiveControl()
{
InitializeComponent();
Expand Down
35 changes: 21 additions & 14 deletions MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public MainForm(ExclusiveControl exclusiveControl = null)
{
InitializeComponent();

exclusiveControl = exclusiveControl ?? new ExclusiveControl();

// 目標位置控制項集合。
TargetPosition = new List<NumericUpDown>
{
Expand Down Expand Up @@ -91,9 +93,9 @@ public MainForm(ExclusiveControl exclusiveControl = null)
};

// 物件實體化。
LogHandler = new LogHandler(Config.LogFilePath, LoggingLevel.Trace);
LogHandler = new LogHandler(exclusiveControl.Config.LogFilePath, LoggingLevel.Trace);
MessageHandler = new GeneralMessage(LogHandler);
Arm = new RASDK.Arm.Hiwin.RoboticArm(MessageHandler, Config.ArmIp);
Arm = new RASDK.Arm.Hiwin.RoboticArm(MessageHandler, exclusiveControl.Config.ArmIp);
// Gripper = new GripperController(Configuration.GripperComPort, Message);
// Bluetooth = new BluetoothArmController(Configuration.BluetoothComPort, Arm, Gripper, Message);
// CsvHandler = new CsvHandler(Configuration.CsvFilePath);
Expand All @@ -105,7 +107,15 @@ public MainForm(ExclusiveControl exclusiveControl = null)
// Camera = new IDSCamera(Message);

// 初始化可連線裝置組。
OrganizeConnectableDevices();
Devices.Clear(); // 請勿移除此行。
if (exclusiveControl.Config.ArmEnable)
{
Devices.Add(Arm);
}
if (exclusiveControl.Config.GripperEnable)
{
Devices.Add(Gripper);
}

// 初始化動作流程。
// ActionFlow.Clear();
Expand All @@ -119,18 +129,15 @@ public MainForm(ExclusiveControl exclusiveControl = null)

// PositionHandler.UpdateFileList();

if (exclusiveControl != null)
{
exclusiveControl.Arm = Arm;
exclusiveControl.LogHandler = LogHandler;
exclusiveControl.MessageHandler = MessageHandler;
exclusiveControl.Arm = Arm;
exclusiveControl.LogHandler = LogHandler;
exclusiveControl.MessageHandler = MessageHandler;

_exclusiveControl = exclusiveControl;
_exclusiveControl.Location = new System.Drawing.Point(0, 0);
_exclusiveControl.Name = "ExclusiveControl";
_exclusiveControl = exclusiveControl;
_exclusiveControl.Location = new System.Drawing.Point(0, 0);
_exclusiveControl.Name = "ExclusiveControl";

tabControl_main.TabPages[1].Controls.Add(_exclusiveControl);
}
tabControl_main.TabPages[1].Controls.Add(_exclusiveControl);
}

/// <summary>
Expand All @@ -141,7 +148,7 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
#if (!DISABLE_FORM_CLOSING)
foreach (var device in Devices)
{
if (device.Connected)
if (device == null ? false : device.Connected)
{
var dr = MessageHandler.Show("手臂或其它裝置似乎還在連線中。\r\n" +
"是否要斷開連線後再關閉視窗?",
Expand Down
6 changes: 0 additions & 6 deletions MainForm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@
<Compile Include="Connection.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Contest.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Gripper.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -179,8 +176,5 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit 910669a

Please sign in to comment.