feat: Migrate IO and Recipe systems to use real data sources

- Enhanced GetIOList() to read from DIO library (inputs, outputs, interlocks)
- Added interlock display to IOMonitorPage with 3-tab layout
- Migrated GetRecipeList() to use PUB.mdm.dataSet.OPModel table
- Migrated GetRecipe() to read from OPModel DataRow
- Migrated SaveRecipe() to save to OPModel table with type conversion
- Updated frontend to handle new structured IO format
- All methods now use real hardware/database instead of mock data

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-25 21:09:23 +09:00
parent c625947b2e
commit 8364f7478c
5 changed files with 432 additions and 158 deletions

View File

@@ -94,7 +94,21 @@ export default function App() {
try {
const ioStr = await comms.getIOList();
const ioData = JSON.parse(ioStr);
setIoPoints(ioData);
// Handle new structured format: { inputs: [...], outputs: [...], interlocks: [...] }
let flatIoList: IOPoint[] = [];
if (ioData.inputs && ioData.outputs) {
// New format - flatten inputs and outputs
flatIoList = [
...ioData.outputs.map((io: any) => ({ id: io.id, name: io.name, type: 'output' as const, state: io.state })),
...ioData.inputs.map((io: any) => ({ id: io.id, name: io.name, type: 'input' as const, state: io.state }))
];
} else if (Array.isArray(ioData)) {
// Old format - already flat array
flatIoList = ioData;
}
setIoPoints(flatIoList);
addLog("IO LIST LOADED", "info");
} catch (e) {
addLog("FAILED TO LOAD IO DATA", "error");

View File

@@ -7,10 +7,19 @@ interface IOMonitorPageProps {
onToggle: (id: number, type: 'input' | 'output') => void;
}
interface InterlockData {
axisIndex: number;
axisName: string;
nonAxis: boolean;
locks: { id: number; name: string; state: boolean }[];
hexValue: string;
}
export const IOMonitorPage: React.FC<IOMonitorPageProps> = ({ onToggle }) => {
const [ioPoints, setIoPoints] = useState<IOPoint[]>([]);
const [interlocks, setInterlocks] = useState<InterlockData[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [activeIOTab, setActiveIOTab] = useState<'in' | 'out'>('in');
const [activeIOTab, setActiveIOTab] = useState<'in' | 'out' | 'interlock'>('in');
// Fetch initial IO list when page mounts
useEffect(() => {
@@ -18,8 +27,21 @@ export const IOMonitorPage: React.FC<IOMonitorPageProps> = ({ onToggle }) => {
setIsLoading(true);
try {
const ioStr = await comms.getIOList();
const ioData: IOPoint[] = JSON.parse(ioStr);
const ioData = JSON.parse(ioStr);
// Handle new structured format: { inputs: [...], outputs: [...], interlocks: [...] }
if (ioData.inputs && ioData.outputs) {
// New format
const flatIoList: IOPoint[] = [
...ioData.outputs.map((io: any) => ({ id: io.id, name: io.name, type: 'output' as const, state: io.state })),
...ioData.inputs.map((io: any) => ({ id: io.id, name: io.name, type: 'input' as const, state: io.state }))
];
setIoPoints(flatIoList);
setInterlocks(ioData.interlocks || []);
} else if (Array.isArray(ioData)) {
// Old format - already flat array
setIoPoints(ioData);
}
} catch (e) {
console.error('Failed to fetch IO list:', e);
}
@@ -46,7 +68,9 @@ export const IOMonitorPage: React.FC<IOMonitorPageProps> = ({ onToggle }) => {
};
}, []);
const points = ioPoints.filter(p => p.type === (activeIOTab === 'in' ? 'input' : 'output'));
const points = activeIOTab === 'interlock'
? []
: ioPoints.filter(p => p.type === (activeIOTab === 'in' ? 'input' : 'output'));
return (
<main className="relative w-full h-full px-6 pt-6 pb-20">
@@ -60,7 +84,7 @@ export const IOMonitorPage: React.FC<IOMonitorPageProps> = ({ onToggle }) => {
</h2>
<div className="h-6 w-px bg-white/20"></div>
<div className="text-sm font-mono text-neon-blue">
TOTAL POINTS: {ioPoints.length}
{activeIOTab === 'interlock' ? `TOTAL AXES: ${interlocks.length}` : `TOTAL POINTS: ${ioPoints.length}`}
</div>
</div>
@@ -77,6 +101,12 @@ export const IOMonitorPage: React.FC<IOMonitorPageProps> = ({ onToggle }) => {
>
OUTPUTS ({ioPoints.filter(p => p.type === 'output').length})
</button>
<button
onClick={() => setActiveIOTab('interlock')}
className={`px-6 py-2 rounded-full font-tech font-bold text-sm transition-all ${activeIOTab === 'interlock' ? 'bg-neon-blue/20 text-neon-blue border border-neon-blue shadow-[0_0_15px_rgba(0,255,255,0.3)]' : 'text-slate-400 hover:text-white hover:bg-white/5'}`}
>
INTERLOCKS ({interlocks.length})
</button>
</div>
</div>
@@ -86,6 +116,35 @@ export const IOMonitorPage: React.FC<IOMonitorPageProps> = ({ onToggle }) => {
<RotateCw className="w-16 h-16 text-neon-blue animate-spin" />
<div className="text-xl font-tech text-neon-blue tracking-widest">LOADING IO POINTS...</div>
</div>
) : activeIOTab === 'interlock' ? (
<div className="p-4 space-y-4">
{interlocks.map(axis => (
<div key={axis.axisIndex} className="bg-slate-900/60 border border-slate-700 rounded-lg p-4">
<div className="flex items-center justify-between mb-3">
<div className="flex items-center gap-3">
<span className="text-xl font-tech font-bold text-neon-blue">{axis.axisName}</span>
<span className="text-sm font-mono text-slate-400">({axis.hexValue})</span>
</div>
</div>
<div className="grid grid-cols-3 gap-2">
{axis.locks.map(lock => (
<div
key={lock.id}
className={`
flex items-center gap-2 px-3 py-2 transition-all border rounded
${lock.state
? 'bg-red-500/20 border-red-500 text-red-400 shadow-[0_0_10px_rgba(239,68,68,0.3)]'
: 'bg-slate-800/40 border-slate-700 text-slate-500'}
`}
>
<div className={`w-2 h-2 rounded-full shrink-0 ${lock.state ? 'bg-red-500 shadow-[0_0_6px_#ef4444]' : 'bg-slate-700'}`}></div>
<span className="text-xs font-mono truncate">{lock.name}</span>
</div>
))}
</div>
</div>
))}
</div>
) : (
<div className="grid grid-cols-2 gap-x-8 gap-y-2 p-4">
{points.map(p => (

View File

@@ -75,6 +75,8 @@
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.panel2 = new System.Windows.Forms.Panel();
this.tblDI = new arDev.AjinEXTEK.UI.IOPanel();
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.pinDefineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.lbTitle1 = new arCtl.arLabel();
this.tabPage4 = new System.Windows.Forms.TabPage();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
@@ -138,12 +140,11 @@
this.gbi17 = new arCtl.GridView.GridView();
this.lbi17 = new System.Windows.Forms.Label();
this.tmDisplay = new System.Windows.Forms.Timer(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.pinDefineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.panel2.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.tabPage4.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.panel6.SuspendLayout();
@@ -167,7 +168,6 @@
this.panel4.SuspendLayout();
this.panel15.SuspendLayout();
this.panel24.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// panel3
@@ -263,6 +263,20 @@
this.tblDI.Text = "ioPanel1";
this.tblDI.TextAttachToImage = true;
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.pinDefineToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(131, 26);
//
// pinDefineToolStripMenuItem
//
this.pinDefineToolStripMenuItem.Name = "pinDefineToolStripMenuItem";
this.pinDefineToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
this.pinDefineToolStripMenuItem.Text = "Pin Define";
this.pinDefineToolStripMenuItem.Click += new System.EventHandler(this.pinDefineToolStripMenuItem_Click);
//
// lbTitle1
//
this.lbTitle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
@@ -425,9 +439,9 @@
// tabPage3
//
this.tabPage3.Controls.Add(this.tableLayoutPanel2);
this.tabPage3.Location = new System.Drawing.Point(22, 4);
this.tabPage3.Location = new System.Drawing.Point(25, 4);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(901, 740);
this.tabPage3.Size = new System.Drawing.Size(898, 740);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "I-LOCK";
this.tabPage3.UseVisualStyleBackColor = true;
@@ -467,7 +481,7 @@
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 16.66667F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(901, 740);
this.tableLayoutPanel2.Size = new System.Drawing.Size(898, 740);
this.tableLayoutPanel2.TabIndex = 0;
//
// panel5
@@ -475,9 +489,9 @@
this.panel5.Controls.Add(this.gbi01);
this.panel5.Controls.Add(this.lbi01);
this.panel5.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel5.Location = new System.Drawing.Point(303, 3);
this.panel5.Location = new System.Drawing.Point(302, 3);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(294, 117);
this.panel5.Size = new System.Drawing.Size(293, 117);
this.panel5.TabIndex = 0;
//
// gbi01
@@ -512,7 +526,7 @@
this.gbi01.ShowIndexString = true;
this.gbi01.ShowNameString = true;
this.gbi01.ShowValueString = false;
this.gbi01.Size = new System.Drawing.Size(294, 103);
this.gbi01.Size = new System.Drawing.Size(293, 103);
this.gbi01.TabIndex = 3;
this.gbi01.Tag = "PKX";
this.gbi01.Tags = null;
@@ -528,7 +542,7 @@
this.lbi01.ForeColor = System.Drawing.Color.Cyan;
this.lbi01.Location = new System.Drawing.Point(0, 0);
this.lbi01.Name = "lbi01";
this.lbi01.Size = new System.Drawing.Size(294, 14);
this.lbi01.Size = new System.Drawing.Size(293, 14);
this.lbi01.TabIndex = 4;
this.lbi01.Text = "X-MIDDLE";
this.lbi01.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -538,9 +552,9 @@
this.panel8.Controls.Add(this.gbi02);
this.panel8.Controls.Add(this.lbi02);
this.panel8.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel8.Location = new System.Drawing.Point(603, 3);
this.panel8.Location = new System.Drawing.Point(601, 3);
this.panel8.Name = "panel8";
this.panel8.Size = new System.Drawing.Size(295, 117);
this.panel8.Size = new System.Drawing.Size(294, 117);
this.panel8.TabIndex = 0;
//
// gbi02
@@ -575,7 +589,7 @@
this.gbi02.ShowIndexString = true;
this.gbi02.ShowNameString = true;
this.gbi02.ShowValueString = false;
this.gbi02.Size = new System.Drawing.Size(295, 101);
this.gbi02.Size = new System.Drawing.Size(294, 101);
this.gbi02.TabIndex = 3;
this.gbi02.Tag = "PKZ";
this.gbi02.Tags = null;
@@ -591,7 +605,7 @@
this.lbi02.ForeColor = System.Drawing.Color.Cyan;
this.lbi02.Location = new System.Drawing.Point(0, 0);
this.lbi02.Name = "lbi02";
this.lbi02.Size = new System.Drawing.Size(295, 16);
this.lbi02.Size = new System.Drawing.Size(294, 16);
this.lbi02.TabIndex = 4;
this.lbi02.Text = "X-FRONT";
this.lbi02.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -603,7 +617,7 @@
this.panel11.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel11.Location = new System.Drawing.Point(3, 3);
this.panel11.Name = "panel11";
this.panel11.Size = new System.Drawing.Size(294, 117);
this.panel11.Size = new System.Drawing.Size(293, 117);
this.panel11.TabIndex = 0;
//
// gbi00
@@ -638,7 +652,7 @@
this.gbi00.ShowIndexString = true;
this.gbi00.ShowNameString = true;
this.gbi00.ShowValueString = false;
this.gbi00.Size = new System.Drawing.Size(294, 101);
this.gbi00.Size = new System.Drawing.Size(293, 101);
this.gbi00.TabIndex = 3;
this.gbi00.Tag = "PKT";
this.gbi00.Tags = null;
@@ -654,7 +668,7 @@
this.lbi00.ForeColor = System.Drawing.Color.Cyan;
this.lbi00.Location = new System.Drawing.Point(0, 0);
this.lbi00.Name = "lbi00";
this.lbi00.Size = new System.Drawing.Size(294, 16);
this.lbi00.Size = new System.Drawing.Size(293, 16);
this.lbi00.TabIndex = 4;
this.lbi00.Text = "X-REAR";
this.lbi00.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -664,9 +678,9 @@
this.panel7.Controls.Add(this.gbi04);
this.panel7.Controls.Add(this.lbi04);
this.panel7.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel7.Location = new System.Drawing.Point(303, 126);
this.panel7.Location = new System.Drawing.Point(302, 126);
this.panel7.Name = "panel7";
this.panel7.Size = new System.Drawing.Size(294, 117);
this.panel7.Size = new System.Drawing.Size(293, 117);
this.panel7.TabIndex = 0;
//
// gbi04
@@ -701,7 +715,7 @@
this.gbi04.ShowIndexString = true;
this.gbi04.ShowNameString = true;
this.gbi04.ShowValueString = false;
this.gbi04.Size = new System.Drawing.Size(294, 101);
this.gbi04.Size = new System.Drawing.Size(293, 101);
this.gbi04.TabIndex = 3;
this.gbi04.Tag = "PKZ";
this.gbi04.Tags = null;
@@ -717,7 +731,7 @@
this.lbi04.ForeColor = System.Drawing.Color.Yellow;
this.lbi04.Location = new System.Drawing.Point(0, 0);
this.lbi04.Name = "lbi04";
this.lbi04.Size = new System.Drawing.Size(294, 16);
this.lbi04.Size = new System.Drawing.Size(293, 16);
this.lbi04.TabIndex = 4;
this.lbi04.Text = "ELEVATOR2-R";
this.lbi04.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -729,7 +743,7 @@
this.panel10.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel10.Location = new System.Drawing.Point(3, 126);
this.panel10.Name = "panel10";
this.panel10.Size = new System.Drawing.Size(294, 117);
this.panel10.Size = new System.Drawing.Size(293, 117);
this.panel10.TabIndex = 0;
//
// gbi03
@@ -764,7 +778,7 @@
this.gbi03.ShowIndexString = true;
this.gbi03.ShowNameString = true;
this.gbi03.ShowValueString = false;
this.gbi03.Size = new System.Drawing.Size(294, 101);
this.gbi03.Size = new System.Drawing.Size(293, 101);
this.gbi03.TabIndex = 3;
this.gbi03.Tag = "PKZ";
this.gbi03.Tags = null;
@@ -780,7 +794,7 @@
this.lbi03.ForeColor = System.Drawing.Color.Yellow;
this.lbi03.Location = new System.Drawing.Point(0, 0);
this.lbi03.Name = "lbi03";
this.lbi03.Size = new System.Drawing.Size(294, 16);
this.lbi03.Size = new System.Drawing.Size(293, 16);
this.lbi03.TabIndex = 4;
this.lbi03.Text = "ELEVATOR1-R";
this.lbi03.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -792,7 +806,7 @@
this.panel12.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel12.Location = new System.Drawing.Point(3, 249);
this.panel12.Name = "panel12";
this.panel12.Size = new System.Drawing.Size(294, 117);
this.panel12.Size = new System.Drawing.Size(293, 117);
this.panel12.TabIndex = 0;
//
// gbi06
@@ -827,7 +841,7 @@
this.gbi06.ShowIndexString = true;
this.gbi06.ShowNameString = true;
this.gbi06.ShowValueString = false;
this.gbi06.Size = new System.Drawing.Size(294, 101);
this.gbi06.Size = new System.Drawing.Size(293, 101);
this.gbi06.TabIndex = 3;
this.gbi06.Tag = "PKZ";
this.gbi06.Tags = null;
@@ -843,7 +857,7 @@
this.lbi06.ForeColor = System.Drawing.Color.Yellow;
this.lbi06.Location = new System.Drawing.Point(0, 0);
this.lbi06.Name = "lbi06";
this.lbi06.Size = new System.Drawing.Size(294, 16);
this.lbi06.Size = new System.Drawing.Size(293, 16);
this.lbi06.TabIndex = 4;
this.lbi06.Text = "ELEVATOR1-F";
this.lbi06.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -853,9 +867,9 @@
this.panel13.Controls.Add(this.gbi07);
this.panel13.Controls.Add(this.lbi07);
this.panel13.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel13.Location = new System.Drawing.Point(303, 249);
this.panel13.Location = new System.Drawing.Point(302, 249);
this.panel13.Name = "panel13";
this.panel13.Size = new System.Drawing.Size(294, 117);
this.panel13.Size = new System.Drawing.Size(293, 117);
this.panel13.TabIndex = 0;
//
// gbi07
@@ -890,7 +904,7 @@
this.gbi07.ShowIndexString = true;
this.gbi07.ShowNameString = true;
this.gbi07.ShowValueString = false;
this.gbi07.Size = new System.Drawing.Size(294, 101);
this.gbi07.Size = new System.Drawing.Size(293, 101);
this.gbi07.TabIndex = 3;
this.gbi07.Tag = "PKZ";
this.gbi07.Tags = null;
@@ -906,7 +920,7 @@
this.lbi07.ForeColor = System.Drawing.Color.Yellow;
this.lbi07.Location = new System.Drawing.Point(0, 0);
this.lbi07.Name = "lbi07";
this.lbi07.Size = new System.Drawing.Size(294, 16);
this.lbi07.Size = new System.Drawing.Size(293, 16);
this.lbi07.TabIndex = 4;
this.lbi07.Text = "ELEVATOR2-F";
this.lbi07.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -916,9 +930,9 @@
this.panel14.Controls.Add(this.gbi08);
this.panel14.Controls.Add(this.lbi08);
this.panel14.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel14.Location = new System.Drawing.Point(603, 249);
this.panel14.Location = new System.Drawing.Point(601, 249);
this.panel14.Name = "panel14";
this.panel14.Size = new System.Drawing.Size(295, 117);
this.panel14.Size = new System.Drawing.Size(294, 117);
this.panel14.TabIndex = 0;
//
// gbi08
@@ -953,7 +967,7 @@
this.gbi08.ShowIndexString = true;
this.gbi08.ShowNameString = true;
this.gbi08.ShowValueString = false;
this.gbi08.Size = new System.Drawing.Size(295, 101);
this.gbi08.Size = new System.Drawing.Size(294, 101);
this.gbi08.TabIndex = 3;
this.gbi08.Tag = "PKZ";
this.gbi08.Tags = null;
@@ -969,7 +983,7 @@
this.lbi08.ForeColor = System.Drawing.Color.Yellow;
this.lbi08.Location = new System.Drawing.Point(0, 0);
this.lbi08.Name = "lbi08";
this.lbi08.Size = new System.Drawing.Size(295, 16);
this.lbi08.Size = new System.Drawing.Size(294, 16);
this.lbi08.TabIndex = 4;
this.lbi08.Text = "ELEVATOR3-F";
this.lbi08.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -979,9 +993,9 @@
this.panel17.Controls.Add(this.gbi11);
this.panel17.Controls.Add(this.lbi11);
this.panel17.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel17.Location = new System.Drawing.Point(603, 372);
this.panel17.Location = new System.Drawing.Point(601, 372);
this.panel17.Name = "panel17";
this.panel17.Size = new System.Drawing.Size(295, 117);
this.panel17.Size = new System.Drawing.Size(294, 117);
this.panel17.TabIndex = 0;
//
// gbi11
@@ -1016,7 +1030,7 @@
this.gbi11.ShowIndexString = true;
this.gbi11.ShowNameString = true;
this.gbi11.ShowValueString = false;
this.gbi11.Size = new System.Drawing.Size(295, 101);
this.gbi11.Size = new System.Drawing.Size(294, 101);
this.gbi11.TabIndex = 3;
this.gbi11.Tag = "PKZ";
this.gbi11.Tags = null;
@@ -1032,7 +1046,7 @@
this.lbi11.ForeColor = System.Drawing.Color.SkyBlue;
this.lbi11.Location = new System.Drawing.Point(0, 0);
this.lbi11.Name = "lbi11";
this.lbi11.Size = new System.Drawing.Size(295, 16);
this.lbi11.Size = new System.Drawing.Size(294, 16);
this.lbi11.TabIndex = 4;
this.lbi11.Text = "Y3";
this.lbi11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -1042,9 +1056,9 @@
this.panel18.Controls.Add(this.gbi10);
this.panel18.Controls.Add(this.lbi10);
this.panel18.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel18.Location = new System.Drawing.Point(303, 372);
this.panel18.Location = new System.Drawing.Point(302, 372);
this.panel18.Name = "panel18";
this.panel18.Size = new System.Drawing.Size(294, 117);
this.panel18.Size = new System.Drawing.Size(293, 117);
this.panel18.TabIndex = 0;
//
// gbi10
@@ -1079,7 +1093,7 @@
this.gbi10.ShowIndexString = true;
this.gbi10.ShowNameString = true;
this.gbi10.ShowValueString = false;
this.gbi10.Size = new System.Drawing.Size(294, 101);
this.gbi10.Size = new System.Drawing.Size(293, 101);
this.gbi10.TabIndex = 3;
this.gbi10.Tag = "PKZ";
this.gbi10.Tags = null;
@@ -1095,7 +1109,7 @@
this.lbi10.ForeColor = System.Drawing.Color.SkyBlue;
this.lbi10.Location = new System.Drawing.Point(0, 0);
this.lbi10.Name = "lbi10";
this.lbi10.Size = new System.Drawing.Size(294, 16);
this.lbi10.Size = new System.Drawing.Size(293, 16);
this.lbi10.TabIndex = 4;
this.lbi10.Text = "Y2";
this.lbi10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -1107,7 +1121,7 @@
this.panel19.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel19.Location = new System.Drawing.Point(3, 372);
this.panel19.Name = "panel19";
this.panel19.Size = new System.Drawing.Size(294, 117);
this.panel19.Size = new System.Drawing.Size(293, 117);
this.panel19.TabIndex = 0;
//
// gbi09
@@ -1142,7 +1156,7 @@
this.gbi09.ShowIndexString = true;
this.gbi09.ShowNameString = true;
this.gbi09.ShowValueString = false;
this.gbi09.Size = new System.Drawing.Size(294, 101);
this.gbi09.Size = new System.Drawing.Size(293, 101);
this.gbi09.TabIndex = 3;
this.gbi09.Tag = "PKZ";
this.gbi09.Tags = null;
@@ -1158,7 +1172,7 @@
this.lbi09.ForeColor = System.Drawing.Color.SkyBlue;
this.lbi09.Location = new System.Drawing.Point(0, 0);
this.lbi09.Name = "lbi09";
this.lbi09.Size = new System.Drawing.Size(294, 16);
this.lbi09.Size = new System.Drawing.Size(293, 16);
this.lbi09.TabIndex = 4;
this.lbi09.Text = "Y1";
this.lbi09.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -1170,7 +1184,7 @@
this.panel20.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel20.Location = new System.Drawing.Point(3, 495);
this.panel20.Name = "panel20";
this.panel20.Size = new System.Drawing.Size(294, 117);
this.panel20.Size = new System.Drawing.Size(293, 117);
this.panel20.TabIndex = 0;
//
// gbi12
@@ -1205,7 +1219,7 @@
this.gbi12.ShowIndexString = true;
this.gbi12.ShowNameString = true;
this.gbi12.ShowValueString = false;
this.gbi12.Size = new System.Drawing.Size(294, 101);
this.gbi12.Size = new System.Drawing.Size(293, 101);
this.gbi12.TabIndex = 3;
this.gbi12.Tag = "PKZ";
this.gbi12.Tags = null;
@@ -1221,7 +1235,7 @@
this.lbi12.ForeColor = System.Drawing.Color.SkyBlue;
this.lbi12.Location = new System.Drawing.Point(0, 0);
this.lbi12.Name = "lbi12";
this.lbi12.Size = new System.Drawing.Size(294, 16);
this.lbi12.Size = new System.Drawing.Size(293, 16);
this.lbi12.TabIndex = 4;
this.lbi12.Text = "Z-PICKER1-F";
this.lbi12.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -1231,9 +1245,9 @@
this.panel21.Controls.Add(this.gbi13);
this.panel21.Controls.Add(this.lbi13);
this.panel21.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel21.Location = new System.Drawing.Point(303, 495);
this.panel21.Location = new System.Drawing.Point(302, 495);
this.panel21.Name = "panel21";
this.panel21.Size = new System.Drawing.Size(294, 117);
this.panel21.Size = new System.Drawing.Size(293, 117);
this.panel21.TabIndex = 0;
//
// gbi13
@@ -1268,7 +1282,7 @@
this.gbi13.ShowIndexString = true;
this.gbi13.ShowNameString = true;
this.gbi13.ShowValueString = false;
this.gbi13.Size = new System.Drawing.Size(294, 101);
this.gbi13.Size = new System.Drawing.Size(293, 101);
this.gbi13.TabIndex = 3;
this.gbi13.Tag = "PKZ";
this.gbi13.Tags = null;
@@ -1284,7 +1298,7 @@
this.lbi13.ForeColor = System.Drawing.Color.SkyBlue;
this.lbi13.Location = new System.Drawing.Point(0, 0);
this.lbi13.Name = "lbi13";
this.lbi13.Size = new System.Drawing.Size(294, 16);
this.lbi13.Size = new System.Drawing.Size(293, 16);
this.lbi13.TabIndex = 4;
this.lbi13.Text = "Z-PICKER2-F";
this.lbi13.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -1294,9 +1308,9 @@
this.panel22.Controls.Add(this.gbi14);
this.panel22.Controls.Add(this.lbi14);
this.panel22.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel22.Location = new System.Drawing.Point(603, 495);
this.panel22.Location = new System.Drawing.Point(601, 495);
this.panel22.Name = "panel22";
this.panel22.Size = new System.Drawing.Size(295, 117);
this.panel22.Size = new System.Drawing.Size(294, 117);
this.panel22.TabIndex = 0;
//
// gbi14
@@ -1331,7 +1345,7 @@
this.gbi14.ShowIndexString = true;
this.gbi14.ShowNameString = true;
this.gbi14.ShowValueString = false;
this.gbi14.Size = new System.Drawing.Size(295, 101);
this.gbi14.Size = new System.Drawing.Size(294, 101);
this.gbi14.TabIndex = 3;
this.gbi14.Tag = "PKZ";
this.gbi14.Tags = null;
@@ -1347,7 +1361,7 @@
this.lbi14.ForeColor = System.Drawing.Color.SkyBlue;
this.lbi14.Location = new System.Drawing.Point(0, 0);
this.lbi14.Name = "lbi14";
this.lbi14.Size = new System.Drawing.Size(295, 16);
this.lbi14.Size = new System.Drawing.Size(294, 16);
this.lbi14.TabIndex = 4;
this.lbi14.Text = "Z-PICKER3-F";
this.lbi14.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -1357,9 +1371,9 @@
this.panel1.Controls.Add(this.gbi05);
this.panel1.Controls.Add(this.lbi05);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(603, 126);
this.panel1.Location = new System.Drawing.Point(601, 126);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(295, 117);
this.panel1.Size = new System.Drawing.Size(294, 117);
this.panel1.TabIndex = 0;
//
// gbi05
@@ -1394,7 +1408,7 @@
this.gbi05.ShowIndexString = true;
this.gbi05.ShowNameString = true;
this.gbi05.ShowValueString = false;
this.gbi05.Size = new System.Drawing.Size(295, 101);
this.gbi05.Size = new System.Drawing.Size(294, 101);
this.gbi05.TabIndex = 3;
this.gbi05.Tag = "PKZ";
this.gbi05.Tags = null;
@@ -1410,7 +1424,7 @@
this.lbi05.ForeColor = System.Drawing.Color.Cyan;
this.lbi05.Location = new System.Drawing.Point(0, 0);
this.lbi05.Name = "lbi05";
this.lbi05.Size = new System.Drawing.Size(295, 16);
this.lbi05.Size = new System.Drawing.Size(294, 16);
this.lbi05.TabIndex = 4;
this.lbi05.Text = "X-FRONT";
this.lbi05.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -1422,7 +1436,7 @@
this.panel4.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel4.Location = new System.Drawing.Point(3, 618);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(294, 119);
this.panel4.Size = new System.Drawing.Size(293, 119);
this.panel4.TabIndex = 0;
//
// gbi15
@@ -1457,7 +1471,7 @@
this.gbi15.ShowIndexString = true;
this.gbi15.ShowNameString = true;
this.gbi15.ShowValueString = false;
this.gbi15.Size = new System.Drawing.Size(294, 103);
this.gbi15.Size = new System.Drawing.Size(293, 103);
this.gbi15.TabIndex = 3;
this.gbi15.Tag = "PKZ";
this.gbi15.Tags = null;
@@ -1473,7 +1487,7 @@
this.lbi15.ForeColor = System.Drawing.Color.Cyan;
this.lbi15.Location = new System.Drawing.Point(0, 0);
this.lbi15.Name = "lbi15";
this.lbi15.Size = new System.Drawing.Size(294, 16);
this.lbi15.Size = new System.Drawing.Size(293, 16);
this.lbi15.TabIndex = 4;
this.lbi15.Text = "X-FRONT";
this.lbi15.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -1483,9 +1497,9 @@
this.panel15.Controls.Add(this.gbi16);
this.panel15.Controls.Add(this.lbi16);
this.panel15.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel15.Location = new System.Drawing.Point(303, 618);
this.panel15.Location = new System.Drawing.Point(302, 618);
this.panel15.Name = "panel15";
this.panel15.Size = new System.Drawing.Size(294, 119);
this.panel15.Size = new System.Drawing.Size(293, 119);
this.panel15.TabIndex = 0;
//
// gbi16
@@ -1520,7 +1534,7 @@
this.gbi16.ShowIndexString = true;
this.gbi16.ShowNameString = true;
this.gbi16.ShowValueString = false;
this.gbi16.Size = new System.Drawing.Size(294, 103);
this.gbi16.Size = new System.Drawing.Size(293, 103);
this.gbi16.TabIndex = 3;
this.gbi16.Tag = "PKZ";
this.gbi16.Tags = null;
@@ -1536,7 +1550,7 @@
this.lbi16.ForeColor = System.Drawing.Color.Cyan;
this.lbi16.Location = new System.Drawing.Point(0, 0);
this.lbi16.Name = "lbi16";
this.lbi16.Size = new System.Drawing.Size(294, 16);
this.lbi16.Size = new System.Drawing.Size(293, 16);
this.lbi16.TabIndex = 4;
this.lbi16.Text = "X-FRONT";
this.lbi16.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -1546,9 +1560,9 @@
this.panel24.Controls.Add(this.gbi17);
this.panel24.Controls.Add(this.lbi17);
this.panel24.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel24.Location = new System.Drawing.Point(603, 618);
this.panel24.Location = new System.Drawing.Point(601, 618);
this.panel24.Name = "panel24";
this.panel24.Size = new System.Drawing.Size(295, 119);
this.panel24.Size = new System.Drawing.Size(294, 119);
this.panel24.TabIndex = 0;
//
// gbi17
@@ -1583,7 +1597,7 @@
this.gbi17.ShowIndexString = true;
this.gbi17.ShowNameString = true;
this.gbi17.ShowValueString = false;
this.gbi17.Size = new System.Drawing.Size(295, 103);
this.gbi17.Size = new System.Drawing.Size(294, 103);
this.gbi17.TabIndex = 3;
this.gbi17.Tag = "PKZ";
this.gbi17.Tags = null;
@@ -1599,7 +1613,7 @@
this.lbi17.ForeColor = System.Drawing.Color.Cyan;
this.lbi17.Location = new System.Drawing.Point(0, 0);
this.lbi17.Name = "lbi17";
this.lbi17.Size = new System.Drawing.Size(295, 16);
this.lbi17.Size = new System.Drawing.Size(294, 16);
this.lbi17.TabIndex = 4;
this.lbi17.Text = "X-FRONT";
this.lbi17.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -1609,20 +1623,6 @@
this.tmDisplay.Interval = 250;
this.tmDisplay.Tick += new System.EventHandler(this.tmDisplay_Tick);
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.pinDefineToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(153, 48);
//
// pinDefineToolStripMenuItem
//
this.pinDefineToolStripMenuItem.Name = "pinDefineToolStripMenuItem";
this.pinDefineToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.pinDefineToolStripMenuItem.Text = "Pin Define";
this.pinDefineToolStripMenuItem.Click += new System.EventHandler(this.pinDefineToolStripMenuItem_Click);
//
// fIOMonitor
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
@@ -1641,6 +1641,7 @@
this.tabPage1.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.contextMenuStrip1.ResumeLayout(false);
this.tabPage4.ResumeLayout(false);
this.tableLayoutPanel3.ResumeLayout(false);
this.panel6.ResumeLayout(false);
@@ -1664,7 +1665,6 @@
this.panel4.ResumeLayout(false);
this.panel15.ResumeLayout(false);
this.panel24.ResumeLayout(false);
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
}

View File

@@ -114,8 +114,6 @@ namespace Project.Dialog
}
//값확인
List<Boolean> diValue = new List<bool>();
for (int i = 0; i < PUB.dio.GetDICount; i++)

View File

@@ -104,7 +104,7 @@ namespace Project.WebUI
}
/// <summary>
/// <20><><EFBFBD>̱׷<CCB1><D7B7>̼<EFBFBD> <20><><EFBFBD><EFBFBD>
/// <20><><EFBFBD>̱׷<CCB1><D7B7>̼<EFBFBD> <20><><EFBFBD><EFBFBD>
/// </summary>
/// <returns></returns>
public string GetConfig()
@@ -196,7 +196,7 @@ namespace Project.WebUI
}
/// <summary>
/// <20><><EFBFBD>̱׷<CCB1><D7B7>̼Ǽ<CCBC><C7BC><EFBFBD>
/// <20><><EFBFBD>̱׷<CCB1><D7B7>̼Ǽ<CCBC><C7BC><EFBFBD>
/// </summary>
/// <param name="configJson"></param>
public void SaveConfig(string configJson)
@@ -261,79 +261,204 @@ namespace Project.WebUI
}
}
/// <summary>
/// 마이그레이션완료
/// </summary>
/// <returns></returns>
public string GetIOList()
{
var ioList = new List<object>();
// Outputs (0-31)
for (int i = 0; i < 32; i++)
try
{
string name = $"DOUT_{i:D2}";
if (i == 0) name = "Tower Lamp Red";
if (i == 1) name = "Tower Lamp Yel";
if (i == 2) name = "Tower Lamp Grn";
ioList.Add(new { id = i, name = name, type = "output", state = false });
}
// Inputs (0-31)
for (int i = 0; i < 32; i++)
var result = new
{
string name = $"DIN_{i:D2}";
bool initialState = false;
if (i == 0) name = "Front Door Sensor";
if (i == 1) name = "Right Door Sensor";
if (i == 2) name = "Left Door Sensor";
if (i == 3) name = "Back Door Sensor";
if (i == 4) { name = "Main Air Pressure"; initialState = true; }
if (i == 5) { name = "Vacuum Generator"; initialState = true; }
if (i == 6) { name = "Emergency Stop Loop"; initialState = true; }
inputs = GetDigitalInputs(),
outputs = GetDigitalOutputs(),
interlocks = GetInterlocks()
};
ioList.Add(new { id = i, name = name, type = "input", state = initialState });
return JsonConvert.SerializeObject(result);
}
catch (Exception ex)
{
Console.WriteLine($"[ERROR] Failed to get IO list: {ex.Message}");
return JsonConvert.SerializeObject(new { inputs = new List<object>(), outputs = new List<object>(), interlocks = new List<object>() });
}
}
/// <summary>
/// 마이그레이션완료
/// </summary>
/// <returns></returns>
private List<object> GetDigitalInputs()
{
var inputs = new List<object>();
try
{
var diNames = DIO.Pin.GetDIName;
var diPinNames = DIO.Pin.GetDIPinName;
int diCount = PUB.dio.GetDICount;
for (int i = 0; i < diCount; i++)
{
bool state = PUB.dio.GetDIValue(i);
string name = i < diNames.Length ? diNames[i] : $"DIN_{i:D2}";
string pinName = i < diPinNames.Length ? diPinNames[i] : $"X{i:D2}";
inputs.Add(new
{
id = i,
name = name,
pinName = pinName,
type = "input",
state = state
});
}
}
catch (Exception ex)
{
Console.WriteLine($"[ERROR] Failed to get digital inputs: {ex.Message}");
}
return JsonConvert.SerializeObject(ioList);
return inputs;
}
/// <summary>
/// 마이그레이션완료
/// </summary>
/// <returns></returns>
private List<object> GetDigitalOutputs()
{
var outputs = new List<object>();
try
{
var doNames = DIO.Pin.GetDOName;
var doPinNames = DIO.Pin.GetDOPinName;
int doCount = PUB.dio.GetDOCount;
for (int i = 0; i < doCount; i++)
{
bool state = PUB.dio.GetDOValue(i);
string name = i < doNames.Length ? doNames[i] : $"DOUT_{i:D2}";
string pinName = i < doPinNames.Length ? doPinNames[i] : $"Y{i:D2}";
outputs.Add(new
{
id = i,
name = name,
pinName = pinName,
type = "output",
state = state
});
}
}
catch (Exception ex)
{
Console.WriteLine($"[ERROR] Failed to get digital outputs: {ex.Message}");
}
return outputs;
}
/// <summary>
/// 마이그레이션완료
/// </summary>
/// <returns></returns>
private List<object> GetInterlocks()
{
var interlocks = new List<object>();
try
{
for (int i = 0; i < PUB.iLock.Length; i++)
{
var axisName = ((AR.eAxis)i).ToString();
var nonAxis = false;
// Check if this is a non-axis interlock (i >= 7)
if (i >= 7)
{
axisName = PUB.iLock[i].Tag.ToString();
nonAxis = true;
}
// Get enum names based on axis index
string[] ilockNames;
if (i == 7) ilockNames = Enum.GetNames(typeof(eILockPRL));
else if (i == 8) ilockNames = Enum.GetNames(typeof(eILockPRR));
else if (i == 9) ilockNames = Enum.GetNames(typeof(eILockVS0));
else if (i == 10) ilockNames = Enum.GetNames(typeof(eILockVS1));
else if (i == 11) ilockNames = Enum.GetNames(typeof(eILockVS2));
else if (i == 12 || i == 13) ilockNames = Enum.GetNames(typeof(eILockCV));
else ilockNames = Enum.GetNames(typeof(eILock));
// Get interlock values (up to 64 bits)
var lockValues = new List<object>();
for (int j = 0; j < ilockNames.Length && j < 64; j++)
{
bool state = PUB.iLock[i].get(j);
lockValues.Add(new
{
id = j,
name = ilockNames[j],
state = state
});
}
interlocks.Add(new
{
axisIndex = i,
axisName = axisName,
nonAxis = nonAxis,
locks = lockValues,
hexValue = PUB.iLock[i].Value().HexString()
});
}
}
catch (Exception ex)
{
Console.WriteLine($"[ERROR] Failed to get interlocks: {ex.Message}");
}
return interlocks;
}
/// <summary>
/// 마이그레이션완료
/// </summary>
/// <returns></returns>
public string GetRecipeList()
{
//PUB.mdm.dataSet.OPModel에 등록된 데이터가 모델 목록이다
try
{
var recipes = new List<object>();
if (!Directory.Exists(_recipeFolder))
if (PUB.mdm == null || PUB.mdm.dataSet == null || PUB.mdm.dataSet.OPModel == null)
{
Directory.CreateDirectory(_recipeFolder);
Console.WriteLine($"[WARN] OPModel is not initialized");
return JsonConvert.SerializeObject(recipes);
}
var jsonFiles = Directory.GetFiles(_recipeFolder, "*.json");
foreach (var filePath in jsonFiles)
// OPModel 테이블에서 Title이 비어있지 않은 항목만 가져오기
foreach (var row in PUB.mdm.dataSet.OPModel)
{
try
{
string fileName = Path.GetFileNameWithoutExtension(filePath);
string json = File.ReadAllText(filePath);
var recipeData = JsonConvert.DeserializeObject<dynamic>(json);
var modelRow = row as DataSet1.OPModelRow;
if (modelRow == null) continue;
var lastModified = File.GetLastWriteTime(filePath).ToString("yyyy-MM-dd");
// Title이 비어있으면 스킵
if (string.IsNullOrEmpty(modelRow.Title))
continue;
recipes.Add(new
{
id = fileName,
name = recipeData?.name ?? fileName,
lastModified = lastModified
id = modelRow.idx.ToString(),
name = modelRow.Title,
lastModified = DateTime.Now.ToString("yyyy-MM-dd")
});
}
catch (Exception ex)
{
Console.WriteLine($"[ERROR] Failed to read recipe {filePath}: {ex.Message}");
}
}
Console.WriteLine($"[INFO] Loaded {recipes.Count} recipes from {_recipeFolder}");
Console.WriteLine($"[INFO] Loaded {recipes.Count} recipes from OPModel");
return JsonConvert.SerializeObject(recipes);
}
catch (Exception ex)
@@ -343,47 +468,125 @@ namespace Project.WebUI
}
}
public string GetRecipe(string recipeId)
/// <summary>
/// 마이그레이션완료
/// </summary>
/// <param name="recipeTitle"></param>
/// <returns></returns>
public string GetRecipe(string recipeTitle)
{
try
{
string recipePath = Path.Combine(_recipeFolder, $"{recipeId}.json");
var dr = PUB.mdm.GetDataV(recipeTitle);
if (!File.Exists(recipePath))
if (dr == null)
{
var response = new { success = false, message = "Recipe not found" };
return JsonConvert.SerializeObject(response);
}
string json = File.ReadAllText(recipePath);
Console.WriteLine($"[INFO] Loaded recipe {recipeId}");
return json;
// DataRow의 모든 컬럼을 Dictionary로 변환
var recipeData = new Dictionary<string, object>();
foreach (System.Data.DataColumn col in dr.Table.Columns)
{
string colName = col.ColumnName;
object value = dr[colName];
// DBNull을 null로 변환
if (value == DBNull.Value)
value = null;
recipeData[colName] = value;
}
Console.WriteLine($"[INFO] Loaded recipe {recipeTitle}");
return JsonConvert.SerializeObject(recipeData);
}
catch (Exception ex)
{
Console.WriteLine($"[ERROR] Failed to get recipe {recipeId}: {ex.Message}");
Console.WriteLine($"[ERROR] Failed to get recipe {recipeTitle}: {ex.Message}");
var response = new { success = false, message = ex.Message };
return JsonConvert.SerializeObject(response);
}
}
public string SaveRecipe(string recipeId, string recipeData)
/// <summary>
/// 마이그레이션완료
/// </summary>
/// <param name="recipeTitle"></param>
/// <param name="recipeData"></param>
/// <returns></returns>
public string SaveRecipe(string recipeTitle, string recipeData)
{
try
{
string recipePath = Path.Combine(_recipeFolder, $"{recipeId}.json");
var dr = PUB.mdm.GetDataV(recipeTitle);
var recipe = JsonConvert.DeserializeObject(recipeData);
File.WriteAllText(recipePath, JsonConvert.SerializeObject(recipe, Formatting.Indented));
Console.WriteLine($"[INFO] Recipe {recipeId} saved successfully to {recipePath}");
var response = new { success = true, message = "Recipe saved successfully", recipeId = recipeId };
if (dr == null)
{
var response = new { success = false, message = "Recipe not found" };
return JsonConvert.SerializeObject(response);
}
// JSON 데이터를 Dictionary로 변환
var recipeDict = JsonConvert.DeserializeObject<Dictionary<string, object>>(recipeData);
// DataRow의 각 컬럼 업데이트
foreach (var kvp in recipeDict)
{
string colName = kvp.Key;
// 컬럼이 테이블에 존재하는지 확인
if (!dr.Table.Columns.Contains(colName))
continue;
// idx나 Midx 같은 자동 생성 컬럼은 스킵
if (colName == "idx" || colName == "Midx")
continue;
try
{
var col = dr.Table.Columns[colName];
object value = kvp.Value;
// null 처리
if (value == null)
{
dr[colName] = DBNull.Value;
}
else
{
// 타입 변환
if (col.DataType == typeof(bool))
dr[colName] = Convert.ToBoolean(value);
else if (col.DataType == typeof(int))
dr[colName] = Convert.ToInt32(value);
else if (col.DataType == typeof(double))
dr[colName] = Convert.ToDouble(value);
else if (col.DataType == typeof(float))
dr[colName] = Convert.ToSingle(value);
else
dr[colName] = value.ToString();
}
}
catch (Exception ex)
{
Console.WriteLine($"[ERROR] Failed to save recipe {recipeId}: {ex.Message}");
Console.WriteLine($"[WARN] Failed to set column {colName}: {ex.Message}");
}
}
// 변경사항 저장
PUB.mdm.dataSet.OPModel.AcceptChanges();
PUB.mdm.SaveModelV();
Console.WriteLine($"[INFO] Recipe {recipeTitle} saved successfully to OPModel");
var response2 = new { success = true, message = "Recipe saved successfully", recipeId = recipeTitle };
return JsonConvert.SerializeObject(response2);
}
catch (Exception ex)
{
Console.WriteLine($"[ERROR] Failed to save recipe {recipeTitle}: {ex.Message}");
var response = new { success = false, message = ex.Message };
return JsonConvert.SerializeObject(response);
}