This commit is contained in:
backuppc
2026-01-30 16:58:14 +09:00
parent 3a8cbd3283
commit faf13f5c37
22 changed files with 1137 additions and 417 deletions

View File

@@ -0,0 +1,230 @@
namespace Project.Dialog
{
partial class fSetCurrentPosition
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainLayout = new System.Windows.Forms.TableLayoutPanel();
this.controlPanel = new System.Windows.Forms.Panel();
this._lblStatus = new System.Windows.Forms.Label();
this.btnForward = new System.Windows.Forms.Button();
this.btnBackward = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.btnTurnR90 = new System.Windows.Forms.Button();
this.lblTurn = new System.Windows.Forms.Label();
this.btnTurnNone = new System.Windows.Forms.Button();
this.btnTurnL90 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.mainLayout.SuspendLayout();
this.controlPanel.SuspendLayout();
this.SuspendLayout();
//
// mainLayout
//
this.mainLayout.ColumnCount = 1;
this.mainLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.mainLayout.Controls.Add(this.controlPanel, 0, 2);
this.mainLayout.Controls.Add(this.label1, 0, 0);
this.mainLayout.Dock = System.Windows.Forms.DockStyle.Fill;
this.mainLayout.Location = new System.Drawing.Point(0, 0);
this.mainLayout.Name = "mainLayout";
this.mainLayout.RowCount = 3;
this.mainLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F));
this.mainLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 84.60411F));
this.mainLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 15.39589F));
this.mainLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.mainLayout.Size = new System.Drawing.Size(1264, 761);
this.mainLayout.TabIndex = 0;
//
// controlPanel
//
this.controlPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.controlPanel.Controls.Add(this._lblStatus);
this.controlPanel.Controls.Add(this.btnForward);
this.controlPanel.Controls.Add(this.btnBackward);
this.controlPanel.Controls.Add(this.btnOK);
this.controlPanel.Controls.Add(this.btnCancel);
this.controlPanel.Controls.Add(this.btnTurnR90);
this.controlPanel.Controls.Add(this.lblTurn);
this.controlPanel.Controls.Add(this.btnTurnNone);
this.controlPanel.Controls.Add(this.btnTurnL90);
this.controlPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.controlPanel.Location = new System.Drawing.Point(3, 652);
this.controlPanel.Name = "controlPanel";
this.controlPanel.Padding = new System.Windows.Forms.Padding(10);
this.controlPanel.Size = new System.Drawing.Size(1258, 106);
this.controlPanel.TabIndex = 1;
//
// _lblStatus
//
this._lblStatus.Font = new System.Drawing.Font("맑은 고딕", 12F, System.Drawing.FontStyle.Bold);
this._lblStatus.ForeColor = System.Drawing.Color.White;
this._lblStatus.Location = new System.Drawing.Point(7, 7);
this._lblStatus.Margin = new System.Windows.Forms.Padding(3, 10, 20, 0);
this._lblStatus.Name = "_lblStatus";
this._lblStatus.Size = new System.Drawing.Size(653, 42);
this._lblStatus.TabIndex = 0;
this._lblStatus.Text = "위치를 선택해 주세요.";
this._lblStatus.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// btnForward
//
this.btnForward.BackColor = System.Drawing.Color.DarkSlateGray;
this.btnForward.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnForward.ForeColor = System.Drawing.Color.White;
this.btnForward.Location = new System.Drawing.Point(721, 51);
this.btnForward.Name = "btnForward";
this.btnForward.Size = new System.Drawing.Size(120, 38);
this.btnForward.TabIndex = 1;
this.btnForward.Text = "전진 (Forward)";
this.btnForward.UseVisualStyleBackColor = false;
//
// btnBackward
//
this.btnBackward.BackColor = System.Drawing.Color.DarkSlateGray;
this.btnBackward.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnBackward.ForeColor = System.Drawing.Color.White;
this.btnBackward.Location = new System.Drawing.Point(847, 51);
this.btnBackward.Name = "btnBackward";
this.btnBackward.Size = new System.Drawing.Size(126, 38);
this.btnBackward.TabIndex = 2;
this.btnBackward.Text = "후진 (Backward)";
this.btnBackward.UseVisualStyleBackColor = false;
//
// btnOK
//
this.btnOK.BackColor = System.Drawing.Color.DarkGreen;
this.btnOK.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnOK.ForeColor = System.Drawing.Color.White;
this.btnOK.Location = new System.Drawing.Point(7, 51);
this.btnOK.Margin = new System.Windows.Forms.Padding(50, 3, 3, 3);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(150, 38);
this.btnOK.TabIndex = 7;
this.btnOK.Text = "설정 완료";
this.btnOK.UseVisualStyleBackColor = false;
//
// btnCancel
//
this.btnCancel.BackColor = System.Drawing.Color.Maroon;
this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnCancel.ForeColor = System.Drawing.Color.White;
this.btnCancel.Location = new System.Drawing.Point(163, 51);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(100, 38);
this.btnCancel.TabIndex = 8;
this.btnCancel.Text = "취소";
this.btnCancel.UseVisualStyleBackColor = false;
//
// btnTurnR90
//
this.btnTurnR90.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.btnTurnR90.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnTurnR90.ForeColor = System.Drawing.Color.White;
this.btnTurnR90.Location = new System.Drawing.Point(893, 7);
this.btnTurnR90.Name = "btnTurnR90";
this.btnTurnR90.Size = new System.Drawing.Size(80, 40);
this.btnTurnR90.TabIndex = 6;
this.btnTurnR90.Text = "R90";
this.btnTurnR90.UseVisualStyleBackColor = false;
//
// lblTurn
//
this.lblTurn.AutoSize = true;
this.lblTurn.ForeColor = System.Drawing.Color.White;
this.lblTurn.Location = new System.Drawing.Point(677, 20);
this.lblTurn.Margin = new System.Windows.Forms.Padding(20, 10, 5, 0);
this.lblTurn.Name = "lblTurn";
this.lblTurn.Size = new System.Drawing.Size(35, 12);
this.lblTurn.TabIndex = 3;
this.lblTurn.Text = "Turn:";
//
// btnTurnNone
//
this.btnTurnNone.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.btnTurnNone.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnTurnNone.ForeColor = System.Drawing.Color.White;
this.btnTurnNone.Location = new System.Drawing.Point(721, 7);
this.btnTurnNone.Name = "btnTurnNone";
this.btnTurnNone.Size = new System.Drawing.Size(80, 40);
this.btnTurnNone.TabIndex = 4;
this.btnTurnNone.Text = "None";
this.btnTurnNone.UseVisualStyleBackColor = false;
//
// btnTurnL90
//
this.btnTurnL90.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
this.btnTurnL90.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnTurnL90.ForeColor = System.Drawing.Color.White;
this.btnTurnL90.Location = new System.Drawing.Point(807, 7);
this.btnTurnL90.Name = "btnTurnL90";
this.btnTurnL90.Size = new System.Drawing.Size(80, 40);
this.btnTurnL90.TabIndex = 5;
this.btnTurnL90.Text = "L90";
this.btnTurnL90.UseVisualStyleBackColor = false;
//
// label1
//
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
this.label1.Font = new System.Drawing.Font("맑은 고딕", 12F, System.Drawing.FontStyle.Bold);
this.label1.Location = new System.Drawing.Point(3, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(1258, 40);
this.label1.TabIndex = 2;
this.label1.Text = "현재 위치에 해당하는 노드를 선택하세요";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// fSetCurrentPosition
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1264, 761);
this.Controls.Add(this.mainLayout);
this.Name = "fSetCurrentPosition";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "AGV 시작 위치 및 방향 설정";
this.mainLayout.ResumeLayout(false);
this.controlPanel.ResumeLayout(false);
this.controlPanel.PerformLayout();
this.ResumeLayout(false);
}
private System.Windows.Forms.TableLayoutPanel mainLayout;
private System.Windows.Forms.Panel controlPanel;
private System.Windows.Forms.Label _lblStatus;
private System.Windows.Forms.Button btnForward;
private System.Windows.Forms.Button btnBackward;
private System.Windows.Forms.Label lblTurn;
private System.Windows.Forms.Button btnTurnNone;
private System.Windows.Forms.Button btnTurnL90;
private System.Windows.Forms.Button btnTurnR90;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Label label1;
}
}

