Browse Source

add a video tutoria named opreator.wmv

pull/17/head
Gavin 9 years ago
parent
commit
7f5a4d63de
  1. BIN
      Document/opreator.wmv
  2. BIN
      SCADA/Example/TagConfig.exe
  3. 14
      SCADA/Program/TagConfig/TagConfig/Form1.Designer.cs
  4. 67
      SCADA/Program/TagConfig/TagConfig/Form1.cs
  5. 2
      SCADA/Program/TagConfig/TagConfig/Form1.resx

BIN
Document/opreator.wmv

Binary file not shown.

BIN
SCADA/Example/TagConfig.exe

Binary file not shown.

14
SCADA/Program/TagConfig/TagConfig/Form1.Designer.cs

@ -113,6 +113,7 @@
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.CSVToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout();
@ -394,9 +395,10 @@
this.tspcut, this.tspcut,
this.tsppaste, this.tsppaste,
this.ToolStripMenuItem, this.ToolStripMenuItem,
this.ToolStripMenuItem}); this.ToolStripMenuItem,
this.CSVToolStripMenuItem});
this.contextMenuStrip2.Name = "contextMenuStrip2"; this.contextMenuStrip2.Name = "contextMenuStrip2";
this.contextMenuStrip2.Size = new System.Drawing.Size(195, 202); this.contextMenuStrip2.Size = new System.Drawing.Size(195, 224);
this.contextMenuStrip2.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip2_Opening); this.contextMenuStrip2.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip2_Opening);
this.contextMenuStrip2.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStrip2_ItemClicked); this.contextMenuStrip2.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.contextMenuStrip2_ItemClicked);
// //
@ -773,6 +775,13 @@
this.tspCount.Name = "tspCount"; this.tspCount.Name = "tspCount";
this.tspCount.Size = new System.Drawing.Size(0, 17); this.tspCount.Size = new System.Drawing.Size(0, 17);
// //
// 粘贴CSVToolStripMenuItem
//
this.CSVToolStripMenuItem.Name = "粘贴CSVToolStripMenuItem";
this.CSVToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y)));
this.CSVToolStripMenuItem.Size = new System.Drawing.Size(194, 22);
this.CSVToolStripMenuItem.Text = "粘贴CSV";
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@ -888,6 +897,7 @@
private System.Windows.Forms.ToolStripSeparator toolStripSeparator9; private System.Windows.Forms.ToolStripSeparator toolStripSeparator9;
private System.Windows.Forms.ToolStripButton toolStripButton5; private System.Windows.Forms.ToolStripButton toolStripButton5;
private System.Windows.Forms.ToolStripTextBox tspOffset; private System.Windows.Forms.ToolStripTextBox tspOffset;
private System.Windows.Forms.ToolStripMenuItem CSVToolStripMenuItem;
} }
} }

67
SCADA/Program/TagConfig/TagConfig/Form1.cs

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
using Excel = Microsoft.Office.Interop.Excel; using Excel = Microsoft.Office.Interop.Excel;
@ -398,34 +399,44 @@ namespace TagConfig
} }
} }
private void LoadFromCsv(string file) private void LoadFromCsv()
{ {
Excel.Application app = new Excel.Application(); if (Clipboard.ContainsText(TextDataFormat.Text))
Workbook book = app.Workbooks.Open(file);
Worksheet sheet = (Worksheet)book.Sheets[1];
list.Clear();
for (int i = 2; i < sheet.Rows.Count; i++)
{ {
if (((Range)sheet.Cells[i, 1]).Value2 == null) string data = Clipboard.GetText(TextDataFormat.Text);
break; if (string.IsNullOrEmpty(data)) return;
try list.Clear();
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(data)))
{ {
short id = Convert.ToInt16(((Range)sheet.Cells[i, 1]).Value2); using (var mysr = new StreamReader(stream))
TagData tag = new TagData(id, Convert.ToInt16(((Range)sheet.Cells[i, 2]).Value2), ((Range)sheet.Cells[i, 3]).Value2.ToString(), {
((Range)sheet.Cells[i, 4]).Value2.ToString(), Convert.ToByte(((Range)sheet.Cells[i, 5]).Value2), Convert.ToUInt16(((Range)sheet.Cells[i, 6]).Value2), string strline = mysr.ReadLine();
Convert.ToBoolean(((Range)sheet.Cells[i, 7]).Value2), Convert.ToBoolean(((Range)sheet.Cells[i, 8]).Value2), Convert.ToBoolean(((Range)sheet.Cells[i, 9]).Value2), while ((strline = mysr.ReadLine()) != null)
Convert.ToBoolean(((Range)sheet.Cells[i, 10]).Value2), ((Range)sheet.Cells[i, 11]).Value2, ((Range)sheet.Cells[i, 12]).Value2 as string, {
Convert.ToSingle(((Range)sheet.Cells[i, 13]).Value2), Convert.ToSingle(((Range)sheet.Cells[i, 14]).Value2), Convert.ToInt32(((Range)sheet.Cells[i, 15]).Value2)); string[] aryline = strline.Split('\t');
list.Add(tag); try
} {
catch (Exception e) var id = Convert.ToInt16(aryline[0]);
{ var groupid = Convert.ToInt16(aryline[1]);
continue; var name = aryline[2];
//Program.AddErrorLog(e); var address = aryline[3];
var type = Convert.ToByte(aryline[4]);
var size = Convert.ToUInt16(aryline[5]);
var active = Convert.ToBoolean(aryline[6]);
var desp = aryline[7];
TagData tag = new TagData(id, groupid, name, address, type, size, active, false, false, false, null, desp, 0, 0, 0);
list.Add(tag);
}
catch (Exception err)
{
continue;
}
}
}
} }
list.Sort();
start = true;
} }
list.Sort();
start = true;
} }
private void LoadFromExcel(string file) private void LoadFromExcel(string file)
@ -914,7 +925,7 @@ namespace TagConfig
} }
break; break;
case "导入变量": case "导入变量":
openFileDialog1.Filter = "xml文件 (*.xml)|*.xml|csv文件 (*.csv)|*.csv|excel文件 (*.xlsx)|*.xlsx|kepserver文件 (*.csv)|*.csv|All files (*.*)|*.*"; openFileDialog1.Filter = "xml文件 (*.xml)|*.xml|excel文件 (*.xlsx)|*.xlsx|kepserver文件 (*.csv)|*.csv|All files (*.*)|*.*";
openFileDialog1.DefaultExt = "xml"; openFileDialog1.DefaultExt = "xml";
if (openFileDialog1.ShowDialog() == DialogResult.OK) if (openFileDialog1.ShowDialog() == DialogResult.OK)
{ {
@ -925,12 +936,9 @@ namespace TagConfig
LoadFromXml(file); LoadFromXml(file);
break; break;
case 2: case 2:
LoadFromCsv(file);
break;
case 3:
LoadFromExcel(file); LoadFromExcel(file);
break; break;
case 4: case 3:
LoadFromKepserverCSV(file); LoadFromKepserverCSV(file);
break; break;
} }
@ -1170,6 +1178,9 @@ namespace TagConfig
isCut = true; isCut = true;
} }
break; break;
case "粘贴CSV":
LoadFromCsv();
break;
case "粘帖": case "粘帖":
{ {
if (treeView1.SelectedNode == null || treeView1.SelectedNode.Level != 2) if (treeView1.SelectedNode == null || treeView1.SelectedNode.Level != 2)

2
SCADA/Program/TagConfig/TagConfig/Form1.resx

@ -128,7 +128,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 LCBDdWx0dXJlPW5ldXRy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