View File

@@ -0,0 +1,128 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AGVNavigationCore.Models;
using AGVNavigationCore.Controls;
namespace Project.Dialog
{
public partial class fSetCurrentPosition : Form
{
private UnifiedAGVCanvas _canvas;
private MapNode _selectedNode;
private AgvDirection _selectedDirection = AgvDirection.Forward;
private AGVTurn _selectedTurn = AGVTurn.None;
public MapNode SelectedNode => _selectedNode;
public AgvDirection SelectedDirection => _selectedDirection;
public AGVTurn SelectedTurn => _selectedTurn;
public fSetCurrentPosition()
{
InitializeComponent();
if (PUB.setting.FullScreen) this.WindowState = FormWindowState.Maximized;
SetupCanvas();
WireEvents();
this.Load += FSetCurrentPosition_Load;
}
private void SetupCanvas()
{
_canvas = new UnifiedAGVCanvas
{
Dock = DockStyle.Fill,
Mode = UnifiedAGVCanvas.CanvasMode.Run,
BackColor = Color.FromArgb(45, 45, 48),
ShowGrid=false,
};
mainLayout.Controls.Add(_canvas, 1, 0);
}
private void WireEvents()
{
_canvas.NodeSelect += _canvas_NodeSelect;
btnForward.Click += (s, e) => { _selectedDirection = AgvDirection.Forward; UpdateStatus(); };
btnBackward.Click += (s, e) => { _selectedDirection = AgvDirection.Backward; UpdateStatus(); };
btnTurnNone.Click += (s, e) => { _selectedTurn = AGVTurn.None; UpdateStatus(); };
btnTurnL90.Click += (s, e) => { _selectedTurn = AGVTurn.L90; UpdateStatus(); };
btnTurnR90.Click += (s, e) => { _selectedTurn = AGVTurn.R90; UpdateStatus(); };
btnOK.Click += BtnOK_Click;
btnCancel.Click += (s, e) => { this.DialogResult = DialogResult.Cancel; this.Close(); };
}
private void FSetCurrentPosition_Load(object sender, EventArgs e)
{
// 맵 데이터 강제 복사 (PUB과 동일한 맵 사용)
if (PUB._mapCanvas != null)
{
_canvas.SetMapData(PUB._mapCanvas.Nodes, PUB._mapCanvas.Labels, PUB._mapCanvas.Images, PUB._mapCanvas.Marks, PUB._mapCanvas.Magnets);
}
// 마지막 위치 로드
var lastPos = PUB.LoadLastPosition();
if (lastPos != null)
{
_selectedNode = _canvas.Nodes.FirstOrDefault(n => n.Id == lastPos.NodeId);
_selectedDirection = lastPos.Direction;
_selectedTurn = lastPos.Turn;
if (_selectedNode != null)
{
_canvas.SelectedNode = _selectedNode;
_canvas.PanToNode(_selectedNode.Id);
UpdateStatus(isRestore: true);
}
}
this.Show();
_canvas.ResetZoom();
}
private void _canvas_NodeSelect(object sender, NodeBase node, MouseEventArgs e)
{
if (node is MapNode mapNode && mapNode.IsNavigationNode())
{
_selectedNode = mapNode;
_canvas.SelectedNode = mapNode;
UpdateStatus();
}
}
private void UpdateStatus(bool isRestore = false)
{
if (_selectedNode == null)
{
_lblStatus.Text = "위치를 선택해 주세요.";
_lblStatus.ForeColor = Color.White;
return;
}
string dirStr = _selectedDirection == AgvDirection.Forward ? "전진" : "후진";
_lblStatus.Text = $"{(isRestore ? "[] " : "")}위치: {_selectedNode.Id} ({_selectedNode.ID2}) | 방향: {dirStr} | Turn: {_selectedTurn}";
_lblStatus.ForeColor = isRestore ? Color.Yellow : Color.Cyan;
// 캔버스에 가상 AGV 미리보기 (선택 사항)
_canvas.Invalidate();
}
private void BtnOK_Click(object sender, EventArgs e)
{
if (_selectedNode == null)
{
MessageBox.Show("AGV의 현재 위치를 맵에서 클릭하여 선택해 주세요.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>