├── .gitignore
├── LICENSE
├── PIToolkit
├── .gitignore
├── AFEventsCleaner
│ ├── AFEventsCleaner.csproj
│ ├── AssemblyInfo.cs
│ ├── Form1.Designer.cs
│ ├── Form1.cs
│ ├── Form1.resx
│ ├── Program.cs
│ └── app.config
├── PBToolkitBar
│ ├── AssemblyInfo.cs
│ ├── PBTKUtils.cs
│ ├── PBToolkitBar.Designer.cs
│ ├── PBToolkitBar.cs
│ ├── PBToolkitBar.csproj
│ ├── PBToolkitBar.resx
│ ├── Program.cs
│ └── app.config
├── PIBrowser
│ ├── Filters
│ │ ├── LowPassFilter.cs
│ │ └── SplineFilter.cs
│ ├── Forms
│ │ ├── AboutDlg.Designer.cs
│ │ ├── AboutDlg.cs
│ │ ├── ConnectionDlg.Designer.cs
│ │ ├── ConnectionDlg.cs
│ │ ├── PIBrowserWin.Designer.cs
│ │ ├── PIBrowserWin.cs
│ │ ├── TrendsOptionsDlg.Designer.cs
│ │ └── TrendsOptionsDlg.cs
│ ├── PIAPI32.cs
│ ├── PIBDataMath.cs
│ ├── PIBTrendChart.cs
│ ├── PIBUtils.cs
│ ├── PIBrowser.csproj
│ ├── Program.cs
│ ├── Resources
│ │ ├── about.gif
│ │ ├── clock.png
│ │ ├── configure.gif
│ │ ├── delete.gif
│ │ ├── load.gif
│ │ ├── options.gif
│ │ ├── print.gif
│ │ ├── save.gif
│ │ └── taggr.gif
│ └── app.config
├── PIBrowserTests
│ ├── AssemblyInfo.cs
│ ├── PIAPI32Tests.cs
│ ├── PIBTests.cs
│ └── PIBrowserTests.csproj
├── PITagsCleaner
│ ├── AssemblyInfo.cs
│ ├── MainForm.Designer.cs
│ ├── MainForm.cs
│ ├── MainForm.resx
│ ├── PITagsCleaner.csproj
│ ├── Program.cs
│ └── app.config
├── PIToolkit.sln
└── clean.cmd
├── README.md
├── RSVTagsExtractor
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── RSVTagsExtractor.csproj
└── app.config
├── SCADATools.sln
├── WCCTagsExtractor
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── WCCTagsExtractor.csproj
└── app.config
├── clean.cmd
└── libs
├── BSLib.Controls.dll
├── BSLib.dll
├── OpenMcdf.dll
├── OpenMcdf.xml
├── ZedGraph.dll
├── nunit.framework.dll
├── x64
└── piapi.dll
└── x86
└── piapi32.dll
/.gitignore:
--------------------------------------------------------------------------------
1 | **/.vs/
2 | /*.exe*
3 | /*.dll
4 | *.pdb
5 | *.mdb
6 | *.suo
7 | *.userprefs
8 | *.DotSettings.user
9 |
10 | /RSVTagsExtractor/bin/
11 | /RSVTagsExtractor/obj/
12 |
13 | /WCCTagsExtractor/bin/
14 | /WCCTagsExtractor/obj/
15 |
16 | /libs/OSIsoft.*.dll
17 | /libs/OSIsoft.*.xml
18 |
--------------------------------------------------------------------------------
/PIToolkit/.gitignore:
--------------------------------------------------------------------------------
1 | **/.vs/
2 | /*.exe*
3 | /*.dll
4 | *.pdb
5 | *.mdb
6 | *.suo
7 | *.userprefs
8 | *.DotSettings.user
9 |
10 | /AFEventsCleaner/bin/
11 | /AFEventsCleaner/obj/
12 |
13 | /PITagsCleaner/bin/
14 | /PITagsCleaner/obj/
15 |
16 | /PIBrowser/bin/
17 | /PIBrowser/obj/
18 |
19 | /PIBrowserTests/bin/
20 | /PIBrowserTests/obj/
21 | /PIBrowserTests/OpenCover/
22 |
23 | /temp/
24 |
25 | /PBToolkitBar/bin
26 | /PBToolkitBar/obj
27 |
--------------------------------------------------------------------------------
/PIToolkit/AFEventsCleaner/AFEventsCleaner.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {246C2105-C134-4372-AAD6-727871C8FFB1}
9 | WinExe
10 | Properties
11 | AFEventsCleaner
12 | AFEventsCleaner
13 | v4.5.2
14 |
15 |
16 | 512
17 | False
18 | False
19 | False
20 | False
21 | obj\$(Configuration)\
22 | bin\Debug\
23 | Full
24 | 4
25 |
26 |
27 | true
28 | prompt
29 |
30 |
31 | prompt
32 |
33 |
34 | True
35 | obj\
36 | DEBUG;TRACE
37 | False
38 |
39 |
40 | 4194304
41 | False
42 | Auto
43 | x86
44 |
45 |
46 | TRACE
47 | True
48 | False
49 | obj\
50 |
51 |
52 | 4194304
53 | AnyCPU
54 | True
55 | False
56 | Auto
57 |
58 |
59 |
60 | False
61 | ..\..\PIPC (x86)\AF\PublicAssemblies\OSIsoft.AFSDK.dll
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | Form
74 |
75 |
76 | Form1.cs
77 |
78 |
79 |
80 | Form1.cs
81 |
82 |
83 |
84 |
85 |
92 |
--------------------------------------------------------------------------------
/PIToolkit/AFEventsCleaner/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("AFEventsCleaner")]
6 | [assembly: AssemblyDescription("")]
7 | [assembly: AssemblyConfiguration("")]
8 | [assembly: AssemblyCompany("")]
9 | [assembly: AssemblyProduct("AFEventsCleaner")]
10 | [assembly: AssemblyCopyright("Copyright © 2016 by Sergey V. Zhdanovskih")]
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: ComVisible(false)]
14 | [assembly: Guid("4c1b25ea-46bf-418d-a4bc-e7222aed7a3c")]
15 | [assembly: AssemblyVersion("1.0.0.0")]
16 | [assembly: AssemblyFileVersion("1.0.0.0")]
17 |
--------------------------------------------------------------------------------
/PIToolkit/AFEventsCleaner/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace AFEventsCleaner
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null)) {
17 | components.Dispose();
18 | }
19 | base.Dispose(disposing);
20 | }
21 |
22 | #region Windows Form Designer generated code
23 |
24 | ///
25 | /// Required method for Designer support - do not modify
26 | /// the contents of this method with the code editor.
27 | ///
28 | private void InitializeComponent()
29 | {
30 | this.btnClean = new System.Windows.Forms.Button();
31 | this.label1 = new System.Windows.Forms.Label();
32 | this.label2 = new System.Windows.Forms.Label();
33 | this.label3 = new System.Windows.Forms.Label();
34 | this.dtpStartTime = new System.Windows.Forms.DateTimePicker();
35 | this.dtpEndTime = new System.Windows.Forms.DateTimePicker();
36 | this.txtTemplate = new System.Windows.Forms.TextBox();
37 | this.progressBar1 = new System.Windows.Forms.ProgressBar();
38 | this.label4 = new System.Windows.Forms.Label();
39 | this.txtAFServer = new System.Windows.Forms.TextBox();
40 | this.label5 = new System.Windows.Forms.Label();
41 | this.txtLogin = new System.Windows.Forms.TextBox();
42 | this.label6 = new System.Windows.Forms.Label();
43 | this.txtPassword = new System.Windows.Forms.TextBox();
44 | this.label7 = new System.Windows.Forms.Label();
45 | this.txtAFDatabase = new System.Windows.Forms.TextBox();
46 | this.SuspendLayout();
47 | //
48 | // btnClean
49 | //
50 | this.btnClean.Location = new System.Drawing.Point(13, 197);
51 | this.btnClean.Margin = new System.Windows.Forms.Padding(4);
52 | this.btnClean.Name = "btnClean";
53 | this.btnClean.Size = new System.Drawing.Size(100, 28);
54 | this.btnClean.TabIndex = 0;
55 | this.btnClean.Text = "Clean";
56 | this.btnClean.UseVisualStyleBackColor = true;
57 | this.btnClean.Click += new System.EventHandler(this.btnClean_Click);
58 | //
59 | // label1
60 | //
61 | this.label1.AutoSize = true;
62 | this.label1.Location = new System.Drawing.Point(9, 65);
63 | this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
64 | this.label1.Name = "label1";
65 | this.label1.Size = new System.Drawing.Size(69, 17);
66 | this.label1.TabIndex = 1;
67 | this.label1.Text = "StartTime";
68 | //
69 | // label2
70 | //
71 | this.label2.AutoSize = true;
72 | this.label2.Location = new System.Drawing.Point(198, 65);
73 | this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
74 | this.label2.Name = "label2";
75 | this.label2.Size = new System.Drawing.Size(64, 17);
76 | this.label2.TabIndex = 2;
77 | this.label2.Text = "EndTime";
78 | //
79 | // label3
80 | //
81 | this.label3.AutoSize = true;
82 | this.label3.Location = new System.Drawing.Point(380, 65);
83 | this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
84 | this.label3.Name = "label3";
85 | this.label3.Size = new System.Drawing.Size(67, 17);
86 | this.label3.TabIndex = 3;
87 | this.label3.Text = "Template";
88 | //
89 | // dtpStartTime
90 | //
91 | this.dtpStartTime.CustomFormat = "dd.MM.yyyy HH:mm:ss";
92 | this.dtpStartTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
93 | this.dtpStartTime.Location = new System.Drawing.Point(13, 85);
94 | this.dtpStartTime.Margin = new System.Windows.Forms.Padding(4);
95 | this.dtpStartTime.Name = "dtpStartTime";
96 | this.dtpStartTime.Size = new System.Drawing.Size(176, 22);
97 | this.dtpStartTime.TabIndex = 4;
98 | this.dtpStartTime.Value = new System.DateTime(2016, 6, 23, 9, 9, 0, 0);
99 | //
100 | // dtpEndTime
101 | //
102 | this.dtpEndTime.CustomFormat = "dd.MM.yyyy HH:mm:ss";
103 | this.dtpEndTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
104 | this.dtpEndTime.Location = new System.Drawing.Point(198, 85);
105 | this.dtpEndTime.Margin = new System.Windows.Forms.Padding(4);
106 | this.dtpEndTime.Name = "dtpEndTime";
107 | this.dtpEndTime.Size = new System.Drawing.Size(176, 22);
108 | this.dtpEndTime.TabIndex = 4;
109 | //
110 | // txtTemplate
111 | //
112 | this.txtTemplate.Location = new System.Drawing.Point(384, 85);
113 | this.txtTemplate.Margin = new System.Windows.Forms.Padding(4);
114 | this.txtTemplate.Name = "txtTemplate";
115 | this.txtTemplate.Size = new System.Drawing.Size(303, 22);
116 | this.txtTemplate.TabIndex = 5;
117 | //
118 | // progressBar1
119 | //
120 | this.progressBar1.Location = new System.Drawing.Point(13, 161);
121 | this.progressBar1.Margin = new System.Windows.Forms.Padding(4);
122 | this.progressBar1.Name = "progressBar1";
123 | this.progressBar1.Size = new System.Drawing.Size(675, 28);
124 | this.progressBar1.TabIndex = 6;
125 | //
126 | // label4
127 | //
128 | this.label4.AutoSize = true;
129 | this.label4.Location = new System.Drawing.Point(13, 9);
130 | this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
131 | this.label4.Name = "label4";
132 | this.label4.Size = new System.Drawing.Size(71, 17);
133 | this.label4.TabIndex = 3;
134 | this.label4.Text = "AF Server";
135 | //
136 | // txtAFServer
137 | //
138 | this.txtAFServer.Location = new System.Drawing.Point(13, 30);
139 | this.txtAFServer.Margin = new System.Windows.Forms.Padding(4);
140 | this.txtAFServer.Name = "txtAFServer";
141 | this.txtAFServer.Size = new System.Drawing.Size(176, 22);
142 | this.txtAFServer.TabIndex = 5;
143 | //
144 | // label5
145 | //
146 | this.label5.AutoSize = true;
147 | this.label5.Location = new System.Drawing.Point(326, 9);
148 | this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
149 | this.label5.Name = "label5";
150 | this.label5.Size = new System.Drawing.Size(43, 17);
151 | this.label5.TabIndex = 3;
152 | this.label5.Text = "Login";
153 | //
154 | // txtLogin
155 | //
156 | this.txtLogin.Location = new System.Drawing.Point(326, 30);
157 | this.txtLogin.Margin = new System.Windows.Forms.Padding(4);
158 | this.txtLogin.Name = "txtLogin";
159 | this.txtLogin.Size = new System.Drawing.Size(176, 22);
160 | this.txtLogin.TabIndex = 5;
161 | //
162 | // label6
163 | //
164 | this.label6.AutoSize = true;
165 | this.label6.Location = new System.Drawing.Point(512, 9);
166 | this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
167 | this.label6.Name = "label6";
168 | this.label6.Size = new System.Drawing.Size(69, 17);
169 | this.label6.TabIndex = 3;
170 | this.label6.Text = "Password";
171 | //
172 | // txtPassword
173 | //
174 | this.txtPassword.Location = new System.Drawing.Point(512, 30);
175 | this.txtPassword.Margin = new System.Windows.Forms.Padding(4);
176 | this.txtPassword.Name = "txtPassword";
177 | this.txtPassword.PasswordChar = '*';
178 | this.txtPassword.Size = new System.Drawing.Size(176, 22);
179 | this.txtPassword.TabIndex = 5;
180 | //
181 | // label7
182 | //
183 | this.label7.AutoSize = true;
184 | this.label7.Location = new System.Drawing.Point(198, 9);
185 | this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
186 | this.label7.Name = "label7";
187 | this.label7.Size = new System.Drawing.Size(90, 17);
188 | this.label7.TabIndex = 3;
189 | this.label7.Text = "AF Database";
190 | //
191 | // txtAFDatabase
192 | //
193 | this.txtAFDatabase.Location = new System.Drawing.Point(198, 30);
194 | this.txtAFDatabase.Margin = new System.Windows.Forms.Padding(4);
195 | this.txtAFDatabase.Name = "txtAFDatabase";
196 | this.txtAFDatabase.Size = new System.Drawing.Size(120, 22);
197 | this.txtAFDatabase.TabIndex = 5;
198 | //
199 | // Form1
200 | //
201 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
202 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
203 | this.ClientSize = new System.Drawing.Size(715, 238);
204 | this.Controls.Add(this.progressBar1);
205 | this.Controls.Add(this.txtPassword);
206 | this.Controls.Add(this.txtLogin);
207 | this.Controls.Add(this.txtAFDatabase);
208 | this.Controls.Add(this.txtAFServer);
209 | this.Controls.Add(this.txtTemplate);
210 | this.Controls.Add(this.dtpEndTime);
211 | this.Controls.Add(this.label6);
212 | this.Controls.Add(this.label5);
213 | this.Controls.Add(this.label7);
214 | this.Controls.Add(this.label4);
215 | this.Controls.Add(this.dtpStartTime);
216 | this.Controls.Add(this.label3);
217 | this.Controls.Add(this.label2);
218 | this.Controls.Add(this.label1);
219 | this.Controls.Add(this.btnClean);
220 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
221 | this.Margin = new System.Windows.Forms.Padding(4);
222 | this.MaximizeBox = false;
223 | this.Name = "Form1";
224 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
225 | this.Text = "AF EventFrames Cleaner";
226 | this.ResumeLayout(false);
227 | this.PerformLayout();
228 |
229 | }
230 |
231 | #endregion
232 |
233 | private System.Windows.Forms.Button btnClean;
234 | private System.Windows.Forms.Label label1;
235 | private System.Windows.Forms.Label label2;
236 | private System.Windows.Forms.Label label3;
237 | private System.Windows.Forms.DateTimePicker dtpStartTime;
238 | private System.Windows.Forms.DateTimePicker dtpEndTime;
239 | private System.Windows.Forms.TextBox txtTemplate;
240 | private System.Windows.Forms.ProgressBar progressBar1;
241 | private System.Windows.Forms.Label label4;
242 | private System.Windows.Forms.TextBox txtAFServer;
243 | private System.Windows.Forms.Label label5;
244 | private System.Windows.Forms.TextBox txtLogin;
245 | private System.Windows.Forms.Label label6;
246 | private System.Windows.Forms.TextBox txtPassword;
247 | private System.Windows.Forms.Label label7;
248 | private System.Windows.Forms.TextBox txtAFDatabase;
249 | }
250 | }
251 |
252 |
--------------------------------------------------------------------------------
/PIToolkit/AFEventsCleaner/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Net;
4 | using System.Windows.Forms;
5 | using OSIsoft.AF;
6 | using OSIsoft.AF.Asset;
7 | using OSIsoft.AF.EventFrame;
8 |
9 | namespace AFEventsCleaner
10 | {
11 | public partial class Form1 : Form
12 | {
13 | private AFDatabase _afDb;
14 |
15 | public Form1()
16 | {
17 | InitializeComponent();
18 | }
19 |
20 | private bool ConnectAF()
21 | {
22 | PISystem piSys = new PISystems()[txtAFServer.Text];
23 | var credential = new NetworkCredential(txtLogin.Text, txtPassword.Text);
24 |
25 | try {
26 | if (!piSys.ConnectionInfo.IsConnected) {
27 | piSys.Connect(credential);
28 | }
29 |
30 | _afDb = piSys.Databases[txtAFDatabase.Text];
31 | return true;
32 | } catch (Exception ex) {
33 | MessageBox.Show(ex.Message);
34 | return false;
35 | }
36 | }
37 |
38 | private void CleanEventFrames(DateTime startTime, DateTime endTime, string template)
39 | {
40 | this.Enabled = false;
41 | try {
42 | var efTemplate = _afDb.ElementTemplates[template];
43 | if (efTemplate == null) {
44 | throw new Exception(string.Format("{0} not found", template));
45 | }
46 |
47 | int count = 0;
48 | while (true) {
49 | var frames = AFEventFrame.FindEventFrames(_afDb, null, AFSearchMode.Overlapped, startTime, endTime, "*", "*", null,
50 | efTemplate, null, false, AFSortField.StartTime, AFSortOrder.Ascending, 0, 1000);
51 |
52 | if (frames.Count <= 0)
53 | break;
54 |
55 | progressBar1.Maximum = frames.Count;
56 | progressBar1.Step = 1;
57 | progressBar1.Value = 0;
58 |
59 | foreach (AFEventFrame frame in frames) {
60 | double ts = frame.EndTime.UtcSeconds - frame.StartTime.UtcSeconds;
61 |
62 | if (ts < 1.0 && string.Equals(frame.Template.Name, template)) {
63 | try {
64 | frame.Delete();
65 | count++;
66 |
67 | if (count >= 1000) {
68 | _afDb.CheckIn(AFCheckedOutMode.ObjectsCheckedOutThisThread);
69 | count = 0;
70 | }
71 | } catch (Exception) {
72 | // event frames may be locked by users
73 | }
74 | }
75 |
76 | progressBar1.PerformStep();
77 | Application.DoEvents();
78 | }
79 | }
80 | } finally {
81 | this.Enabled = true;
82 | MessageBox.Show("Cleaning finished");
83 | }
84 | }
85 |
86 | private void btnClean_Click(object sender, EventArgs e)
87 | {
88 | if (!ConnectAF())
89 | return;
90 |
91 | CleanEventFrames(dtpStartTime.Value, dtpEndTime.Value, txtTemplate.Text);
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/PIToolkit/AFEventsCleaner/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/PIToolkit/AFEventsCleaner/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace AFEventsCleaner
5 | {
6 | static class Program
7 | {
8 | [STAThread]
9 | static void Main()
10 | {
11 | Application.EnableVisualStyles();
12 | Application.SetCompatibleTextRenderingDefault(false);
13 | Application.Run(new Form1());
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/PIToolkit/AFEventsCleaner/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/PIToolkit/PBToolkitBar/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.InteropServices;
4 | using System.Resources;
5 |
6 | [assembly: AssemblyTitle ("PBToolkitBar")]
7 | [assembly: AssemblyDescription ("")]
8 | [assembly: AssemblyConfiguration ("")]
9 | [assembly: AssemblyCompany ("")]
10 | [assembly: AssemblyProduct ("PBToolkitBar")]
11 | [assembly: AssemblyCopyright ("Copyright © 2018 by Sergey V. Zhdanovskikh")]
12 | [assembly: AssemblyTrademark ("")]
13 | [assembly: AssemblyCulture ("")]
14 | [assembly: ComVisible (false)]
15 | [assembly: Guid ("8200ad1b-4e23-4816-b4bb-30ab03d0b06c")]
16 | [assembly: AssemblyVersion ("0.1.0.0")]
17 | [assembly: AssemblyFileVersion ("0.1.0.0")]
18 | [assembly: NeutralResourcesLanguage ("en")]
19 |
--------------------------------------------------------------------------------
/PIToolkit/PBToolkitBar/PBTKUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using PBObjLib;
3 |
4 | namespace PBToolkitBar
5 | {
6 | public delegate void ProcessSymbolHandler(Symbol sym);
7 |
8 | ///
9 | ///
10 | ///
11 | public static class PBTKUtils
12 | {
13 | public static void ProcessSymbol(Symbol sym, ProcessSymbolHandler handler)
14 | {
15 | try {
16 | if (sym.Type == (int)PBObjLib.pbSYMBOLTYPE.pbSymbolComposite) {
17 |
18 | Composite comp = (Composite)sym;
19 | for (int i = 1; i <= comp.GroupedSymbols.Count; i++) {
20 | Symbol subsym = comp.GroupedSymbols.Item(i);
21 | ProcessSymbol(subsym, handler);
22 | }
23 |
24 | } else {
25 |
26 | handler(sym);
27 |
28 | }
29 | } catch (Exception ex) {
30 | //MessageBox.Show(ex.Message);
31 | }
32 | }
33 |
34 | public static void ProcessSymbols(Symbols syms, ProcessSymbolHandler handler)
35 | {
36 | for (int i = 1; i <= syms.Count; i++) {
37 | try {
38 | Symbol sym = syms.Item(i);
39 | ProcessSymbol(sym, handler);
40 | } catch (Exception ex) {
41 | //MessageBox.Show(ex.Message);
42 | }
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/PIToolkit/PBToolkitBar/PBToolkitBar.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace PBToolkitBar
2 | {
3 | partial class PBToolkitBar
4 | {
5 | private System.ComponentModel.IContainer components = null;
6 | private System.Windows.Forms.Button btnReplace;
7 | private System.Windows.Forms.Button btnBackupMS;
8 | private System.Windows.Forms.Button btnRestoreMS;
9 | private System.Windows.Forms.Button btnReplaceTags;
10 | private System.Windows.Forms.TextBox txtSource;
11 | private System.Windows.Forms.TextBox txtTarget;
12 | private System.Windows.Forms.ComboBox cmbColors;
13 | private System.Windows.Forms.Button btnSetMS;
14 | private System.Windows.Forms.Button btnSetINKProps;
15 | private System.Windows.Forms.Button btnTagsAnalyse;
16 | private System.Windows.Forms.Button btnSetValuesEU;
17 |
18 | protected override void Dispose(bool disposing)
19 | {
20 | if (disposing) {
21 | if (components != null) {
22 | components.Dispose();
23 | }
24 | }
25 | base.Dispose(disposing);
26 | }
27 |
28 | private void InitializeComponent()
29 | {
30 | this.btnReplace = new System.Windows.Forms.Button();
31 | this.btnBackupMS = new System.Windows.Forms.Button();
32 | this.btnRestoreMS = new System.Windows.Forms.Button();
33 | this.btnReplaceTags = new System.Windows.Forms.Button();
34 | this.txtSource = new System.Windows.Forms.TextBox();
35 | this.txtTarget = new System.Windows.Forms.TextBox();
36 | this.cmbColors = new System.Windows.Forms.ComboBox();
37 | this.btnSetMS = new System.Windows.Forms.Button();
38 | this.btnSetINKProps = new System.Windows.Forms.Button();
39 | this.btnTagsAnalyse = new System.Windows.Forms.Button();
40 | this.btnSetValuesEU = new System.Windows.Forms.Button();
41 | this.SuspendLayout();
42 | //
43 | // btnReplace
44 | //
45 | this.btnReplace.Location = new System.Drawing.Point(14, 16);
46 | this.btnReplace.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
47 | this.btnReplace.Name = "btnReplace";
48 | this.btnReplace.Size = new System.Drawing.Size(136, 38);
49 | this.btnReplace.TabIndex = 0;
50 | this.btnReplace.Text = "Replace";
51 | this.btnReplace.UseVisualStyleBackColor = true;
52 | this.btnReplace.Click += new System.EventHandler(this.btnReplace_Click);
53 | //
54 | // btnBackupMS
55 | //
56 | this.btnBackupMS.Location = new System.Drawing.Point(156, 16);
57 | this.btnBackupMS.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
58 | this.btnBackupMS.Name = "btnBackupMS";
59 | this.btnBackupMS.Size = new System.Drawing.Size(136, 38);
60 | this.btnBackupMS.TabIndex = 0;
61 | this.btnBackupMS.Text = "Backup MS";
62 | this.btnBackupMS.UseVisualStyleBackColor = true;
63 | this.btnBackupMS.Click += new System.EventHandler(this.btnBackupMSClick);
64 | //
65 | // btnRestoreMS
66 | //
67 | this.btnRestoreMS.Location = new System.Drawing.Point(298, 16);
68 | this.btnRestoreMS.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
69 | this.btnRestoreMS.Name = "btnRestoreMS";
70 | this.btnRestoreMS.Size = new System.Drawing.Size(136, 38);
71 | this.btnRestoreMS.TabIndex = 0;
72 | this.btnRestoreMS.Text = "Restore MS";
73 | this.btnRestoreMS.UseVisualStyleBackColor = true;
74 | this.btnRestoreMS.Click += new System.EventHandler(this.btnRestoreMSClick);
75 | //
76 | // btnReplaceTags
77 | //
78 | this.btnReplaceTags.Location = new System.Drawing.Point(440, 16);
79 | this.btnReplaceTags.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
80 | this.btnReplaceTags.Name = "btnReplaceTags";
81 | this.btnReplaceTags.Size = new System.Drawing.Size(136, 38);
82 | this.btnReplaceTags.TabIndex = 0;
83 | this.btnReplaceTags.Text = "Replace Tags";
84 | this.btnReplaceTags.UseVisualStyleBackColor = true;
85 | this.btnReplaceTags.Click += new System.EventHandler(this.btnReplaceTagsClick);
86 | //
87 | // txtSource
88 | //
89 | this.txtSource.Location = new System.Drawing.Point(14, 61);
90 | this.txtSource.Name = "txtSource";
91 | this.txtSource.Size = new System.Drawing.Size(278, 28);
92 | this.txtSource.TabIndex = 1;
93 | this.txtSource.Text = "???";
94 | //
95 | // txtTarget
96 | //
97 | this.txtTarget.Location = new System.Drawing.Point(298, 61);
98 | this.txtTarget.Name = "txtTarget";
99 | this.txtTarget.Size = new System.Drawing.Size(278, 28);
100 | this.txtTarget.TabIndex = 1;
101 | //
102 | // cmbColors
103 | //
104 | this.cmbColors.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
105 | this.cmbColors.FormattingEnabled = true;
106 | this.cmbColors.Items.AddRange(new object[] {
107 | "0-Зелен, 1-Красн, 2-Желт, 3-Желт, 4-Красн, 5-Серый, 6-Сирен",
108 | "0-Зелен, 5-Серый",
109 | "0-Зелен, 1-Серый, 2-Желт, 3-Желт, 4-Красн, 5-Серый, 6-Сирен",
110 | "0-Зелен, 1-Желт, 2-Красн, 3-Серый"});
111 | this.cmbColors.Location = new System.Drawing.Point(14, 116);
112 | this.cmbColors.Name = "cmbColors";
113 | this.cmbColors.Size = new System.Drawing.Size(420, 29);
114 | this.cmbColors.TabIndex = 2;
115 | //
116 | // btnSetMS
117 | //
118 | this.btnSetMS.Location = new System.Drawing.Point(440, 110);
119 | this.btnSetMS.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
120 | this.btnSetMS.Name = "btnSetMS";
121 | this.btnSetMS.Size = new System.Drawing.Size(136, 38);
122 | this.btnSetMS.TabIndex = 0;
123 | this.btnSetMS.Text = "Set MS";
124 | this.btnSetMS.UseVisualStyleBackColor = true;
125 | this.btnSetMS.Click += new System.EventHandler(this.BtnSetMSClick);
126 | //
127 | // btnSetINKProps
128 | //
129 | this.btnSetINKProps.Location = new System.Drawing.Point(582, 61);
130 | this.btnSetINKProps.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
131 | this.btnSetINKProps.Name = "btnSetINKProps";
132 | this.btnSetINKProps.Size = new System.Drawing.Size(166, 38);
133 | this.btnSetINKProps.TabIndex = 0;
134 | this.btnSetINKProps.Text = "SetINKProps";
135 | this.btnSetINKProps.UseVisualStyleBackColor = true;
136 | this.btnSetINKProps.Click += new System.EventHandler(this.BtnReplaceTextClick);
137 | //
138 | // btnTagsAnalyse
139 | //
140 | this.btnTagsAnalyse.Location = new System.Drawing.Point(582, 15);
141 | this.btnTagsAnalyse.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
142 | this.btnTagsAnalyse.Name = "btnTagsAnalyse";
143 | this.btnTagsAnalyse.Size = new System.Drawing.Size(136, 38);
144 | this.btnTagsAnalyse.TabIndex = 0;
145 | this.btnTagsAnalyse.Text = "Tags Analyse";
146 | this.btnTagsAnalyse.UseVisualStyleBackColor = true;
147 | this.btnTagsAnalyse.Click += new System.EventHandler(this.btnTagsAnalyse_Click);
148 | //
149 | // btnSetValuesEU
150 | //
151 | this.btnSetValuesEU.Location = new System.Drawing.Point(14, 152);
152 | this.btnSetValuesEU.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
153 | this.btnSetValuesEU.Name = "btnSetValuesEU";
154 | this.btnSetValuesEU.Size = new System.Drawing.Size(136, 38);
155 | this.btnSetValuesEU.TabIndex = 3;
156 | this.btnSetValuesEU.Text = "SetValuesEU";
157 | this.btnSetValuesEU.UseVisualStyleBackColor = true;
158 | this.btnSetValuesEU.Click += new System.EventHandler(this.btnSetValuesEU_Click);
159 | //
160 | // PBToolkitBar
161 | //
162 | this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 21F);
163 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
164 | this.ClientSize = new System.Drawing.Size(760, 203);
165 | this.Controls.Add(this.btnSetValuesEU);
166 | this.Controls.Add(this.cmbColors);
167 | this.Controls.Add(this.txtTarget);
168 | this.Controls.Add(this.txtSource);
169 | this.Controls.Add(this.btnSetMS);
170 | this.Controls.Add(this.btnSetINKProps);
171 | this.Controls.Add(this.btnTagsAnalyse);
172 | this.Controls.Add(this.btnReplaceTags);
173 | this.Controls.Add(this.btnRestoreMS);
174 | this.Controls.Add(this.btnBackupMS);
175 | this.Controls.Add(this.btnReplace);
176 | this.Font = new System.Drawing.Font("Calibri", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
177 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
178 | this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
179 | this.MaximizeBox = false;
180 | this.Name = "PBToolkitBar";
181 | this.Text = "PBToolkitBar";
182 | this.TopMost = true;
183 | this.Load += new System.EventHandler(this.PBToolkitBarLoad);
184 | this.ResumeLayout(false);
185 | this.PerformLayout();
186 |
187 | }
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/PIToolkit/PBToolkitBar/PBToolkitBar.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {BE714B6B-FCC7-4852-BB8A-D7597C05F8BF}
5 | {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
6 | Debug
7 | AnyCPU
8 | WinExe
9 | PBToolkitBar
10 | PBToolkitBar
11 | v4.5.2
12 | Properties
13 |
14 | False
15 |
16 |
17 | x86
18 |
19 |
20 | bin\Debug\
21 | True
22 | Full
23 | False
24 | True
25 | DEBUG;TRACE
26 |
27 |
28 | bin\Release\
29 | False
30 | None
31 | True
32 | False
33 | TRACE
34 |
35 |
36 |
37 | libs\OSIsoft.AF.UI.dll
38 |
39 |
40 | libs\OSIsoft.AFSDK.dll
41 |
42 |
43 | libs\OSIsoft.PBObjLib.dll
44 |
45 |
46 | libs\OSIsoft.PBSymLib.dll
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | Form
59 |
60 |
61 | PBToolkitBar.cs
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | PBToolkitBar.cs
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/PIToolkit/PBToolkitBar/PBToolkitBar.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/PIToolkit/PBToolkitBar/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace PBToolkitBar
5 | {
6 | static class Program
7 | {
8 | [STAThread]
9 | static void Main()
10 | {
11 | Application.EnableVisualStyles();
12 | Application.SetCompatibleTextRenderingDefault(false);
13 | Application.Run(new PBToolkitBar());
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/PIToolkit/PBToolkitBar/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Filters/LowPassFilter.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/PIToolkit/PIBrowser/Filters/LowPassFilter.cs
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Filters/SplineFilter.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * "PIBrowser", the PISystem tags browser.
3 | * Copyright (C) 2007-2017 by Sergey V. Zhdanovskih.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | using System.Collections.Generic;
20 |
21 | namespace PIBrowser.Filters
22 | {
23 | public class SplineFilter
24 | {
25 | private readonly List fData;
26 | private readonly int fSize;
27 |
28 | public SplineFilter(int size)
29 | {
30 | this.fSize = size;
31 | this.fData = new List();
32 | }
33 |
34 | public double Run(double value)
35 | {
36 | if (fData.Count == fSize) {
37 | fData.RemoveAt(0);
38 | }
39 |
40 | fData.Add(value);
41 |
42 | double sum = 0;
43 | for (int k = 0; k < fData.Count; k++) {
44 | sum = sum + fData[k];
45 | }
46 |
47 | int cnt = fData.Count;
48 | double res = (cnt != 0) ? (sum / cnt) : 0;
49 | return res;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Forms/AboutDlg.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace PIBrowser
2 | {
3 | partial class AboutDlg
4 | {
5 | private System.Windows.Forms.Label lblProduct;
6 | private System.Windows.Forms.Label lblVersion;
7 | private System.Windows.Forms.Button btnClose;
8 | private System.Windows.Forms.Label lblCopyright;
9 | private System.Windows.Forms.Label lblMail;
10 | private System.ComponentModel.IContainer components = null;
11 |
12 | protected override void Dispose(bool disposing)
13 | {
14 | if (disposing) {
15 | if (components != null) {
16 | components.Dispose();
17 | }
18 | }
19 | base.Dispose(disposing);
20 | }
21 |
22 | private void InitializeComponent()
23 | {
24 | this.lblProduct = new System.Windows.Forms.Label();
25 | this.lblVersion = new System.Windows.Forms.Label();
26 | this.btnClose = new System.Windows.Forms.Button();
27 | this.lblCopyright = new System.Windows.Forms.Label();
28 | this.lblMail = new System.Windows.Forms.Label();
29 | this.SuspendLayout();
30 | //
31 | // LabelProduct
32 | //
33 | this.lblProduct.AutoSize = true;
34 | this.lblProduct.Font = new System.Drawing.Font("Tahoma", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
35 | this.lblProduct.Location = new System.Drawing.Point(8, 8);
36 | this.lblProduct.Name = "LabelProduct";
37 | this.lblProduct.Size = new System.Drawing.Size(20, 21);
38 | this.lblProduct.TabIndex = 0;
39 | this.lblProduct.Text = "?";
40 | //
41 | // Label3
42 | //
43 | this.lblVersion.AutoSize = true;
44 | this.lblVersion.Location = new System.Drawing.Point(8, 40);
45 | this.lblVersion.Name = "Label3";
46 | this.lblVersion.Size = new System.Drawing.Size(52, 17);
47 | this.lblVersion.TabIndex = 1;
48 | this.lblVersion.Text = "Version";
49 | //
50 | // btnClose
51 | //
52 | this.btnClose.Location = new System.Drawing.Point(279, 109);
53 | this.btnClose.Name = "btnClose";
54 | this.btnClose.Size = new System.Drawing.Size(75, 25);
55 | this.btnClose.TabIndex = 4;
56 | this.btnClose.Text = "Close";
57 | this.btnClose.Click += new System.EventHandler(this.btnCloseClick);
58 | //
59 | // LabelCopyright
60 | //
61 | this.lblCopyright.AutoSize = true;
62 | this.lblCopyright.Location = new System.Drawing.Point(8, 64);
63 | this.lblCopyright.Name = "LabelCopyright";
64 | this.lblCopyright.Size = new System.Drawing.Size(80, 17);
65 | this.lblCopyright.TabIndex = 2;
66 | this.lblCopyright.Text = "Copyright ?";
67 | //
68 | // Label_eMail
69 | //
70 | this.lblMail.AutoSize = true;
71 | this.lblMail.Location = new System.Drawing.Point(8, 88);
72 | this.lblMail.Name = "Label_eMail";
73 | this.lblMail.Size = new System.Drawing.Size(230, 17);
74 | this.lblMail.TabIndex = 3;
75 | this.lblMail.Text = "mailto:serg.zhdanovskih@gmail.com";
76 | this.lblMail.Click += new System.EventHandler(this.Label_eMailClick);
77 | //
78 | // TfmAbout
79 | //
80 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 17F);
81 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
82 | this.ClientSize = new System.Drawing.Size(366, 146);
83 | this.Controls.Add(this.lblProduct);
84 | this.Controls.Add(this.lblVersion);
85 | this.Controls.Add(this.lblCopyright);
86 | this.Controls.Add(this.lblMail);
87 | this.Controls.Add(this.btnClose);
88 | this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
89 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
90 | this.MaximizeBox = false;
91 | this.MinimizeBox = false;
92 | this.Name = "TfmAbout";
93 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
94 | this.Text = "About";
95 | this.ResumeLayout(false);
96 | this.PerformLayout();
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Forms/AboutDlg.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * "PIBrowser", the PISystem tags browser.
3 | * Copyright (C) 2007-2017 by Sergey V. Zhdanovskih.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | using System;
20 | using System.Windows.Forms;
21 |
22 | namespace PIBrowser
23 | {
24 | public partial class AboutDlg : Form
25 | {
26 | public void btnCloseClick(object sender, EventArgs e)
27 | {
28 | base.Close();
29 | }
30 |
31 | public void Label_eMailClick(object sender, EventArgs e)
32 | {
33 | }
34 |
35 | public AboutDlg()
36 | {
37 | InitializeComponent();
38 | }
39 |
40 | public static void AboutDialog()
41 | {
42 | using (var fmAbout = new AboutDlg()) {
43 | fmAbout.lblProduct.Text = "PI Browser";
44 | fmAbout.lblVersion.Text = "Version " + PIBUtils.GetFileVersion();
45 | fmAbout.lblCopyright.Text = "© 2007-2012, 2017 Sergey V. Zhdanovskih";
46 | fmAbout.lblMail.Text = "mailto:serg.zhdanovskih@gmail.com";
47 | fmAbout.ShowDialog();
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Forms/ConnectionDlg.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace PIBrowser
2 | {
3 | partial class ConnectionDlg
4 | {
5 | private System.ComponentModel.IContainer components = null;
6 | public System.Windows.Forms.GroupBox gbCon;
7 | public System.Windows.Forms.Label Label8;
8 | public System.Windows.Forms.Label Label9;
9 | public System.Windows.Forms.Label Label10;
10 | public System.Windows.Forms.TextBox txtUser;
11 | public System.Windows.Forms.MaskedTextBox txtPassword;
12 | public System.Windows.Forms.Button btnCon;
13 | public System.Windows.Forms.Button btnCancel;
14 | public System.Windows.Forms.ComboBox cmbServer;
15 |
16 | protected override void Dispose(bool disposing)
17 | {
18 | if (disposing) {
19 | if (components != null) {
20 | components.Dispose();
21 | }
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | private void InitializeComponent()
27 | {
28 | this.gbCon = new System.Windows.Forms.GroupBox();
29 | this.Label8 = new System.Windows.Forms.Label();
30 | this.Label9 = new System.Windows.Forms.Label();
31 | this.Label10 = new System.Windows.Forms.Label();
32 | this.txtUser = new System.Windows.Forms.TextBox();
33 | this.txtPassword = new System.Windows.Forms.MaskedTextBox();
34 | this.btnCon = new System.Windows.Forms.Button();
35 | this.btnCancel = new System.Windows.Forms.Button();
36 | this.cmbServer = new System.Windows.Forms.ComboBox();
37 | this.gbCon.SuspendLayout();
38 | this.SuspendLayout();
39 | //
40 | // gbCon
41 | //
42 | this.gbCon.Controls.Add(this.Label8);
43 | this.gbCon.Controls.Add(this.Label9);
44 | this.gbCon.Controls.Add(this.Label10);
45 | this.gbCon.Controls.Add(this.txtUser);
46 | this.gbCon.Controls.Add(this.txtPassword);
47 | this.gbCon.Controls.Add(this.btnCon);
48 | this.gbCon.Controls.Add(this.btnCancel);
49 | this.gbCon.Controls.Add(this.cmbServer);
50 | this.gbCon.Dock = System.Windows.Forms.DockStyle.Fill;
51 | this.gbCon.Location = new System.Drawing.Point(0, 0);
52 | this.gbCon.Name = "gbCon";
53 | this.gbCon.Size = new System.Drawing.Size(348, 170);
54 | this.gbCon.TabIndex = 1;
55 | this.gbCon.TabStop = false;
56 | this.gbCon.Text = "Connection";
57 | //
58 | // Label8
59 | //
60 | this.Label8.AutoSize = true;
61 | this.Label8.Location = new System.Drawing.Point(8, 26);
62 | this.Label8.Name = "Label8";
63 | this.Label8.Size = new System.Drawing.Size(69, 17);
64 | this.Label8.TabIndex = 0;
65 | this.Label8.Text = "PI Server:";
66 | //
67 | // Label9
68 | //
69 | this.Label9.AutoSize = true;
70 | this.Label9.Location = new System.Drawing.Point(8, 59);
71 | this.Label9.Name = "Label9";
72 | this.Label9.Size = new System.Drawing.Size(46, 17);
73 | this.Label9.TabIndex = 1;
74 | this.Label9.Text = "Login:";
75 | //
76 | // Label10
77 | //
78 | this.Label10.AutoSize = true;
79 | this.Label10.Location = new System.Drawing.Point(8, 91);
80 | this.Label10.Name = "Label10";
81 | this.Label10.Size = new System.Drawing.Size(71, 17);
82 | this.Label10.TabIndex = 2;
83 | this.Label10.Text = "Password:";
84 | //
85 | // txtUser
86 | //
87 | this.txtUser.Location = new System.Drawing.Point(136, 56);
88 | this.txtUser.Name = "txtUser";
89 | this.txtUser.Size = new System.Drawing.Size(198, 24);
90 | this.txtUser.TabIndex = 3;
91 | this.txtUser.KeyDown += new System.Windows.Forms.KeyEventHandler(this.mePasKeyPress);
92 | //
93 | // txtPassword
94 | //
95 | this.txtPassword.Location = new System.Drawing.Point(136, 88);
96 | this.txtPassword.Name = "txtPassword";
97 | this.txtPassword.PasswordChar = '*';
98 | this.txtPassword.Size = new System.Drawing.Size(198, 24);
99 | this.txtPassword.TabIndex = 4;
100 | this.txtPassword.KeyDown += new System.Windows.Forms.KeyEventHandler(this.mePasKeyPress);
101 | //
102 | // btnCon
103 | //
104 | this.btnCon.Location = new System.Drawing.Point(74, 131);
105 | this.btnCon.Name = "btnCon";
106 | this.btnCon.Size = new System.Drawing.Size(125, 26);
107 | this.btnCon.TabIndex = 5;
108 | this.btnCon.Text = "Connect";
109 | this.btnCon.Click += new System.EventHandler(this.btnConClick);
110 | //
111 | // btnCancel
112 | //
113 | this.btnCancel.Location = new System.Drawing.Point(205, 131);
114 | this.btnCancel.Name = "btnCancel";
115 | this.btnCancel.Size = new System.Drawing.Size(129, 26);
116 | this.btnCancel.TabIndex = 6;
117 | this.btnCancel.Text = "Cancel";
118 | this.btnCancel.Click += new System.EventHandler(this.btnCancelClick);
119 | //
120 | // cmbServer
121 | //
122 | this.cmbServer.Location = new System.Drawing.Point(136, 22);
123 | this.cmbServer.Name = "cmbServer";
124 | this.cmbServer.Size = new System.Drawing.Size(198, 25);
125 | this.cmbServer.TabIndex = 7;
126 | //
127 | // ConnectionDlg
128 | //
129 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 17F);
130 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
131 | this.ClientSize = new System.Drawing.Size(348, 170);
132 | this.Controls.Add(this.gbCon);
133 | this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
134 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
135 | this.MaximizeBox = false;
136 | this.MinimizeBox = false;
137 | this.Name = "ConnectionDlg";
138 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
139 | this.Text = "PI Server Connect";
140 | this.Load += new System.EventHandler(this.FormCreate);
141 | this.Shown += new System.EventHandler(this.FormShow);
142 | this.gbCon.ResumeLayout(false);
143 | this.gbCon.PerformLayout();
144 | this.ResumeLayout(false);
145 |
146 | }
147 | }
148 | }
149 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Forms/ConnectionDlg.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * "PIBrowser", the PISystem tags browser.
3 | * Copyright (C) 2007-2017 by Sergey V. Zhdanovskih.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | using System;
20 | using System.Windows.Forms;
21 |
22 | namespace PIBrowser
23 | {
24 | public partial class ConnectionDlg : Form
25 | {
26 | public void btnConClick(object sender, EventArgs e)
27 | {
28 | if (this.cmbServer.Text != "" && this.txtUser.Text != "" && this.txtPassword.Text != "") {
29 | this.gbCon.Enabled = false;
30 |
31 | try {
32 | PIBrowserWin.Instance.ConServerName = this.cmbServer.Text;
33 | PIBrowserWin.Instance.ConUser = this.txtUser.Text;
34 | PIBrowserWin.Instance.ConPassword = this.txtPassword.Text;
35 |
36 | if (!PIBrowserWin.Instance.Connect()) {
37 | PIBUtils.ShowError("The data entered does not match. Try again");
38 | } else {
39 | if (this.cmbServer.Items.IndexOf(this.cmbServer.Text) == -1) {
40 | this.cmbServer.Items.Insert(0, this.cmbServer.Text);
41 | }
42 | PIBrowserWin.Instance.SaveConnectionSettings();
43 |
44 | base.Hide();
45 | PIBrowserWin.Instance.Timer1.Enabled = false;
46 | PIBrowserWin.Instance.Timer1.Interval = 30000;
47 | PIBrowserWin.Instance.Timer1.Enabled = true;
48 | PIBrowserWin.Instance.Show();
49 | }
50 | } finally {
51 | this.gbCon.Enabled = true;
52 | }
53 | }
54 | }
55 |
56 | public void FormCreate(object sender, EventArgs e)
57 | {
58 | PIBrowserWin.Instance.LoadConnectionSettings();
59 |
60 | this.cmbServer.Text = PIBrowserWin.Instance.ConServerName;
61 | this.txtUser.Text = PIBrowserWin.Instance.ConUser;
62 | }
63 |
64 | public void btnCancelClick(object sender, EventArgs e)
65 | {
66 | base.Close();
67 | }
68 |
69 | public void mePasKeyPress(object sender, KeyEventArgs e)
70 | {
71 | switch (e.KeyCode) {
72 | case Keys.Return:
73 | this.btnConClick(sender, null);
74 | break;
75 |
76 | case Keys.Escape:
77 | base.Close();
78 | break;
79 | }
80 | }
81 |
82 | public void FormShow(object sender, EventArgs e)
83 | {
84 | if (this.cmbServer.Text != "" || this.txtUser.Text != "") {
85 | this.txtPassword.Focus();
86 | }
87 | }
88 |
89 | public ConnectionDlg()
90 | {
91 | InitializeComponent();
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Forms/TrendsOptionsDlg.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * "PIBrowser", the PISystem tags browser.
3 | * Copyright (C) 2007-2017 by Sergey V. Zhdanovskih.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | using System;
20 | using System.Windows.Forms;
21 | using BSLib;
22 | using PIBrowser.Filters;
23 |
24 | namespace PIBrowser
25 | {
26 | public partial class TrendsOptionsDlg : Form
27 | {
28 | private TrendChart fChart;
29 | private FilterOptions fFilterOptions;
30 |
31 | public TrendsOptionsDlg(TrendChart chart)
32 | {
33 | InitializeComponent();
34 |
35 | fChart = chart;
36 |
37 | for (int i = 0; i < 3; i++) {
38 | cmbSuppressionDegree.Items.Add(PIBUtils.Degree[i]);
39 | cmbSubstractionNoiseDegree.Items.Add(PIBUtils.Degree[i]);
40 | }
41 |
42 | for (int i = 0; i < PIBUtils.PostActions.Length; i++) {
43 | rgPrepareMode.AddItem(PIBUtils.PostActions[i]);
44 | }
45 |
46 | for (int i = 0; i < PIBUtils.FilterModes.Length; i++) {
47 | rgFilterMode.AddItem(PIBUtils.FilterModes[i]);
48 | }
49 |
50 | TreeNode parent = TreeView1.Nodes[0];
51 | for (int i = 0; i < fChart.TrendsCount; i++) {
52 | if (!string.IsNullOrEmpty(fChart[i].Name)) {
53 | var node = parent.Nodes.Add(fChart[i].Name);
54 | node.Tag = i;
55 | }
56 | }
57 | parent.Expand();
58 | }
59 |
60 | public void btnApply_Click(object sender, EventArgs e)
61 | {
62 | TreeNode selected = TreeView1.SelectedNode;
63 | if (selected != null) {
64 | int num = (int)selected.Tag;
65 | if (num >= 0 && num < fChart.TrendsCount) {
66 | ApplyTrend(num);
67 | }
68 | }
69 | }
70 |
71 | public void FormKeyDown(object Sender, KeyEventArgs e)
72 | {
73 | switch (e.KeyCode) {
74 | case Keys.Return:
75 | btnApply_Click(null, null);
76 | btnClose_Click(null, null);
77 | break;
78 |
79 | case Keys.Escape:
80 | btnClose_Click(null, null);
81 | break;
82 | }
83 | }
84 |
85 | public void btnClose_Click(object sender, EventArgs e)
86 | {
87 | Close();
88 | }
89 |
90 | public void TreeView1_AfterSelect(object sender, TreeViewEventArgs e)
91 | {
92 | if (e.Node != null && e.Node.Tag != null) {
93 | int num = (int)e.Node.Tag;
94 | if (num >= 0 && num < fChart.TrendsCount) {
95 | ResetTrend(num);
96 | }
97 | }
98 | }
99 |
100 | public void btnReset_Click(object sender, EventArgs e)
101 | {
102 | TreeNode selected = TreeView1.SelectedNode;
103 | if (selected != null) {
104 | int num = (int)selected.Tag;
105 | if (num >= 0 && num < fChart.TrendsCount) {
106 | TrendObj trendObj = fChart[num];
107 | trendObj.ClearSettings();
108 | ResetTrend(num);
109 | fChart.DataUpdated();
110 | }
111 | }
112 | }
113 |
114 | public void rgPrepareMode_SelectedIndexChanged(object sender, EventArgs e)
115 | {
116 | GroupBox3.Enabled = (rgPrepareMode.SelectedIndex == 2);
117 | rgFilterMode.Enabled = GroupBox3.Enabled;
118 | txtBandWidth.Enabled = GroupBox3.Enabled;
119 | chkOvershoot.Enabled = GroupBox3.Enabled;
120 | chkShowSource.Enabled = (rgPrepareMode.SelectedIndex > 0);
121 | }
122 |
123 | public void txtMin_Change(object sender, EventArgs e)
124 | {
125 | chkMin.Checked = false;
126 | }
127 |
128 | public void txtMax_Change(object sender, EventArgs e)
129 | {
130 | chkMax.Checked = false;
131 | }
132 |
133 | public void chkCrossSight_Click(object sender, EventArgs e)
134 | {
135 | fChart.CrossRuler = chkCrossSight.Checked;
136 | fChart.Invalidate();
137 | }
138 |
139 | public void FormShow(object sender, EventArgs e)
140 | {
141 | chkCrossSight.Checked = fChart.CrossRuler;
142 | base.ActiveControl = TreeView1;
143 | if (TreeView1.Nodes[0].Nodes.Count > 0) {
144 | TreeView1.SelectedNode = TreeView1.Nodes[0].Nodes[0];
145 | }
146 | }
147 |
148 | public void chkOvershoot_Click(object sender, EventArgs e)
149 | {
150 | if (chkOvershoot.Checked) {
151 | cmbSuppressionDegree.Enabled = true;
152 | } else {
153 | cmbSuppressionDegree.Enabled = false;
154 | }
155 | }
156 |
157 | public void rgMode_SelectedIndexChanged(object sender, EventArgs e)
158 | {
159 | if (fFilterOptions != null) {
160 | fFilterOptions.Mode = (FilterMode)rgFilterMode.SelectedIndex;
161 | }
162 | UpdateFilterControls();
163 | }
164 |
165 | public void ResetTrend(int trendIndex)
166 | {
167 | TrendObj trendObj = fChart[trendIndex];
168 |
169 | Panel1.Text = "< " + trendObj.Name + " >";
170 | if (trendObj.AutoScaleMin) {
171 | txtMin.Text = string.Format("{0:0.00}", trendObj.Series.ChartMin);
172 | } else {
173 | txtMin.Text = string.Format("{0:0.00}", trendObj.Min);
174 | }
175 | chkMin.Checked = trendObj.AutoScaleMin;
176 | if (trendObj.AutoScaleMax) {
177 | txtMax.Text = string.Format("{0:0.00}", trendObj.Series.ChartMax);
178 | } else {
179 | txtMax.Text = string.Format("{0:0.00}", trendObj.Max);
180 | }
181 | chkMax.Checked = trendObj.AutoScaleMax;
182 | chkVisible.Checked = trendObj.Visible;
183 | rgPrepareMode.SelectedIndex = (int)trendObj.Series.PostAction;
184 | chkShowSource.Checked = trendObj.ShowSource;
185 | fFilterOptions = trendObj.Series.Filter;
186 | rgFilterMode.SelectedIndex = (int)fFilterOptions.Mode;
187 | txtBandWidth.Text = fFilterOptions.BandWidth.ToString();
188 | chkOvershoot.Checked = fFilterOptions.Overshoot;
189 | cmbSuppressionDegree.SelectedIndex = (int)((sbyte)fFilterOptions.SuppressionDegree);
190 | cmbSubstractionNoiseDegree.SelectedIndex = (int)((sbyte)fFilterOptions.SubstractionNoiseDegree);
191 |
192 | UpdateFilterControls();
193 | }
194 |
195 | public void ApplyTrend(int trendIndex)
196 | {
197 | TrendObj trendObj = fChart[trendIndex];
198 |
199 | trendObj.AutoScaleMin = chkMin.Checked;
200 | if (!trendObj.AutoScaleMin) {
201 | trendObj.Min = ConvertHelper.ParseFloat(txtMin.Text, 0);
202 | }
203 | trendObj.AutoScaleMax = chkMax.Checked;
204 | if (!trendObj.AutoScaleMax) {
205 | trendObj.Max = ConvertHelper.ParseFloat(txtMax.Text, 0);
206 | }
207 | trendObj.Visible = chkVisible.Checked;
208 | trendObj.Series.PostAction = (PostAction)rgPrepareMode.SelectedIndex;
209 | trendObj.ShowSource = chkShowSource.Checked;
210 | fFilterOptions.BandWidth = ConvertHelper.ParseFloat(txtBandWidth.Text, 0);
211 | fFilterOptions.Overshoot = chkOvershoot.Checked;
212 | fFilterOptions.SuppressionDegree = (FilterDegree)cmbSuppressionDegree.SelectedIndex;
213 | fFilterOptions.SubstractionNoiseDegree = (FilterDegree)cmbSubstractionNoiseDegree.SelectedIndex;
214 | trendObj.Series.Filter = fFilterOptions;
215 | trendObj.SaveSettings();
216 |
217 | fChart.DataUpdated();
218 | }
219 |
220 | public void UpdateFilterControls()
221 | {
222 | if (fFilterOptions == null)
223 | return;
224 |
225 | switch (fFilterOptions.Mode) {
226 | case FilterMode.mdNoneFiltering:
227 | txtBandWidth.Enabled = false;
228 | cmbSubstractionNoiseDegree.Enabled = false;
229 | break;
230 |
231 | case FilterMode.mdLowPassFilter:
232 | txtBandWidth.Enabled = true;
233 | cmbSubstractionNoiseDegree.Enabled = false;
234 | break;
235 |
236 | case FilterMode.mdSubtractionNoise:
237 | txtBandWidth.Enabled = false;
238 | cmbSubstractionNoiseDegree.Enabled = true;
239 | break;
240 | }
241 |
242 | cmbSuppressionDegree.Enabled = chkOvershoot.Checked;
243 | }
244 | }
245 | }
246 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/PIBDataMath.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * "PIBrowser", the PISystem tags browser.
3 | * Copyright (C) 2007-2017 by Sergey V. Zhdanovskih.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using BSLib;
22 | using PIBrowser.Filters;
23 |
24 | namespace PIBrowser
25 | {
26 | public class FilterOptions
27 | {
28 | public FilterMode Mode;
29 | public double BandWidth;
30 | public bool Overshoot;
31 | public int FrequencyResolution;
32 | public FilterDegree SuppressionDegree;
33 | public FilterDegree SubstractionNoiseDegree;
34 |
35 | public FilterOptions(FilterMode mode, double bandWidth,
36 | bool overshoot, int frequencyResolution,
37 | FilterDegree suppressionDegree,
38 | FilterDegree substractionNoiseDegree)
39 | {
40 | Mode = mode;
41 | BandWidth = bandWidth;
42 | Overshoot = overshoot;
43 | FrequencyResolution = frequencyResolution;
44 | SuppressionDegree = suppressionDegree;
45 | SubstractionNoiseDegree = substractionNoiseDegree;
46 | }
47 | }
48 |
49 | public class TrendPoint
50 | {
51 | public double pTime;
52 | public double pValue;
53 | public double pFilteredValue;
54 | public bool pValid;
55 | }
56 |
57 | public class TrendSeries : BaseObject
58 | {
59 | public static readonly FilterOptions StdFilter = new FilterOptions(
60 | FilterMode.mdLowPassFilter, 0.1, false, 5,
61 | FilterDegree.edSmall, FilterDegree.edSmall);
62 |
63 | private int fCapacity;
64 | private double fChartMin;
65 | private double fChartMax;
66 | private List fData;
67 | private FilterOptions fFilter;
68 | private PostAction fPostAction;
69 | private int fSplineCount;
70 |
71 | public int Capacity
72 | {
73 | get { return fCapacity; }
74 | set { fCapacity = value; }
75 | }
76 |
77 | public double ChartMax
78 | {
79 | get { return fChartMax; }
80 | }
81 |
82 | public double ChartMin
83 | {
84 | get { return fChartMin; }
85 | }
86 |
87 | public int Count
88 | {
89 | get { return fData.Count; }
90 | }
91 |
92 | public FilterOptions Filter
93 | {
94 | get { return fFilter; }
95 | set { fFilter = value; }
96 | }
97 |
98 | public List List
99 | {
100 | get { return fData; }
101 | }
102 |
103 | public TrendPoint this[int index]
104 | {
105 | get {
106 | TrendPoint result;
107 | if (index >= 0 && index < fData.Count) {
108 | result = fData[index];
109 | } else {
110 | result = null;
111 | }
112 | return result;
113 | }
114 | }
115 |
116 | public PostAction PostAction
117 | {
118 | get { return fPostAction; }
119 | set { fPostAction = value; }
120 | }
121 |
122 | public int SplineCount
123 | {
124 | get { return fSplineCount; }
125 | set { fSplineCount = value; }
126 | }
127 |
128 | private void Init()
129 | {
130 | fChartMin = 2147483647.0;
131 | fChartMax = -2147483648.0;
132 | }
133 |
134 | public TrendSeries()
135 | {
136 | fCapacity = 0;
137 | fData = new List();
138 | fSplineCount = 15;
139 | Init();
140 | }
141 |
142 | protected override void Dispose(bool disposing)
143 | {
144 | if (disposing) {
145 | Clear();
146 | fData = null;
147 | }
148 | base.Dispose(disposing);
149 | }
150 |
151 | public void AddValue(double time, double value, bool valid)
152 | {
153 | if (!Double.IsNaN(value)) {
154 | if ((fData.Count > 0) && (fData[fData.Count - 1].pTime >= time)) {
155 | return;
156 | }
157 |
158 | TrendPoint trendPoint = new TrendPoint();
159 | try {
160 | trendPoint.pTime = time;
161 | trendPoint.pValue = value;
162 | trendPoint.pFilteredValue = 0.0;
163 | trendPoint.pValid = valid;
164 | if (value < fChartMin) {
165 | fChartMin = value;
166 | }
167 | if (value > fChartMax) {
168 | fChartMax = value;
169 | }
170 | } catch (Exception ex) {
171 | return;
172 | }
173 | if (fCapacity != 0 && fData.Count == fCapacity) {
174 | fData.RemoveAt(0);
175 | }
176 | fData.Add(trendPoint);
177 | }
178 | }
179 |
180 | public void Clear()
181 | {
182 | fData.Clear();
183 | Init();
184 | }
185 |
186 | public void ApplyFilter()
187 | {
188 | switch (fPostAction) {
189 | case PostAction.paSpline:
190 | {
191 | SplineFilter splineFilter = new SplineFilter(fSplineCount);
192 | for (int i = 0; i < fData.Count; i++) {
193 | TrendPoint trendPt = this[i];
194 | trendPt.pFilteredValue = splineFilter.Run(trendPt.pValue);
195 | }
196 | //splineFilter.Dispose();
197 | }
198 | break;
199 |
200 | case PostAction.paFilter:
201 | {
202 | int count = fData.Count;
203 | if (count != 0) {
204 | LowPassFilter lowPassFilter = new LowPassFilter(count);
205 | try {
206 | for (int i = 0; i < count; i++) {
207 | lowPassFilter.SetInputDataItem(i, this[i].pValue);
208 | }
209 |
210 | lowPassFilter.SetMode(fFilter.Mode);
211 | lowPassFilter.SetBandWidth(fFilter.BandWidth);
212 | lowPassFilter.SetOvershoot(fFilter.Overshoot);
213 | lowPassFilter.SetFrequencyResolution(fFilter.FrequencyResolution);
214 | lowPassFilter.SetSuppressionDegree(fFilter.SuppressionDegree);
215 | lowPassFilter.SetSubstractionNoiseDegree(fFilter.SubstractionNoiseDegree);
216 | lowPassFilter.Execute();
217 |
218 | for (int i = 0; i < count; i++) {
219 | this[i].pFilteredValue = lowPassFilter.GetOutputDataItem(i);
220 | }
221 | } finally {
222 | //lowPassFilter.Dispose();
223 | }
224 | }
225 | }
226 | break;
227 | }
228 | }
229 |
230 | public void Normalize()
231 | {
232 | for (int i = 1; i < fData.Count - 2; i++) {
233 | TrendPoint pt0 = this[i - 1];
234 | TrendPoint pt1 = this[i];
235 | TrendPoint pt2 = this[i + 1];
236 | bool flag = (pt0.pValue < pt1.pValue && pt1.pValue < pt2.pValue) || (pt0.pValue > pt1.pValue && pt1.pValue > pt2.pValue);
237 | if (flag) {
238 | fData.RemoveAt(i);
239 | }
240 | }
241 | }
242 | }
243 | }
244 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/PIBUtils.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * "PIBrowser", the PISystem tags browser.
3 | * Copyright (C) 2007-2017 by Sergey V. Zhdanovskih.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | using System;
20 | using System.Drawing;
21 | using System.IO;
22 | using System.Reflection;
23 | using System.Windows.Forms;
24 | using BSLib;
25 |
26 | namespace PIBrowser
27 | {
28 | public enum PostAction
29 | {
30 | paNone,
31 | paSpline,
32 | paFilter
33 | }
34 |
35 | public enum DataLoadKind
36 | {
37 | dlkByStart,
38 | dlkByTimer
39 | }
40 |
41 | public enum PeriodKind
42 | {
43 | pkSession,
44 | pkDay,
45 | pkWeek
46 | }
47 |
48 | public enum PeriodMove
49 | {
50 | pmPrior,
51 | pmNext
52 | }
53 |
54 | public enum LoadFlags
55 | {
56 | lfNegativeCut = 1,
57 | lfValidity = 2
58 | }
59 |
60 | public enum PIArchiveRetrievalMode
61 | {
62 | armCompressed,
63 | armInterpolated,
64 | armTimeInterpolated
65 | }
66 |
67 | public enum Season
68 | {
69 | snWinter,
70 | snSummer
71 | }
72 |
73 | public static class PIBUtils
74 | {
75 | public static string[] Degree;
76 | public static string[] PostActions;
77 | public static string[] FilterModes;
78 | public static string[] PeriodKinds;
79 |
80 | public const string AppName = "PIBrowser";
81 |
82 | public static readonly _PIvaluetype[] PIFloatTypes = new _PIvaluetype[] {
83 | _PIvaluetype.PI_Type_float16, _PIvaluetype.PI_Type_float32,
84 | _PIvaluetype.PI_Type_float64
85 | };
86 |
87 | public static readonly _PIvaluetype[] PIIntTypes = new _PIvaluetype[] {
88 | _PIvaluetype.PI_Type_uint8, _PIvaluetype.PI_Type_int8,
89 | _PIvaluetype.PI_Type_uint16, _PIvaluetype.PI_Type_int16,
90 | _PIvaluetype.PI_Type_uint32, _PIvaluetype.PI_Type_int32,
91 | _PIvaluetype.PI_Type_uint64, _PIvaluetype.PI_Type_int64
92 | };
93 |
94 | private static string[] MonthsNames;
95 | private static PIArchiveRetrievalMode ArchiveRetrievalMode;
96 |
97 | static PIBUtils()
98 | {
99 | PIBUtils.Degree = new string[] {
100 | "small",
101 | "medium",
102 | "large"
103 | };
104 |
105 | PIBUtils.PostActions = new string[] {
106 | "None",
107 | "Spline",
108 | "Filter"
109 | };
110 |
111 | PIBUtils.FilterModes = new string[] {
112 | "None",
113 | "LowPassFilter",
114 | "SubtractionNoise"
115 | };
116 |
117 | PIBUtils.PeriodKinds = new string[] {
118 | "Session",
119 | "Day",
120 | "Week"
121 | };
122 |
123 | MonthsNames = new string[] {
124 | "jan",
125 | "feb",
126 | "mar",
127 | "apr",
128 | "may",
129 | "jun",
130 | "jul",
131 | "aug",
132 | "sep",
133 | "oct",
134 | "nov",
135 | "dec"
136 | };
137 |
138 | PIBUtils.ArchiveRetrievalMode = PIArchiveRetrievalMode.armInterpolated;
139 | }
140 |
141 |
142 | public static int piServerConnectEx(string serverName, string userName, string password, ref int valid)
143 | {
144 | int num = PIAPI32.piut_setservernode(serverName);
145 | if (num == 0) {
146 | num = PIAPI32.piut_login(userName, password, out valid);
147 | }
148 | return num;
149 | }
150 |
151 | public static bool piServerConnect(string serverName, string userName, string password)
152 | {
153 | int num = -1;
154 | return PIBUtils.piServerConnectEx(serverName, userName, password, ref num) == 0 && num == 2;
155 | }
156 |
157 | private static readonly DateTime UNIX_DATE = new DateTime(1970, 1, 1, 0, 0, 0, 0);
158 |
159 | public static double ToUnixTimeStamp(DateTime dtime)
160 | {
161 | return (dtime - UNIX_DATE.ToLocalTime()).TotalSeconds;
162 | }
163 |
164 | public static DateTime FromUnixTimeStamp(double unixTimeStamp)
165 | {
166 | return UNIX_DATE.AddSeconds(unixTimeStamp).ToLocalTime();
167 | }
168 |
169 | //private const uint PI_TimeDiff = 2209161600;
170 |
171 | public static int TimeToPITime(DateTime DTime)
172 | {
173 | /*if (DTime < 1)
174 | {
175 | DTime = DateTime.TheDate() + DTime;
176 | }
177 | return (int)(Math.Truncate(DTime * 86400) - (long)((ulong)-2085805696));*/
178 | return (int)ToUnixTimeStamp(DTime);
179 | }
180 |
181 | public static DateTime PITimeToTime(int PITime)
182 | {
183 | //long num = (long)PITime + PI_TimeDiff;
184 | //return DateTime.FromOADate();;
185 | return FromUnixTimeStamp(PITime);
186 | }
187 |
188 | public static Season GetDaylightOffset(DateTime dt)
189 | {
190 | /*DateTime DMarch = EncodeDayOfWeekInMonth(dt.Year, 4, 1, 7) - 7 + PIBUtils.StrToTime("3:00:00");
191 | DateTime DOktober = EncodeDayOfWeekInMonth(dt.Year, 11, 1, 7) - 7 + PIBUtils.StrToTime("2:00:00");
192 | TSeason result;
193 | if (dt >= DMarch && dt < DOktober)
194 | {
195 | result = TSeason.snSummer;
196 | }
197 | else
198 | {
199 | result = TSeason.snWinter;
200 | }*/
201 | Season result = Season.snSummer;
202 | return result;
203 | }
204 |
205 | /* x hours */
206 | public static double GetOffset(Season now_sn, Season pt_sn)
207 | {
208 | double result = 0.0;
209 | if (pt_sn != now_sn) {
210 | if (now_sn == Season.snWinter && pt_sn == Season.snSummer) {
211 | result = 1.0;
212 | } else if (now_sn == Season.snSummer && pt_sn == Season.snWinter) {
213 | result = -1.0;
214 | }
215 | }
216 | return result;
217 | }
218 |
219 | public static void piLoadTrend(TrendSeries trend, string tagName,
220 | LoadFlags flags, DateTime aBeg, DateTime aEnd,
221 | out float zero, out float span, int interval = 10, bool autoRange = false)
222 | {
223 | DateTime dtNow = DateTime.Now;
224 | Season daylightOffset = PIBUtils.GetDaylightOffset(dtNow);
225 |
226 | aBeg.AddHours(-PIBUtils.GetOffset(daylightOffset, PIBUtils.GetDaylightOffset(aBeg)));
227 | aEnd.AddHours(-PIBUtils.GetOffset(daylightOffset, PIBUtils.GetDaylightOffset(aEnd)));
228 |
229 | int tagNum;
230 | int res = PIAPI32.pipt_findpointex(tagName, out tagNum);
231 |
232 | if (autoRange) {
233 | TimeSpan ts = (aEnd - aBeg);
234 | double d = ts.TotalHours;
235 | if (d >= 24 * 7) {
236 | interval *= 9;
237 | } else if (d >= 24) {
238 | interval *= 3;
239 | } else if (d >= 12) {
240 | interval *= 2;
241 | }
242 | }
243 |
244 | if (res == 0) {
245 | _PIvaluetype elem;
246 | PIAPI32.pipt_pointtypex(tagNum, out elem);
247 | PIAPI32.pipt_scale(tagNum, out zero, out span);
248 |
249 | DateTime tm = aBeg;
250 | int cnt = 0;
251 | while (tm <= aEnd && (tm <= dtNow)) {
252 | cnt++;
253 | tm = tm.AddSeconds(interval);
254 | }
255 |
256 | try {
257 | float[] rvals = new float[cnt * 4];
258 | int[] times = new int[cnt * 4];
259 | int[] istats = new int[cnt * 4];
260 | try {
261 | tm = aBeg;
262 | cnt = 0;
263 | while (tm <= aEnd && tm <= dtNow) {
264 | int timedate = PIBUtils.TimeToPITime(tm);
265 | times[cnt] = timedate;
266 | cnt++;
267 | tm = tm.AddSeconds(interval);
268 | }
269 |
270 | if (cnt != 0) {
271 | switch (PIBUtils.ArchiveRetrievalMode) {
272 | case PIArchiveRetrievalMode.armTimeInterpolated:
273 | res = PIAPI32.piar_timedvaluesex(tagNum, ref cnt, ref times, out rvals, out istats, 0);
274 | break;
275 |
276 | case PIArchiveRetrievalMode.armInterpolated:
277 | res = PIAPI32.piar_interpvaluesex(tagNum, ref cnt, ref times, out rvals, out istats);
278 | break;
279 |
280 | case PIArchiveRetrievalMode.armCompressed:
281 | res = PIAPI32.piar_compvaluesex(tagNum, ref cnt, ref times, out rvals, out istats, 0);
282 | break;
283 | }
284 |
285 | if (res == 0) {
286 | for (int i = 0; i < cnt; i++) {
287 | double rval = (double)rvals[i];
288 | DateTime dtx = PIBUtils.PITimeToTime(times[i]);
289 | dtx.AddHours(+PIBUtils.GetOffset(daylightOffset, PIBUtils.GetDaylightOffset(dtx)));
290 | int num14 = istats[i];
291 |
292 | if (Array.IndexOf(PIBUtils.PIFloatTypes, elem) >= 0) {
293 | bool valid = true;
294 | if (num14 != 0) {
295 | if ((flags & LoadFlags.lfValidity) == (LoadFlags)0) {
296 | continue;
297 | }
298 | valid = false;
299 | }
300 | if ((flags & LoadFlags.lfNegativeCut) != (LoadFlags)0 && rval < 0.0) {
301 | rval = 0.0;
302 | }
303 | trend.AddValue(dtx.ToOADate(), rval, valid);
304 | } else if (Array.IndexOf(PIBUtils.PIIntTypes, elem) >= 0) {
305 | rval = (double)num14;
306 | trend.AddValue(dtx.ToOADate(), rval, true);
307 | }
308 | }
309 | }
310 | }
311 | } finally {
312 | }
313 | } catch (Exception ex) {
314 | PIBUtils.ShowError("Error type #44: " + ex.Message);
315 | }
316 | } else {
317 | zero = 0;
318 | span = 0;
319 | }
320 | }
321 |
322 | public static string GetFileVersion()
323 | {
324 | return "";
325 | }
326 |
327 | public static string GetAppPath()
328 | {
329 | Module[] mods = Assembly.GetExecutingAssembly().GetModules();
330 | string fn = mods[0].FullyQualifiedName;
331 | return Path.GetDirectoryName(fn) + Path.DirectorySeparatorChar;
332 | }
333 |
334 | public static string GetIniFile()
335 | {
336 | return GetAppPath() + "PIBrowser.ini";
337 | }
338 |
339 | public static void ShowMessage(string msg)
340 | {
341 | MessageBox.Show(msg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
342 | }
343 |
344 | public static void ShowError(string msg)
345 | {
346 | MessageBox.Show(msg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
347 | }
348 |
349 | public static bool ShowQuestionYN(string msg)
350 | {
351 | return MessageBox.Show(msg, AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
352 | }
353 |
354 | public static void ShowWarning(string msg)
355 | {
356 | MessageBox.Show(msg, AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
357 | }
358 |
359 | public static DateTime StrToTime(string xtime)
360 | {
361 | return DateTime.ParseExact(xtime, "HH:mm:ss", null);
362 | }
363 |
364 | private static double FInt(double value)
365 | {
366 | return ((value > (double)0f) ? Math.Floor(value) : Math.Ceiling(value));
367 | }
368 |
369 | private static double Frac(double value)
370 | {
371 | return (value - FInt(value));
372 | }
373 |
374 | public static int GetSession(DateTime aDate)
375 | {
376 | double num = Frac(aDate.ToOADate());
377 | int result;
378 | if (num > 0.333333333333333 && num <= 0.833333333333333) {
379 | result = 2;
380 | } else {
381 | result = 1;
382 | }
383 | return result;
384 | }
385 |
386 | public static void SessionRangeGen(DateTime sdt, int session,
387 | ref DateTime rangeBeg, ref DateTime rangeEnd,
388 | bool direct)
389 | {
390 | sdt = sdt.Date;
391 | if (session == -1) {
392 | if (direct) {
393 | rangeBeg = sdt.AddTicks(StrToTime("00:00:01").TimeOfDay.Ticks);
394 | rangeEnd = sdt.AddTicks(StrToTime("23:59:59").TimeOfDay.Ticks);
395 | } else {
396 | rangeBeg = sdt.AddDays(-1).AddTicks(StrToTime("20:00:01").TimeOfDay.Ticks);
397 | rangeEnd = sdt.AddDays(+0).AddTicks(StrToTime("19:59:59").TimeOfDay.Ticks);
398 | }
399 | } else if (session != 1) {
400 | if (session == 2) {
401 | rangeBeg = sdt.AddTicks(StrToTime("08:00:01").TimeOfDay.Ticks);
402 | rangeEnd = sdt.AddTicks(StrToTime("19:59:59").TimeOfDay.Ticks);
403 | }
404 | } else {
405 | rangeBeg = sdt.AddDays(-1).AddTicks(StrToTime("20:00:01").TimeOfDay.Ticks);
406 | rangeEnd = sdt.AddDays(0).AddTicks(StrToTime("07:59:59").TimeOfDay.Ticks);
407 | }
408 | }
409 |
410 | public static ListViewItem GetSelectedItem(ListView listView)
411 | {
412 | ListViewItem result;
413 |
414 | if (listView.SelectedItems.Count <= 0) {
415 | result = null;
416 | } else {
417 | result = (listView.SelectedItems[0] as ListViewItem);
418 | }
419 |
420 | return result;
421 | }
422 |
423 | public static ListViewItem FindCaption(ListView listView, string text)
424 | {
425 | return null;
426 | }
427 |
428 | public static void SelectItem(ListView listView, ListViewItem item)
429 | {
430 | if (item == null)
431 | return;
432 |
433 | listView.SelectedIndices.Clear();
434 | item.Selected = true;
435 | item.EnsureVisible();
436 | }
437 |
438 | public static Image LoadResourceImage(Assembly assembly, string resourceName)
439 | {
440 | using (Stream stm = assembly.GetManifestResourceStream(resourceName)) {
441 | return Bitmap.FromStream(stm);
442 | }
443 | }
444 | }
445 | }
446 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/PIBrowser.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {C6B8E368-7807-440A-9A48-03B3A89C5878}
5 | {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
6 | Debug
7 | AnyCPU
8 | WinExe
9 | PIBrowser
10 | PIBrowser
11 | v4.5.2
12 | Properties
13 |
14 | False
15 | False
16 | False
17 | OnBuildSuccess
18 | True
19 | False
20 | False
21 | obj\$(Configuration)\
22 | 4
23 |
24 |
25 | x86
26 | 4194304
27 | False
28 | Auto
29 | 4096
30 |
31 |
32 | bin\Debug\
33 | True
34 | Full
35 | False
36 | True
37 | DEBUG;TRACE
38 | obj\
39 |
40 |
41 | bin\Release\
42 | False
43 | None
44 | True
45 | False
46 | TRACE
47 |
48 |
49 |
50 | libs\BSLib.dll
51 |
52 |
53 | libs\BSLib.Controls.dll
54 |
55 |
56 | libs\x86\piapi32.dll
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | libs\ZedGraph.dll
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | AboutDlg.cs
73 |
74 |
75 |
76 | ConnectionDlg.cs
77 |
78 |
79 |
80 | PIBrowserWin.cs
81 |
82 |
83 |
84 | TrendsOptionsDlg.cs
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Program.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * "PIBrowser", the PISystem tags browser.
3 | * Copyright (C) 2007-2017 by Sergey V. Zhdanovskih.
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | using System;
20 | using System.Reflection;
21 | using System.Runtime.InteropServices;
22 | using System.Windows.Forms;
23 |
24 | [assembly: AssemblyTitle("PIBrowser")]
25 | [assembly: AssemblyDescription("")]
26 | [assembly: AssemblyConfiguration("")]
27 | [assembly: AssemblyCompany("")]
28 | [assembly: AssemblyProduct("PIBrowser")]
29 | [assembly: AssemblyCopyright("Copyright © 2007-2012,2017 Sergey V. Zhdanovskih")]
30 | [assembly: AssemblyTrademark("")]
31 | [assembly: AssemblyCulture("")]
32 | [assembly: ComVisible(false)]
33 | [assembly: AssemblyVersion("2.0.0.0")]
34 |
35 | namespace PIBrowser
36 | {
37 | internal sealed class Program
38 | {
39 | [STAThread]
40 | private static void Main(string[] args)
41 | {
42 | Application.EnableVisualStyles();
43 | Application.SetCompatibleTextRenderingDefault(false);
44 | Application.Run(new PIBrowserWin());
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Resources/about.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/PIToolkit/PIBrowser/Resources/about.gif
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Resources/clock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/PIToolkit/PIBrowser/Resources/clock.png
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Resources/configure.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/PIToolkit/PIBrowser/Resources/configure.gif
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Resources/delete.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/PIToolkit/PIBrowser/Resources/delete.gif
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Resources/load.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/PIToolkit/PIBrowser/Resources/load.gif
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Resources/options.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/PIToolkit/PIBrowser/Resources/options.gif
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Resources/print.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/PIToolkit/PIBrowser/Resources/print.gif
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Resources/save.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/PIToolkit/PIBrowser/Resources/save.gif
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/Resources/taggr.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/PIToolkit/PIBrowser/Resources/taggr.gif
--------------------------------------------------------------------------------
/PIToolkit/PIBrowser/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowserTests/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("PIBrowserTests")]
6 | [assembly: AssemblyDescription("")]
7 | [assembly: AssemblyConfiguration("")]
8 | [assembly: AssemblyCompany("")]
9 | [assembly: AssemblyProduct("PIBrowserTests")]
10 | [assembly: AssemblyCopyright("Copyright © 2017 Sergey V. Zhdanovskih")]
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: ComVisible(false)]
14 | [assembly: AssemblyVersion("1.0.*")]
15 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowserTests/PIAPI32Tests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using NUnit.Framework;
4 | using PIBrowser;
5 |
6 | namespace PIBrowserTests
7 | {
8 | [TestFixture]
9 | public class PIAPI32Tests
10 | {
11 | [Test]
12 | public void Test_piServerConnectEx()
13 | {
14 | int valid = 0;
15 | int res = PIBUtils.piServerConnectEx("WIN-ESHVLOLGNK8", "piadmin", "piadmin", ref valid);
16 | Assert.AreEqual(0, res);
17 | Assert.AreEqual(2, valid);
18 | }
19 |
20 | [Test]
21 | public void Test_piServerConnect()
22 | {
23 | bool res = PIBUtils.piServerConnect("WIN-ESHVLOLGNK8", "piadmin", "piadmin");
24 | Assert.AreEqual(true, res);
25 | }
26 |
27 | [Test]
28 | public void Test_piGetTagID_Success()
29 | {
30 | int ptNum;
31 | int res = PIAPI32.pipt_findpointex("sinusoid", out ptNum);
32 | Assert.AreEqual(0, res);
33 | Assert.AreEqual(1, ptNum);
34 | }
35 |
36 | [Test]
37 | public void Test_piGetTagID_Fail()
38 | {
39 | int ptNum;
40 | int res = PIAPI32.pipt_findpointex("sinus123", out ptNum);
41 | Assert.AreEqual(-5, res);
42 | }
43 |
44 | [Test]
45 | public void Test_piGetTagDesc()
46 | {
47 | string desc;
48 | int res = PIAPI32.pipt_descriptorex(1, out desc);
49 | Assert.AreEqual(0, res);
50 | Assert.AreEqual("12 Hour Sine Wave", desc);
51 | }
52 |
53 | [Test]
54 | public void Test_piLoadTrend()
55 | {
56 | bool res = PIBUtils.piServerConnect("WIN-ESHVLOLGNK8", "piadmin", "piadmin");
57 | Assert.AreEqual(true, res);
58 |
59 | TrendSeries trendSeries = new TrendSeries();
60 | float zero, span;
61 | PIBUtils.piLoadTrend(trendSeries, "sinusoid", LoadFlags.lfNegativeCut | LoadFlags.lfValidity,
62 | DateTime.Parse("09.12.2017 00:00:00"), DateTime.Parse("10.12.2017 00:00:00"), out zero, out span);
63 | //string res = piUtils.piGetTagDesc(1);
64 | //Assert.AreEqual("12 Hour Sine Wave", res);
65 | }
66 |
67 | [Test]
68 | public void Test_Times()
69 | {
70 | var xtime = DateTime.Parse("09.12.2017 00:00:00");
71 | int pitime = PIBUtils.TimeToPITime(xtime);
72 | var newTime = PIBUtils.PITimeToTime(pitime);
73 | Assert.AreEqual(xtime, newTime);
74 | }
75 |
76 | }
77 | }
--------------------------------------------------------------------------------
/PIToolkit/PIBrowserTests/PIBTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using NUnit.Framework;
4 | using BSLib;
5 | using PIBrowser;
6 | using PIBrowser.Filters;
7 |
8 | namespace PIBrowserTests
9 | {
10 | [TestFixture]
11 | public class PIBTests
12 | {
13 | [Test]
14 | public void Test_Times()
15 | {
16 |
17 | }
18 |
19 | [Test]
20 | public void Test_LowPassFilter()
21 | {
22 | var filter = new LowPassFilter(3);
23 | Assert.IsNotNull(filter);
24 | }
25 |
26 | [Test]
27 | public void Test_SplineFilter()
28 | {
29 | var filter = new SplineFilter(3);
30 | Assert.IsNotNull(filter);
31 |
32 | Assert.AreEqual(3.0, filter.Run(3.0));
33 | Assert.AreEqual(2.0, filter.Run(1.0));
34 | Assert.IsTrue(DoubleHelper.Equals(4.66666, filter.Run(10.0)));
35 | Assert.IsTrue(DoubleHelper.Equals(4.33333, filter.Run(2.0)));
36 | }
37 |
38 | [Test]
39 | public void Test_TrendObj()
40 | {
41 | var filter = new TrendObj();
42 | Assert.IsNotNull(filter);
43 | }
44 |
45 | [Test]
46 | public void Test_TrendSeries()
47 | {
48 | var filter = new TrendSeries();
49 | Assert.IsNotNull(filter);
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/PIToolkit/PIBrowserTests/PIBrowserTests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {B45CA2DF-3F5E-4765-AEBF-4C2C0D4DAF04}
5 | {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
6 | Debug
7 | AnyCPU
8 | Library
9 | PIBrowserTests
10 | PIBrowserTests
11 | v4.5.2
12 | Properties
13 |
14 |
15 |
16 | AnyCPU
17 |
18 |
19 | bin\Debug\
20 | True
21 | Full
22 | False
23 | True
24 | DEBUG;TRACE
25 |
26 |
27 | bin\Release\
28 | False
29 | None
30 | True
31 | False
32 | TRACE
33 |
34 |
35 |
36 | ..\PIBrowser\libs\BSLib.dll
37 |
38 |
39 | nunit.framework.dll
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | {C6B8E368-7807-440A-9A48-03B3A89C5878}
51 | PIBrowser
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/PIToolkit/PITagsCleaner/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("PITagsCleaner")]
6 | [assembly: AssemblyDescription("")]
7 | [assembly: AssemblyConfiguration("")]
8 | [assembly: AssemblyCompany("")]
9 | [assembly: AssemblyProduct("PITagsCleaner")]
10 | [assembly: AssemblyCopyright("Copyright © 2012 Sergey V. Zhdanovskih")]
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: ComVisible(false)]
14 | [assembly: AssemblyVersion("1.0.0.0")]
15 |
--------------------------------------------------------------------------------
/PIToolkit/PITagsCleaner/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace PITagsCleaner
2 | {
3 | partial class MainForm
4 | {
5 | ///
6 | /// Designer variable used to keep track of non-visual components.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Disposes resources used by the form.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing) {
17 | if (components != null) {
18 | components.Dispose();
19 | }
20 | }
21 | base.Dispose(disposing);
22 | }
23 |
24 | ///
25 | /// This method is required for Windows Forms designer support.
26 | /// Do not change the method contents inside the source code editor. The Forms designer might
27 | /// not be able to load this method if it was changed manually.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.btnTagsView = new System.Windows.Forms.Button();
32 | this.ProgressBar = new System.Windows.Forms.ProgressBar();
33 | this.lbTags = new System.Windows.Forms.ListBox();
34 | this.tbFilter = new System.Windows.Forms.TextBox();
35 | this.label1 = new System.Windows.Forms.Label();
36 | this.label2 = new System.Windows.Forms.Label();
37 | this.label3 = new System.Windows.Forms.Label();
38 | this.dtpStart = new System.Windows.Forms.DateTimePicker();
39 | this.dtpFinish = new System.Windows.Forms.DateTimePicker();
40 | this.btnClear = new System.Windows.Forms.Button();
41 | this.textBox1 = new System.Windows.Forms.TextBox();
42 | this.SuspendLayout();
43 | //
44 | // btnTagsView
45 | //
46 | this.btnTagsView.Location = new System.Drawing.Point(348, 9);
47 | this.btnTagsView.Name = "btnTagsView";
48 | this.btnTagsView.Size = new System.Drawing.Size(75, 23);
49 | this.btnTagsView.TabIndex = 0;
50 | this.btnTagsView.Text = "View";
51 | this.btnTagsView.UseVisualStyleBackColor = true;
52 | this.btnTagsView.Click += new System.EventHandler(this.btnTagsView_Click);
53 | //
54 | // ProgressBar
55 | //
56 | this.ProgressBar.Location = new System.Drawing.Point(12, 367);
57 | this.ProgressBar.Name = "ProgressBar";
58 | this.ProgressBar.Size = new System.Drawing.Size(619, 31);
59 | this.ProgressBar.Step = 1;
60 | this.ProgressBar.TabIndex = 2;
61 | //
62 | // lbTags
63 | //
64 | this.lbTags.FormattingEnabled = true;
65 | this.lbTags.ItemHeight = 16;
66 | this.lbTags.Location = new System.Drawing.Point(12, 37);
67 | this.lbTags.Name = "lbTags";
68 | this.lbTags.Size = new System.Drawing.Size(411, 324);
69 | this.lbTags.TabIndex = 3;
70 | //
71 | // tbFilter
72 | //
73 | this.tbFilter.Location = new System.Drawing.Point(118, 9);
74 | this.tbFilter.Name = "tbFilter";
75 | this.tbFilter.Size = new System.Drawing.Size(224, 22);
76 | this.tbFilter.TabIndex = 4;
77 | this.tbFilter.Text = "*";
78 | //
79 | // label1
80 | //
81 | this.label1.Location = new System.Drawing.Point(12, 9);
82 | this.label1.Name = "label1";
83 | this.label1.Size = new System.Drawing.Size(100, 23);
84 | this.label1.TabIndex = 5;
85 | this.label1.Text = "Фильтр тэгов";
86 | //
87 | // label2
88 | //
89 | this.label2.Location = new System.Drawing.Point(440, 166);
90 | this.label2.Name = "label2";
91 | this.label2.Size = new System.Drawing.Size(143, 23);
92 | this.label2.TabIndex = 6;
93 | this.label2.Text = "Дата/время начала";
94 | //
95 | // label3
96 | //
97 | this.label3.Location = new System.Drawing.Point(440, 235);
98 | this.label3.Name = "label3";
99 | this.label3.Size = new System.Drawing.Size(149, 23);
100 | this.label3.TabIndex = 7;
101 | this.label3.Text = "Дата/время конца";
102 | //
103 | // dtpStart
104 | //
105 | this.dtpStart.CustomFormat = "dd/MM/yyyy HH:mm:ss";
106 | this.dtpStart.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
107 | this.dtpStart.Location = new System.Drawing.Point(440, 196);
108 | this.dtpStart.Name = "dtpStart";
109 | this.dtpStart.Size = new System.Drawing.Size(191, 22);
110 | this.dtpStart.TabIndex = 8;
111 | //
112 | // dtpFinish
113 | //
114 | this.dtpFinish.CustomFormat = "dd/MM/yyyy HH:mm:ss";
115 | this.dtpFinish.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
116 | this.dtpFinish.Location = new System.Drawing.Point(440, 265);
117 | this.dtpFinish.Name = "dtpFinish";
118 | this.dtpFinish.Size = new System.Drawing.Size(191, 22);
119 | this.dtpFinish.TabIndex = 9;
120 | //
121 | // btnClear
122 | //
123 | this.btnClear.Location = new System.Drawing.Point(440, 333);
124 | this.btnClear.Name = "btnClear";
125 | this.btnClear.Size = new System.Drawing.Size(191, 28);
126 | this.btnClear.TabIndex = 10;
127 | this.btnClear.Text = "Очистить тэги";
128 | this.btnClear.UseVisualStyleBackColor = true;
129 | this.btnClear.Click += new System.EventHandler(this.btnClear_Click);
130 | //
131 | // textBox1
132 | //
133 | this.textBox1.Location = new System.Drawing.Point(13, 409);
134 | this.textBox1.Multiline = true;
135 | this.textBox1.Name = "textBox1";
136 | this.textBox1.Size = new System.Drawing.Size(617, 145);
137 | this.textBox1.TabIndex = 11;
138 | //
139 | // MainForm
140 | //
141 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
142 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
143 | this.ClientSize = new System.Drawing.Size(645, 564);
144 | this.Controls.Add(this.textBox1);
145 | this.Controls.Add(this.btnClear);
146 | this.Controls.Add(this.dtpFinish);
147 | this.Controls.Add(this.dtpStart);
148 | this.Controls.Add(this.label3);
149 | this.Controls.Add(this.label2);
150 | this.Controls.Add(this.label1);
151 | this.Controls.Add(this.tbFilter);
152 | this.Controls.Add(this.lbTags);
153 | this.Controls.Add(this.ProgressBar);
154 | this.Controls.Add(this.btnTagsView);
155 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
156 | this.MaximizeBox = false;
157 | this.Name = "MainForm";
158 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
159 | this.Text = "PITagsCleaner";
160 | this.ResumeLayout(false);
161 | this.PerformLayout();
162 | }
163 | private System.Windows.Forms.TextBox textBox1;
164 | private System.Windows.Forms.Button btnClear;
165 | private System.Windows.Forms.DateTimePicker dtpFinish;
166 | private System.Windows.Forms.DateTimePicker dtpStart;
167 | private System.Windows.Forms.Label label3;
168 | private System.Windows.Forms.Label label2;
169 | private System.Windows.Forms.Label label1;
170 | private System.Windows.Forms.TextBox tbFilter;
171 | private System.Windows.Forms.ListBox lbTags;
172 | private System.Windows.Forms.ProgressBar ProgressBar;
173 | private System.Windows.Forms.Button btnTagsView;
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/PIToolkit/PITagsCleaner/MainForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 | using PISDK;
4 |
5 | namespace PITagsCleaner
6 | {
7 | public partial class MainForm : Form
8 | {
9 | private PISDK.PISDK pisdk;
10 | private PISDK.Server pisrv;
11 | private PISDK.PointList ptList;
12 |
13 | public MainForm()
14 | {
15 | InitializeComponent();
16 | pisdk = new PISDK.PISDK();
17 | pisrv = pisdk.Servers.DefaultServer;
18 | pisrv.Open();
19 | }
20 |
21 | void btnTagsView_Click(object sender, EventArgs e)
22 | {
23 | ptList = pisrv.GetPoints("tag='" + tbFilter.Text + "'");
24 |
25 | ProgressBar.Minimum = 0;
26 | ProgressBar.Maximum = ptList.Count;
27 | ProgressBar.Value = 0;
28 |
29 | lbTags.Items.Clear();
30 | foreach (PIPoint p in ptList) {
31 | lbTags.Items.Add(p.Name);
32 | ProgressBar.Increment(1);
33 | }
34 |
35 | ProgressBar.Value = 0;
36 | }
37 |
38 | void btnClear_Click(object sender, EventArgs e)
39 | {
40 | ptList = pisrv.GetPoints("tag='" + tbFilter.Text + "'");
41 |
42 | ProgressBar.Minimum = 0;
43 | ProgressBar.Maximum = ptList.Count;
44 | ProgressBar.Value = 0;
45 |
46 | int i = 0;
47 |
48 | lbTags.Items.Clear();
49 | foreach (PIPoint p in ptList) {
50 | i++;
51 | this.Text = i.ToString() + " / " + ptList.Count.ToString();
52 |
53 | lbTags.Items.Add(p.Name);
54 |
55 | try {
56 | p.Data.RemoveValues(dtpStart.Value, dtpFinish.Value, DataRemovalConstants.drRemoveAll);
57 | } catch (Exception ex) {
58 | textBox1.AppendText(ex.Message.ToString() + " [" + p.Name + ", " + i.ToString() + "]\n");
59 | }
60 |
61 | ProgressBar.Increment(1);
62 | Application.DoEvents();
63 | }
64 |
65 | ProgressBar.Value = 0;
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/PIToolkit/PITagsCleaner/MainForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/PIToolkit/PITagsCleaner/PITagsCleaner.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {F43F2E7D-DEC8-4586-A8AD-B13152A1DF51}
5 | Debug
6 | x86
7 | WinExe
8 | PITagsCleaner
9 | PITagsCleaner
10 | v4.5.2
11 |
12 |
13 | Properties
14 |
15 |
16 | x86
17 |
18 |
19 | bin\Debug\
20 | True
21 | Full
22 | False
23 | True
24 | DEBUG;TRACE
25 |
26 |
27 | bin\Release\
28 | False
29 | None
30 | True
31 | False
32 | TRACE
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | MainForm.cs
46 |
47 |
48 |
49 |
50 |
51 | MainForm.cs
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/PIToolkit/PITagsCleaner/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace PITagsCleaner
5 | {
6 | internal sealed class Program
7 | {
8 | [STAThread]
9 | private static void Main(string[] args)
10 | {
11 | Application.EnableVisualStyles();
12 | Application.SetCompatibleTextRenderingDefault(false);
13 | Application.Run(new MainForm());
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/PIToolkit/PITagsCleaner/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/PIToolkit/PIToolkit.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28010.2036
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PIBrowser", "PIBrowser\PIBrowser.csproj", "{C6B8E368-7807-440A-9A48-03B3A89C5878}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PIBrowserTests", "PIBrowserTests\PIBrowserTests.csproj", "{B45CA2DF-3F5E-4765-AEBF-4C2C0D4DAF04}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AFEventsCleaner", "AFEventsCleaner\AFEventsCleaner.csproj", "{246C2105-C134-4372-AAD6-727871C8FFB1}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PITagsCleaner", "PITagsCleaner\PITagsCleaner.csproj", "{F43F2E7D-DEC8-4586-A8AD-B13152A1DF51}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PBToolkitBar", "PBToolkitBar\PBToolkitBar.csproj", "{BE714B6B-FCC7-4852-BB8A-D7597C05F8BF}"
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | Debug|Any CPU = Debug|Any CPU
19 | Release|Any CPU = Release|Any CPU
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {C6B8E368-7807-440A-9A48-03B3A89C5878}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {C6B8E368-7807-440A-9A48-03B3A89C5878}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {C6B8E368-7807-440A-9A48-03B3A89C5878}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {C6B8E368-7807-440A-9A48-03B3A89C5878}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {B45CA2DF-3F5E-4765-AEBF-4C2C0D4DAF04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {B45CA2DF-3F5E-4765-AEBF-4C2C0D4DAF04}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {B45CA2DF-3F5E-4765-AEBF-4C2C0D4DAF04}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {B45CA2DF-3F5E-4765-AEBF-4C2C0D4DAF04}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {246C2105-C134-4372-AAD6-727871C8FFB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {246C2105-C134-4372-AAD6-727871C8FFB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {246C2105-C134-4372-AAD6-727871C8FFB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {246C2105-C134-4372-AAD6-727871C8FFB1}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {F43F2E7D-DEC8-4586-A8AD-B13152A1DF51}.Debug|Any CPU.ActiveCfg = Debug|x86
35 | {F43F2E7D-DEC8-4586-A8AD-B13152A1DF51}.Release|Any CPU.ActiveCfg = Release|x86
36 | {BE714B6B-FCC7-4852-BB8A-D7597C05F8BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {BE714B6B-FCC7-4852-BB8A-D7597C05F8BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {BE714B6B-FCC7-4852-BB8A-D7597C05F8BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {BE714B6B-FCC7-4852-BB8A-D7597C05F8BF}.Release|Any CPU.Build.0 = Release|Any CPU
40 | EndGlobalSection
41 | GlobalSection(SolutionProperties) = preSolution
42 | HideSolutionNode = FALSE
43 | EndGlobalSection
44 | GlobalSection(ExtensibilityGlobals) = postSolution
45 | SolutionGuid = {695C51B7-6539-4254-B3E1-E066476C1748}
46 | EndGlobalSection
47 | EndGlobal
48 |
--------------------------------------------------------------------------------
/PIToolkit/clean.cmd:
--------------------------------------------------------------------------------
1 | rmdir .\.vs /s /q
2 |
3 | rmdir .\AFEventsCleaner\bin /s /q
4 | rmdir .\AFEventsCleaner\obj /s /q
5 |
6 | rmdir .\PITagsCleaner\bin /s /q
7 | rmdir .\PITagsCleaner\obj /s /q
8 |
9 | rmdir .\PIBrowser\bin /s /q
10 | rmdir .\PIBrowser\obj /s /q
11 |
12 | rmdir .\PIBrowserTests\bin /s /q
13 | rmdir .\PIBrowserTests\obj /s /q
14 | rmdir .\PIBrowserTests\OpenCover /s /q
15 |
16 | rmdir .\PBToolkitBar\bin /s /q
17 | rmdir .\PBToolkitBar\obj /s /q
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Industrial Toolkit
2 |
3 | ## SCADA Tools
4 |
5 | ### RSVTagsExtractor
6 |
7 | This program simplifies the extraction of tags used in the displays of RSView32 software.
8 |
9 | ### WCCTagsExtractor
10 |
11 | This program simplifies the extraction of tags used in the displays of WinCC software.
12 |
13 | ## PI Toolkit
14 |
15 | ### AFEventsCleaner
16 |
17 | ### PITagsCleaner
18 |
19 | ### PIBrowser
20 |
21 | A simple program for searching for tags in PISystem, with the choice of the algorithm for filtering data and viewing on charts.
22 |
23 | The current version using the PI API (no support for collectives of PIServers and domain authorization). Functionality is limited.
24 |
--------------------------------------------------------------------------------
/RSVTagsExtractor/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace RSVTagsExtractor
2 | {
3 | partial class MainForm
4 | {
5 | ///
6 | /// Designer variable used to keep track of non-visual components.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 | private System.Windows.Forms.Button btnSelectXML;
10 | private System.Windows.Forms.TextBox txtXMLFilename;
11 | private System.Windows.Forms.Button btnSelectCSV;
12 | private System.Windows.Forms.TextBox txtCSVFilename;
13 | private System.Windows.Forms.Button btnExtract;
14 | private System.Windows.Forms.TextBox textBox1;
15 | private System.Windows.Forms.Button btnSelectOutputCSV;
16 | private System.Windows.Forms.TextBox txtOutputFilename;
17 |
18 | ///
19 | /// Disposes resources used by the form.
20 | ///
21 | /// true if managed resources should be disposed; otherwise, false.
22 | protected override void Dispose(bool disposing)
23 | {
24 | if (disposing) {
25 | if (components != null) {
26 | components.Dispose();
27 | }
28 | }
29 | base.Dispose(disposing);
30 | }
31 |
32 | ///
33 | /// This method is required for Windows Forms designer support.
34 | /// Do not change the method contents inside the source code editor. The Forms designer might
35 | /// not be able to load this method if it was changed manually.
36 | ///
37 | private void InitializeComponent()
38 | {
39 | this.btnSelectXML = new System.Windows.Forms.Button();
40 | this.txtXMLFilename = new System.Windows.Forms.TextBox();
41 | this.btnSelectCSV = new System.Windows.Forms.Button();
42 | this.txtCSVFilename = new System.Windows.Forms.TextBox();
43 | this.btnExtract = new System.Windows.Forms.Button();
44 | this.textBox1 = new System.Windows.Forms.TextBox();
45 | this.btnSelectOutputCSV = new System.Windows.Forms.Button();
46 | this.txtOutputFilename = new System.Windows.Forms.TextBox();
47 | this.SuspendLayout();
48 | //
49 | // btnSelectXML
50 | //
51 | this.btnSelectXML.Location = new System.Drawing.Point(24, 22);
52 | this.btnSelectXML.Name = "btnSelectXML";
53 | this.btnSelectXML.Size = new System.Drawing.Size(161, 38);
54 | this.btnSelectXML.TabIndex = 0;
55 | this.btnSelectXML.Text = "Select XML (display)";
56 | this.btnSelectXML.UseVisualStyleBackColor = true;
57 | this.btnSelectXML.Click += new System.EventHandler(this.btnSelectXML_Click);
58 | //
59 | // txtXMLFilename
60 | //
61 | this.txtXMLFilename.Location = new System.Drawing.Point(191, 30);
62 | this.txtXMLFilename.Name = "txtXMLFilename";
63 | this.txtXMLFilename.ReadOnly = true;
64 | this.txtXMLFilename.Size = new System.Drawing.Size(752, 22);
65 | this.txtXMLFilename.TabIndex = 1;
66 | //
67 | // btnSelectCSV
68 | //
69 | this.btnSelectCSV.Location = new System.Drawing.Point(24, 66);
70 | this.btnSelectCSV.Name = "btnSelectCSV";
71 | this.btnSelectCSV.Size = new System.Drawing.Size(161, 38);
72 | this.btnSelectCSV.TabIndex = 0;
73 | this.btnSelectCSV.Text = "Select CSV (tags)";
74 | this.btnSelectCSV.UseVisualStyleBackColor = true;
75 | this.btnSelectCSV.Click += new System.EventHandler(this.btnSelectCSV_Click);
76 | //
77 | // txtCSVFilename
78 | //
79 | this.txtCSVFilename.Location = new System.Drawing.Point(191, 74);
80 | this.txtCSVFilename.Name = "txtCSVFilename";
81 | this.txtCSVFilename.ReadOnly = true;
82 | this.txtCSVFilename.Size = new System.Drawing.Size(752, 22);
83 | this.txtCSVFilename.TabIndex = 1;
84 | //
85 | // btnExtract
86 | //
87 | this.btnExtract.Location = new System.Drawing.Point(24, 173);
88 | this.btnExtract.Name = "btnExtract";
89 | this.btnExtract.Size = new System.Drawing.Size(161, 38);
90 | this.btnExtract.TabIndex = 0;
91 | this.btnExtract.Text = "Extract tags";
92 | this.btnExtract.UseVisualStyleBackColor = true;
93 | this.btnExtract.Click += new System.EventHandler(this.btnExtract_Click);
94 | //
95 | // textBox1
96 | //
97 | this.textBox1.Location = new System.Drawing.Point(26, 217);
98 | this.textBox1.Multiline = true;
99 | this.textBox1.Name = "textBox1";
100 | this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
101 | this.textBox1.Size = new System.Drawing.Size(1038, 314);
102 | this.textBox1.TabIndex = 2;
103 | //
104 | // btnSelectOutputCSV
105 | //
106 | this.btnSelectOutputCSV.Enabled = false;
107 | this.btnSelectOutputCSV.Location = new System.Drawing.Point(24, 110);
108 | this.btnSelectOutputCSV.Name = "btnSelectOutputCSV";
109 | this.btnSelectOutputCSV.Size = new System.Drawing.Size(161, 38);
110 | this.btnSelectOutputCSV.TabIndex = 0;
111 | this.btnSelectOutputCSV.Text = "Select CSV (tags out)";
112 | this.btnSelectOutputCSV.UseVisualStyleBackColor = true;
113 | this.btnSelectOutputCSV.Click += new System.EventHandler(this.btnSelectOutputCSV_Click);
114 | //
115 | // txtOutputFilename
116 | //
117 | this.txtOutputFilename.Location = new System.Drawing.Point(191, 118);
118 | this.txtOutputFilename.Name = "txtOutputFilename";
119 | this.txtOutputFilename.ReadOnly = true;
120 | this.txtOutputFilename.Size = new System.Drawing.Size(752, 22);
121 | this.txtOutputFilename.TabIndex = 1;
122 | //
123 | // MainForm
124 | //
125 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
126 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
127 | this.ClientSize = new System.Drawing.Size(1076, 546);
128 | this.Controls.Add(this.textBox1);
129 | this.Controls.Add(this.txtOutputFilename);
130 | this.Controls.Add(this.txtCSVFilename);
131 | this.Controls.Add(this.txtXMLFilename);
132 | this.Controls.Add(this.btnSelectOutputCSV);
133 | this.Controls.Add(this.btnExtract);
134 | this.Controls.Add(this.btnSelectCSV);
135 | this.Controls.Add(this.btnSelectXML);
136 | this.Name = "MainForm";
137 | this.Text = "RSView TagsExtractor";
138 | this.ResumeLayout(false);
139 | this.PerformLayout();
140 |
141 | }
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/RSVTagsExtractor/MainForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data;
3 | using System.IO;
4 | using System.Text;
5 | using System.Windows.Forms;
6 | using System.Xml;
7 | using BSLib;
8 |
9 | namespace RSVTagsExtractor
10 | {
11 | public partial class MainForm : Form
12 | {
13 | private string fXMLFilename;
14 | private string fCSVFilename;
15 | private string fCSVOutput;
16 |
17 | private DataTable fCSVData;
18 |
19 | public MainForm()
20 | {
21 | InitializeComponent();
22 | }
23 |
24 | private void btnSelectXML_Click(object sender, EventArgs e)
25 | {
26 | using (var ofd = new OpenFileDialog()) {
27 | if (ofd.ShowDialog() == DialogResult.OK) {
28 | fXMLFilename = ofd.FileName;
29 | txtXMLFilename.Text = fXMLFilename;
30 |
31 | string outFn = Path.ChangeExtension(fXMLFilename, ".tags.csv");
32 | txtOutputFilename.Text = outFn;
33 | fCSVOutput = outFn;
34 |
35 | string path = Path.GetDirectoryName(fXMLFilename);
36 | fCSVFilename = path + "\\tags.csv";
37 | txtCSVFilename.Text = fCSVFilename;
38 | }
39 | }
40 | }
41 |
42 | private void btnSelectCSV_Click(object sender, EventArgs e)
43 | {
44 | using (var ofd = new OpenFileDialog()) {
45 | if (ofd.ShowDialog() == DialogResult.OK) {
46 | fCSVFilename = ofd.FileName;
47 | txtCSVFilename.Text = fCSVFilename;
48 | }
49 | }
50 | }
51 |
52 | private string SearchExpression(XmlNode node, XmlNamespaceManager ns)
53 | {
54 | XmlNodeList nodes = node.SelectNodes("ReplaceableFields/Property", ns);
55 | foreach (XmlNode propNode in nodes) {
56 | var attrVal = propNode.Attributes["Name"].InnerText;
57 | if (attrVal == "Expression") {
58 | return propNode.InnerText;
59 | }
60 | }
61 | return null;
62 | }
63 |
64 | private string SearchExpressionExt(XmlNode node, XmlNamespaceManager ns, string filter)
65 | {
66 | XmlNodeList nodes = node.SelectNodes(filter, ns);
67 | foreach (XmlNode propNode in nodes) {
68 | var attrVal = propNode.Attributes["expression"].InnerText;
69 | //if (string.Equals(attrVal, "Expression", StringComparison.InvariantCultureIgnoreCase)) {
70 | return attrVal;
71 | //}
72 | }
73 | return null;
74 | }
75 |
76 | private void LoadCSV()
77 | {
78 | if (!string.IsNullOrEmpty(fCSVFilename)) {
79 | fCSVData = CSVReader.ReadCSVFile(fCSVFilename, Encoding.GetEncoding(1251), true, CSVReader.COMMA_SEPARATOR);
80 | }
81 | }
82 |
83 | private DataRow SearchTag(string tag)
84 | {
85 | if (fCSVData != null) {
86 | foreach (DataRow row in fCSVData.Rows) {
87 | if (string.Equals(row[1].ToString(), tag, StringComparison.OrdinalIgnoreCase)) {
88 | return row;
89 | }
90 | }
91 | }
92 |
93 | return null;
94 | }
95 |
96 | private void WriteTagInfo(DataRow tagRow, string nodeName, StreamWriter wrtOut)
97 | {
98 | StringBuilder str = new StringBuilder();
99 |
100 | foreach (var cell in tagRow.ItemArray) {
101 | if (str.Length > 0) {
102 | str.Append(";");
103 | }
104 | if (cell is string) {
105 | str.Append("\"" + cell.ToString() + "\"");
106 | } else {
107 | str.Append(cell.ToString());
108 | }
109 | }
110 |
111 | if (wrtOut != null) {
112 | wrtOut.WriteLine(nodeName + ";" + str.ToString());
113 | }
114 | }
115 |
116 | private void btnExtract_Click(object sender, EventArgs e)
117 | {
118 | textBox1.Clear();
119 |
120 | if (string.IsNullOrEmpty(fXMLFilename)) {
121 | MessageBox.Show("XML not defined", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
122 | return;
123 | }
124 |
125 | LoadCSV();
126 |
127 | StreamWriter wrtOut;
128 | if (string.IsNullOrEmpty(fCSVOutput)) {
129 | MessageBox.Show("Output filename not defined", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
130 | wrtOut = null;
131 | } else {
132 | wrtOut = new StreamWriter(new FileStream(fCSVOutput, FileMode.Create), Encoding.GetEncoding(1251));
133 |
134 | string header = "Element";
135 | if (fCSVData != null) {
136 | foreach (DataColumn column in fCSVData.Columns) {
137 | string colName = column.ColumnName;
138 | if (!string.IsNullOrEmpty(colName)) {
139 | if (colName[0] == ';') {
140 | header += colName;
141 | } else {
142 | header += ";" + colName;
143 | }
144 | }
145 | }
146 | }
147 | wrtOut.WriteLine(header);
148 | }
149 |
150 | using (var dataStream = new FileStream(fXMLFilename, FileMode.Open)) {
151 | XmlDocument doc = new XmlDocument();
152 | doc.Load(dataStream);
153 |
154 | XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable);
155 |
156 | XmlNodeList nodes = doc.SelectNodes("//RSGFX", ns);
157 | foreach (XmlNode node in nodes) {
158 | //textBox1.AppendText(node.Attributes["name"].InnerText + "\r\n");
159 |
160 | string expr = SearchExpression(node, ns);
161 | if (expr != null) {
162 | PrepareExpression(node, expr, wrtOut, "");
163 | }
164 |
165 | expr = SearchExpressionExt(node, ns, "ReplaceableFields/Animations/Color");
166 | if (expr != null) {
167 | PrepareExpression(node, expr, wrtOut, "#C");
168 | }
169 |
170 | expr = SearchExpressionExt(node, ns, "ReplaceableFields/Animations/Fill");
171 | if (expr != null) {
172 | PrepareExpression(node, expr, wrtOut, "#F");
173 | }
174 |
175 | expr = SearchExpressionExt(node, ns, "ReplaceableFields/Animations/Visibility");
176 | if (expr != null) {
177 | PrepareExpression(node, expr, wrtOut, "#V");
178 | }
179 | }
180 | }
181 |
182 | if (wrtOut != null) {
183 | wrtOut.Flush();
184 | wrtOut.Close();
185 | }
186 |
187 | textBox1.AppendText("\r\nExtraction finished!");
188 | }
189 |
190 | private void PrepareExpression(XmlNode node, string expr, StreamWriter wrtOut, string ext)
191 | {
192 | string parentName = "";
193 | if (node.ParentNode != null) {
194 | try {
195 | parentName = node.ParentNode.Attributes["name"].InnerText;
196 | } catch {
197 | }
198 | }
199 |
200 | string nodeName = parentName + "|" + node.Attributes["name"].InnerText + ext;
201 |
202 | DataRow tagRow = SearchTag(expr);
203 | if (tagRow != null) {
204 | WriteTagInfo(tagRow, nodeName, wrtOut);
205 | } else {
206 | ProcessExpression(expr, nodeName, wrtOut);
207 | }
208 | }
209 |
210 | private void ProcessExpression(string expr, string nodeName, StreamWriter wrtOut)
211 | {
212 | expr = expr.Trim();
213 | expr = expr.Replace("\r", "~").Replace("\n", "~").Replace("{", "~").Replace("}", "~");
214 | expr = expr.Replace("(", "~").Replace(")", "~").Replace("==", "~").Replace(")", "~");
215 | expr = expr.Replace("<", "~").Replace(">", "~").Replace("=", "~");
216 | expr = ReplaceCaseInsensitive(expr, " or ", "~", StringComparison.OrdinalIgnoreCase);
217 | expr = ReplaceCaseInsensitive(expr, " and ", "~", StringComparison.OrdinalIgnoreCase);
218 | expr = ReplaceCaseInsensitive(expr, "If ", "~", StringComparison.OrdinalIgnoreCase);
219 | expr = ReplaceCaseInsensitive(expr, "Then ", "~", StringComparison.OrdinalIgnoreCase);
220 | expr = ReplaceCaseInsensitive(expr, " Then", "~", StringComparison.OrdinalIgnoreCase);
221 | expr = ReplaceCaseInsensitive(expr, "Else ", "~", StringComparison.OrdinalIgnoreCase);
222 | expr = ReplaceCaseInsensitive(expr, " Else", "~", StringComparison.OrdinalIgnoreCase);
223 | expr = expr.Replace("~~", "~");
224 |
225 | bool first = true;
226 | string[] slices = expr.Split(new char[]{ '~' }, StringSplitOptions.RemoveEmptyEntries);
227 | foreach (string sl in slices) {
228 | string tsl = sl.Trim();
229 | if (!string.IsNullOrEmpty(tsl)) {
230 | double x;
231 | if (double.TryParse(tsl, out x) || (tsl[0] == '"' && tsl[tsl.Length - 1] == '"') || tsl == "Else" || tsl == "AND" || tsl == "OR" || tsl.StartsWith("system\\")) {
232 | // skip
233 | } else {
234 | DataRow tagRow = SearchTag(tsl);
235 | if (tagRow == null) {
236 | if (first) {
237 | textBox1.AppendText(nodeName + "\r\n");
238 | first = false;
239 | }
240 | textBox1.AppendText(">>>>>>>> Tag not found: '" + sl + "'\r\n");
241 | } else {
242 | WriteTagInfo(tagRow, nodeName, wrtOut);
243 | }
244 | }
245 | }
246 | }
247 | }
248 |
249 | private void btnSelectOutputCSV_Click(object sender, EventArgs e)
250 | {
251 | /*using (var sfd = new SaveFileDialog()) {
252 | if (sfd.ShowDialog() == DialogResult.OK) {
253 | txtOutputFilename.Text = sfd.FileName;
254 | fCSVOutput = sfd.FileName;
255 | }
256 | }*/
257 | }
258 |
259 | public static string ReplaceCaseInsensitive(string str, string oldValue, string newValue, StringComparison comparison)
260 | {
261 | if (oldValue == null)
262 | throw new ArgumentNullException("oldValue");
263 | if (oldValue.Length == 0)
264 | throw new ArgumentException("String cannot be of zero length.", "oldValue");
265 |
266 | StringBuilder sb = null;
267 |
268 | int startIndex = 0;
269 | int foundIndex = str.IndexOf(oldValue, comparison);
270 | while (foundIndex != -1) {
271 | if (sb == null)
272 | sb = new StringBuilder(str.Length + (newValue != null ? Math.Max(0, 5 * (newValue.Length - oldValue.Length)) : 0));
273 | sb.Append(str, startIndex, foundIndex - startIndex);
274 | sb.Append(newValue);
275 |
276 | startIndex = foundIndex + oldValue.Length;
277 | foundIndex = str.IndexOf(oldValue, startIndex, comparison);
278 | }
279 |
280 | if (startIndex == 0)
281 | return str;
282 | sb.Append(str, startIndex, str.Length - startIndex);
283 | return sb.ToString();
284 | }
285 | }
286 | }
287 |
--------------------------------------------------------------------------------
/RSVTagsExtractor/MainForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/RSVTagsExtractor/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace RSVTagsExtractor
5 | {
6 | internal sealed class Program
7 | {
8 | [STAThread]
9 | private static void Main(string[] args)
10 | {
11 | Application.EnableVisualStyles();
12 | Application.SetCompatibleTextRenderingDefault(false);
13 | Application.Run(new MainForm());
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/RSVTagsExtractor/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("RSView TagsExtractor")]
6 | [assembly: AssemblyDescription("")]
7 | [assembly: AssemblyConfiguration("")]
8 | [assembly: AssemblyCompany("")]
9 | [assembly: AssemblyProduct("RSVTagsExtractor")]
10 | [assembly: AssemblyCopyright("Copyright © 2017 Sergey V. Zhdanovskih")]
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: ComVisible(false)]
14 | [assembly: AssemblyVersion("1.0.0.0")]
15 |
--------------------------------------------------------------------------------
/RSVTagsExtractor/RSVTagsExtractor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {28B0A4BD-3246-49B4-A797-8C009902E251}
5 | {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
6 | Debug
7 | AnyCPU
8 | WinExe
9 | RSVExtractor
10 | RSVTagsExtractor
11 | v4.5
12 | Properties
13 |
14 |
15 |
16 | x86
17 |
18 |
19 | bin\Debug\
20 | True
21 | Full
22 | False
23 | True
24 | DEBUG;TRACE
25 |
26 |
27 | bin\Release\
28 | False
29 | None
30 | True
31 | False
32 | TRACE
33 |
34 |
35 |
36 | ..\BSLib.dll
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | MainForm.cs
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | MainForm.cs
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/RSVTagsExtractor/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/SCADATools.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | # SharpDevelop 5.1
5 | VisualStudioVersion = 12.0.20827.3
6 | MinimumVisualStudioVersion = 10.0.40219.1
7 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RSVTagsExtractor", "RSVTagsExtractor\RSVTagsExtractor.csproj", "{28B0A4BD-3246-49B4-A797-8C009902E251}"
8 | EndProject
9 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WCCTagsExtractor", "WCCTagsExtractor\WCCTagsExtractor.csproj", "{2ABDE4E8-757E-4E63-A802-D65F9275709B}"
10 | EndProject
11 | Global
12 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
13 | Debug|Any CPU = Debug|Any CPU
14 | Release|Any CPU = Release|Any CPU
15 | EndGlobalSection
16 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
17 | {28B0A4BD-3246-49B4-A797-8C009902E251}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18 | {28B0A4BD-3246-49B4-A797-8C009902E251}.Debug|Any CPU.Build.0 = Debug|Any CPU
19 | {28B0A4BD-3246-49B4-A797-8C009902E251}.Release|Any CPU.ActiveCfg = Release|Any CPU
20 | {28B0A4BD-3246-49B4-A797-8C009902E251}.Release|Any CPU.Build.0 = Release|Any CPU
21 | {2ABDE4E8-757E-4E63-A802-D65F9275709B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22 | {2ABDE4E8-757E-4E63-A802-D65F9275709B}.Debug|Any CPU.Build.0 = Debug|Any CPU
23 | {2ABDE4E8-757E-4E63-A802-D65F9275709B}.Release|Any CPU.ActiveCfg = Release|Any CPU
24 | {2ABDE4E8-757E-4E63-A802-D65F9275709B}.Release|Any CPU.Build.0 = Release|Any CPU
25 | EndGlobalSection
26 | EndGlobal
27 |
--------------------------------------------------------------------------------
/WCCTagsExtractor/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WCCTagsExtractor
2 | {
3 | partial class MainForm
4 | {
5 | ///
6 | /// Designer variable used to keep track of non-visual components.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 | private System.Windows.Forms.TextBox textBox1;
10 | private System.Windows.Forms.TextBox txtOutputFilename;
11 | private System.Windows.Forms.TextBox txtCSVFilename;
12 | private System.Windows.Forms.Button btnSelectCSV;
13 | private System.Windows.Forms.Button btnSelectPDL;
14 | private System.Windows.Forms.TextBox txtPDLFilename;
15 | private System.Windows.Forms.Label label1;
16 | private System.Windows.Forms.ComboBox cmbEncoding;
17 | private System.Windows.Forms.CheckBox chkDebugMode;
18 | private System.Windows.Forms.Label label2;
19 | private System.Windows.Forms.TextBox textBox2;
20 |
21 | ///
22 | /// Disposes resources used by the form.
23 | ///
24 | /// true if managed resources should be disposed; otherwise, false.
25 | protected override void Dispose(bool disposing)
26 | {
27 | if (disposing) {
28 | if (components != null) {
29 | components.Dispose();
30 | }
31 | }
32 | base.Dispose(disposing);
33 | }
34 |
35 | ///
36 | /// This method is required for Windows Forms designer support.
37 | /// Do not change the method contents inside the source code editor. The Forms designer might
38 | /// not be able to load this method if it was changed manually.
39 | ///
40 | private void InitializeComponent()
41 | {
42 | this.textBox1 = new System.Windows.Forms.TextBox();
43 | this.txtOutputFilename = new System.Windows.Forms.TextBox();
44 | this.txtCSVFilename = new System.Windows.Forms.TextBox();
45 | this.txtPDLFilename = new System.Windows.Forms.TextBox();
46 | this.btnSelectCSV = new System.Windows.Forms.Button();
47 | this.btnSelectPDL = new System.Windows.Forms.Button();
48 | this.label1 = new System.Windows.Forms.Label();
49 | this.cmbEncoding = new System.Windows.Forms.ComboBox();
50 | this.chkDebugMode = new System.Windows.Forms.CheckBox();
51 | this.label2 = new System.Windows.Forms.Label();
52 | this.textBox2 = new System.Windows.Forms.TextBox();
53 | this.SuspendLayout();
54 | //
55 | // textBox1
56 | //
57 | this.textBox1.Location = new System.Drawing.Point(14, 199);
58 | this.textBox1.Multiline = true;
59 | this.textBox1.Name = "textBox1";
60 | this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
61 | this.textBox1.Size = new System.Drawing.Size(1101, 328);
62 | this.textBox1.TabIndex = 10;
63 | //
64 | // txtOutputFilename
65 | //
66 | this.txtOutputFilename.Location = new System.Drawing.Point(179, 108);
67 | this.txtOutputFilename.Name = "txtOutputFilename";
68 | this.txtOutputFilename.ReadOnly = true;
69 | this.txtOutputFilename.Size = new System.Drawing.Size(752, 22);
70 | this.txtOutputFilename.TabIndex = 7;
71 | //
72 | // txtCSVFilename
73 | //
74 | this.txtCSVFilename.Location = new System.Drawing.Point(179, 64);
75 | this.txtCSVFilename.Name = "txtCSVFilename";
76 | this.txtCSVFilename.ReadOnly = true;
77 | this.txtCSVFilename.Size = new System.Drawing.Size(752, 22);
78 | this.txtCSVFilename.TabIndex = 8;
79 | //
80 | // txtPDLFilename
81 | //
82 | this.txtPDLFilename.Location = new System.Drawing.Point(179, 20);
83 | this.txtPDLFilename.Name = "txtPDLFilename";
84 | this.txtPDLFilename.ReadOnly = true;
85 | this.txtPDLFilename.Size = new System.Drawing.Size(752, 22);
86 | this.txtPDLFilename.TabIndex = 9;
87 | //
88 | // btnSelectCSV
89 | //
90 | this.btnSelectCSV.Location = new System.Drawing.Point(12, 56);
91 | this.btnSelectCSV.Name = "btnSelectCSV";
92 | this.btnSelectCSV.Size = new System.Drawing.Size(161, 38);
93 | this.btnSelectCSV.TabIndex = 5;
94 | this.btnSelectCSV.Text = "Select CSV (tags)";
95 | this.btnSelectCSV.UseVisualStyleBackColor = true;
96 | this.btnSelectCSV.Click += new System.EventHandler(this.btnSelectCSV_Click);
97 | //
98 | // btnSelectPDL
99 | //
100 | this.btnSelectPDL.Location = new System.Drawing.Point(12, 12);
101 | this.btnSelectPDL.Name = "btnSelectPDL";
102 | this.btnSelectPDL.Size = new System.Drawing.Size(161, 38);
103 | this.btnSelectPDL.TabIndex = 6;
104 | this.btnSelectPDL.Text = "Select PDL (display)";
105 | this.btnSelectPDL.UseVisualStyleBackColor = true;
106 | this.btnSelectPDL.Click += new System.EventHandler(this.btnSelectPDL_Click);
107 | //
108 | // label1
109 | //
110 | this.label1.Location = new System.Drawing.Point(12, 154);
111 | this.label1.Name = "label1";
112 | this.label1.Size = new System.Drawing.Size(100, 23);
113 | this.label1.TabIndex = 11;
114 | this.label1.Text = "Encoding";
115 | //
116 | // cmbEncoding
117 | //
118 | this.cmbEncoding.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
119 | this.cmbEncoding.FormattingEnabled = true;
120 | this.cmbEncoding.Items.AddRange(new object[] {
121 | "ASCII",
122 | "Win1251",
123 | "Unicode"});
124 | this.cmbEncoding.Location = new System.Drawing.Point(179, 151);
125 | this.cmbEncoding.Name = "cmbEncoding";
126 | this.cmbEncoding.Size = new System.Drawing.Size(148, 24);
127 | this.cmbEncoding.TabIndex = 12;
128 | //
129 | // chkDebugMode
130 | //
131 | this.chkDebugMode.Location = new System.Drawing.Point(446, 148);
132 | this.chkDebugMode.Name = "chkDebugMode";
133 | this.chkDebugMode.Size = new System.Drawing.Size(155, 31);
134 | this.chkDebugMode.TabIndex = 13;
135 | this.chkDebugMode.Text = "DebugMode";
136 | this.chkDebugMode.UseVisualStyleBackColor = true;
137 | //
138 | // label2
139 | //
140 | this.label2.Location = new System.Drawing.Point(12, 111);
141 | this.label2.Name = "label2";
142 | this.label2.Size = new System.Drawing.Size(100, 23);
143 | this.label2.TabIndex = 11;
144 | this.label2.Text = "CSV tags out";
145 | //
146 | // textBox2
147 | //
148 | this.textBox2.Location = new System.Drawing.Point(1121, 199);
149 | this.textBox2.Multiline = true;
150 | this.textBox2.Name = "textBox2";
151 | this.textBox2.ScrollBars = System.Windows.Forms.ScrollBars.Both;
152 | this.textBox2.Size = new System.Drawing.Size(386, 328);
153 | this.textBox2.TabIndex = 14;
154 | //
155 | // MainForm
156 | //
157 | this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
158 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
159 | this.ClientSize = new System.Drawing.Size(1519, 539);
160 | this.Controls.Add(this.textBox2);
161 | this.Controls.Add(this.chkDebugMode);
162 | this.Controls.Add(this.cmbEncoding);
163 | this.Controls.Add(this.label2);
164 | this.Controls.Add(this.label1);
165 | this.Controls.Add(this.textBox1);
166 | this.Controls.Add(this.txtOutputFilename);
167 | this.Controls.Add(this.txtCSVFilename);
168 | this.Controls.Add(this.txtPDLFilename);
169 | this.Controls.Add(this.btnSelectCSV);
170 | this.Controls.Add(this.btnSelectPDL);
171 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
172 | this.MaximizeBox = false;
173 | this.Name = "MainForm";
174 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
175 | this.Text = "WinCC TagsExtractor";
176 | this.ResumeLayout(false);
177 | this.PerformLayout();
178 |
179 | }
180 | }
181 | }
182 |
--------------------------------------------------------------------------------
/WCCTagsExtractor/MainForm.cs:
--------------------------------------------------------------------------------
1 | #define AUTO_ENCODE
2 |
3 | using System;
4 | using System.Data;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using BSLib;
10 | using OpenMcdf;
11 |
12 | namespace WCCTagsExtractor
13 | {
14 | public partial class MainForm : Form
15 | {
16 | private string fPDLFileName;
17 | private string fCSVFilename;
18 | private string fCSVOutput;
19 |
20 | private DataTable fCSVData;
21 |
22 | private int fEncodingIndex;
23 | private Encoding fEncoding;
24 | private bool fIsUnicode;
25 |
26 | public MainForm()
27 | {
28 | InitializeComponent();
29 |
30 | cmbEncoding.SelectedIndex = 2;
31 | chkDebugMode.Checked = true;
32 | }
33 |
34 | private void DefineEncoding()
35 | {
36 | fEncodingIndex = cmbEncoding.SelectedIndex;
37 | fIsUnicode = false;
38 | switch (fEncodingIndex) {
39 | case 0:
40 | fEncoding = Encoding.ASCII;
41 | break;
42 |
43 | case 1:
44 | fEncoding = Encoding.GetEncoding(1251);
45 | break;
46 |
47 | case 2:
48 | fIsUnicode = true;
49 | fEncoding = Encoding.Unicode;
50 | break;
51 | }
52 | }
53 |
54 | private void btnSelectPDL_Click(object sender, EventArgs e)
55 | {
56 | using (var ofd = new OpenFileDialog()) {
57 | ofd.Filter = "WinCC graphics files (*.pdl)|*.pdl";
58 | ofd.Multiselect = true;
59 | if (ofd.ShowDialog() == DialogResult.OK) {
60 | int num = ofd.FileNames.Length;
61 | for (int i = 0; i < num; i++) {
62 | Text = (i+1) + " / " + num;
63 | SelectPdl(ofd.FileNames[i]);
64 | Update();
65 | }
66 | }
67 | }
68 | }
69 |
70 | private void SelectPdl(string fileName)
71 | {
72 | textBox1.Clear();
73 |
74 | fPDLFileName = fileName;
75 | txtPDLFilename.Text = fPDLFileName;
76 |
77 | string outFn = Path.ChangeExtension(fPDLFileName, ".tags.csv");
78 | txtOutputFilename.Text = outFn;
79 | fCSVOutput = outFn;
80 |
81 | string path = Path.GetDirectoryName(fPDLFileName);
82 | fCSVFilename = path + "\\tags.csv";
83 | txtCSVFilename.Text = fCSVFilename;
84 |
85 | DefineEncoding();
86 |
87 | ExtractTags(chkDebugMode.Checked);
88 | }
89 |
90 | private void ExtractTags(bool debug)
91 | {
92 | textBox1.Clear();
93 |
94 | if (string.IsNullOrEmpty(fPDLFileName)) {
95 | MessageBox.Show("PDL not defined", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
96 | return;
97 | }
98 |
99 | StreamWriter wrtOut = null;
100 | if (!debug) {
101 | if (string.IsNullOrEmpty(fCSVOutput)) {
102 | MessageBox.Show("Output filename not defined", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
103 | wrtOut = null;
104 | } else {
105 | wrtOut = new StreamWriter(new FileStream(fCSVOutput, FileMode.Create), Encoding.GetEncoding(1251));
106 |
107 | string header = "Element";
108 | if (fCSVData != null) {
109 | foreach (DataColumn column in fCSVData.Columns) {
110 | string colName = column.ColumnName;
111 | if (!string.IsNullOrEmpty(colName)) {
112 | if (colName[0] == ';') {
113 | header += colName;
114 | } else {
115 | header += ";" + colName;
116 | }
117 | }
118 | }
119 | }
120 | wrtOut.WriteLine(header);
121 | }
122 | }
123 |
124 | ParsePDL(wrtOut, debug);
125 |
126 | if (!debug) {
127 | if (wrtOut != null) {
128 | wrtOut.Flush();
129 | wrtOut.Close();
130 | }
131 |
132 | textBox1.AppendText("\r\nExtraction finished!");
133 | }
134 | }
135 |
136 | private void ParsePDL(StreamWriter wrtOut, bool debug)
137 | {
138 | using (var fs = new FileStream(fPDLFileName, FileMode.Open)) {
139 | using (var cf = new CompoundFile(fs)) {
140 | CFStream cfStm = cf.RootStorage.GetStream("DynamicsStream");
141 | byte[] bytes = cfStm.GetData();
142 | using (var ms = new MemoryStream(bytes)) {
143 | using (var binRd = new BinaryReader(ms, Encoding.Unicode)) {
144 | ParsePDL(binRd, wrtOut, debug);
145 | }
146 | }
147 | }
148 | }
149 | }
150 |
151 | private void ParsePDL(BinaryReader binReader, StreamWriter wrtOut, bool debug)
152 | {
153 | try {
154 | int size = binReader.ReadInt16();
155 | textBox1.AppendText("size: " + size + "\r\n");
156 | byte[] fileHeader = binReader.ReadBytes(2);
157 | textBox1.AppendText("header: " + ByteArrayToString(fileHeader) + "\r\n\r\n");
158 |
159 | int num = 0;
160 | while (binReader.BaseStream.Position < binReader.BaseStream.Length) {
161 | num += 1;
162 |
163 | byte[] recHeader = binReader.ReadBytes(6);
164 | byte[] recFooter = new byte[0];
165 |
166 | #if AUTO_ENCODE
167 | byte encod = recHeader[0];
168 | switch (encod) {
169 | case 1:
170 | fEncoding = Encoding.GetEncoding(1251);
171 | fIsUnicode = false;
172 | break;
173 | case 2:
174 | case 3:
175 | fEncoding = Encoding.Unicode;
176 | fIsUnicode = true;
177 | break;
178 | default:
179 | textBox1.AppendText(">>>> Unknown 'enc' code: " + encod + "\r\n");
180 | break;
181 | }
182 | #endif
183 |
184 | string objName, propName, tagName = "";
185 | bool needOutput = true;
186 | bool breakout = false;
187 |
188 | objName = ReadStr(binReader);
189 | propName = ReadStr(binReader);
190 |
191 | byte recTypeX = recHeader[5];
192 | switch (recTypeX) {
193 | case 0x03:
194 | case 0x07:
195 | case 0x11:
196 | {
197 | byte[] bufX = binReader.ReadBytes(4);
198 | tagName = ReadStr(binReader);
199 | break;
200 | }
201 |
202 | case 0x04:
203 | {
204 | byte[] bufX = binReader.ReadBytes(4);
205 | tagName = ReadStr(binReader);
206 | string x2 = ReadStr(binReader); // tag too
207 | break;
208 | }
209 |
210 | case 0x9:
211 | {
212 | // button
213 | byte[] bufX = binReader.ReadBytes(8);
214 | string x1 = ReadStr(binReader);
215 | string dispName = ReadStr(binReader);
216 | string x2 = ReadStr(binReader);
217 | string picName = ReadStr(binReader);
218 | needOutput = false;
219 | break;
220 | }
221 |
222 | case 0x1:
223 | case 0x2:
224 | case 0x10:
225 | {
226 | tagName = ReadStr(binReader);
227 | recFooter = binReader.ReadBytes(4);
228 | break;
229 | }
230 |
231 | case 0x8:
232 | {
233 | byte[] bufX = binReader.ReadBytes(4);
234 | tagName = ReadStr(binReader);
235 | break;
236 | }
237 |
238 | case 0x6:
239 | {
240 | if (encod != 1) {
241 | tagName = ReadStr(binReader);
242 | }
243 | recFooter = binReader.ReadBytes(4);
244 | break;
245 | }
246 |
247 | case 0x0A:
248 | {
249 | tagName = ReadStr(binReader);
250 | recFooter = binReader.ReadBytes(4);
251 | break;
252 | }
253 |
254 | case 0x0B:
255 | {
256 | string x1 = ReadStr(binReader); // several tags separated by space (setpoints?)
257 | byte[] bufX = binReader.ReadBytes(4);
258 | tagName = ReadStr(binReader);
259 | break;
260 | }
261 |
262 | case 0x0C:
263 | {
264 | tagName = ReadStr(binReader);
265 | break;
266 | }
267 |
268 | case 0x0D:
269 | {
270 | byte[] bufX = binReader.ReadBytes(4);
271 | tagName = ReadStr(binReader);
272 | break;
273 | }
274 |
275 | case 0x0E:
276 | {
277 | byte[] bufX = binReader.ReadBytes(4);
278 | string x1 = ReadStr(binReader);
279 | tagName = ReadStr(binReader);
280 | break;
281 | }
282 |
283 | case 0x17:
284 | {
285 | tagName = ReadStr(binReader);
286 | break;
287 | }
288 |
289 | default:
290 | {
291 | textBox1.AppendText(">>>> Unknown element type: " + recTypeX+"\r\n");
292 | breakout = true;
293 | break;
294 | }
295 | }
296 |
297 | LogTag(num, objName, propName, tagName, wrtOut, debug, recHeader, recFooter);
298 |
299 | if (needOutput && !string.IsNullOrEmpty(propName) && !string.IsNullOrEmpty(tagName)) {
300 | bool res = ProcessTag(num, objName, propName, tagName, wrtOut, debug);
301 |
302 | // may be errors of pdl-parsing
303 | if (!res) {
304 | res = ProcessTag(num, objName, tagName, propName, wrtOut, debug);
305 | }
306 |
307 | if (!res && !debug) {
308 | textBox2.AppendText(propName + " || " + tagName + "\r\n");
309 | }
310 | }
311 |
312 | if (breakout) {
313 | break;
314 | }
315 |
316 | if (num == size) {
317 | textBox1.AppendText("\r\nAll readed! \r\n");
318 | break;
319 | }
320 | }
321 |
322 | long rest = binReader.BaseStream.Length - binReader.BaseStream.Position;
323 | if (rest == 0) {
324 | textBox1.AppendText("EoF, all right! \r\n");
325 | } else {
326 | MessageBox.Show("Rest founded: " + rest);
327 | }
328 | } catch (Exception ex) {
329 | MessageBox.Show(ex.Message);
330 | }
331 | }
332 |
333 | public static string ByteArrayToString(byte[] ba)
334 | {
335 | return BitConverter.ToString(ba).Replace("-", " ");
336 | }
337 |
338 | // strange, nonstandard BOM
339 | private static readonly byte[] BOM = new byte[] { 255, 254, 255 };
340 |
341 | private string ReadStr(BinaryReader binReader)
342 | {
343 | if (fIsUnicode) {
344 | byte[] bom = binReader.ReadBytes(3);
345 | if (!Algorithms.ArraysEqual(BOM, bom)) {
346 | binReader.BaseStream.Seek(-3, SeekOrigin.Current);
347 | return "";
348 | }
349 |
350 | byte strLen = binReader.ReadByte();
351 | if (strLen == 0) {
352 | return string.Empty;
353 | } else {
354 | byte[] strBytes = binReader.ReadBytes(strLen * 2);
355 | return Encoding.Unicode.GetString(strBytes);
356 | }
357 | } else {
358 | byte[] strBytes = new byte[255];
359 | byte bt;
360 | bt = binReader.ReadByte();
361 | if (bt == 0x0A) {
362 | return string.Empty;
363 | } else {
364 | binReader.BaseStream.Seek(-1, SeekOrigin.Current);
365 | }
366 |
367 | int i = 0;
368 | while ((bt = binReader.ReadByte()) != 0x0A) {
369 | strBytes[i] = bt;
370 | i++;
371 | }
372 |
373 | if (i > 0) {
374 | return fEncoding.GetString(strBytes, 0, i);
375 | } else {
376 | return string.Empty;
377 | }
378 | }
379 | }
380 |
381 | private bool ProcessTag(int num, string objName, string propName, string tagName, StreamWriter wrtOut, bool debug)
382 | {
383 | if (string.IsNullOrEmpty(tagName)) return false;
384 | if (tagName.EndsWith("_COMMENT") || tagName.EndsWith("_FORMAT") || tagName.EndsWith("_UNITS") || tagName.EndsWith("_SHORT")) return false;
385 |
386 | /*int sharPos = tagName.IndexOf('#');
387 | if (sharPos > 0) {
388 | tagName = tagName.Substring(0, sharPos);
389 | }*/
390 |
391 | int nsPos = tagName.IndexOf("::");
392 | if (nsPos > 0) {
393 | tagName = tagName.Substring(nsPos + 2);
394 | }
395 |
396 | bool result = false;
397 | if (!debug && wrtOut != null) {
398 | DataRow row = SearchTag(tagName);
399 | if (row != null) {
400 | WriteTagInfo(row, objName + "@" + propName, wrtOut);
401 | result = true;
402 | }
403 | }
404 |
405 | return result;
406 | }
407 |
408 | private void LogTag(int num, string objName, string propName, string tagName, StreamWriter wrtOut, bool debug,
409 | byte[] header, byte[] footer)
410 | {
411 | if (debug) {
412 | textBox1.AppendText(ByteArrayToString(header) + " ~~ ");
413 | }
414 | textBox1.AppendText(num.ToString() + " ~ " + objName + " ~ " + propName + " ~ " + tagName);
415 | if (debug) {
416 | textBox1.AppendText(" ~~ " + ByteArrayToString(footer));
417 | }
418 | textBox1.AppendText("\r\n");
419 | }
420 |
421 | private void LoadCSV()
422 | {
423 | if (!string.IsNullOrEmpty(fCSVFilename)) {
424 | fCSVData = CSVReader.ReadCSVFile(fCSVFilename, Encoding.GetEncoding(1251), true, CSVReader.SEMICOLON_SEPARATOR);
425 | textBox1.AppendText("\r\nCSV tags is loaded.");
426 | }
427 | }
428 |
429 | private DataRow SearchTag(string tag)
430 | {
431 | if (fCSVData != null) {
432 | foreach (DataRow row in fCSVData.Rows) {
433 | if (string.Equals(row[0].ToString(), tag, StringComparison.OrdinalIgnoreCase)) {
434 | return row;
435 | }
436 | }
437 | }
438 |
439 | return null;
440 | }
441 |
442 | private void WriteTagInfo(DataRow tagRow, string nodeName, StreamWriter wrtOut)
443 | {
444 | StringBuilder str = new StringBuilder();
445 |
446 | foreach (var cell in tagRow.ItemArray) {
447 | if (str.Length > 0) {
448 | str.Append(";");
449 | }
450 | if (cell is string) {
451 | str.Append("\"" + cell.ToString() + "\"");
452 | } else {
453 | str.Append(cell.ToString());
454 | }
455 | }
456 |
457 | if (wrtOut != null) {
458 | wrtOut.WriteLine(nodeName + ";" + str.ToString());
459 | }
460 | }
461 |
462 | private void btnSelectCSV_Click(object sender, EventArgs e)
463 | {
464 | using (var ofd = new OpenFileDialog()) {
465 | ofd.Filter = "WinCC tags database (*.csv)|*.csv";
466 | if (ofd.ShowDialog() == DialogResult.OK) {
467 | fCSVFilename = ofd.FileName;
468 | txtCSVFilename.Text = fCSVFilename;
469 |
470 | LoadCSV();
471 | }
472 | }
473 | }
474 | }
475 | }
476 |
--------------------------------------------------------------------------------
/WCCTagsExtractor/MainForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/WCCTagsExtractor/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace WCCTagsExtractor
5 | {
6 | internal sealed class Program
7 | {
8 | [STAThread]
9 | private static void Main(string[] args)
10 | {
11 | Application.EnableVisualStyles();
12 | Application.SetCompatibleTextRenderingDefault(false);
13 | Application.Run(new MainForm());
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/WCCTagsExtractor/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Runtime.InteropServices;
4 |
5 | [assembly: AssemblyTitle("WinCC TagsExtractor")]
6 | [assembly: AssemblyDescription("")]
7 | [assembly: AssemblyConfiguration("")]
8 | [assembly: AssemblyCompany("")]
9 | [assembly: AssemblyProduct("WCCTagsExtractor")]
10 | [assembly: AssemblyCopyright("Copyright © 2017 Sergey V. Zhdanovskih")]
11 | [assembly: AssemblyTrademark("")]
12 | [assembly: AssemblyCulture("")]
13 | [assembly: ComVisible(false)]
14 | [assembly: AssemblyVersion("1.0.0.0")]
15 |
--------------------------------------------------------------------------------
/WCCTagsExtractor/WCCTagsExtractor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {2ABDE4E8-757E-4E63-A802-D65F9275709B}
5 | {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
6 | Debug
7 | AnyCPU
8 | WinExe
9 | WCCTagsExtractor
10 | WCCTagsExtractor
11 | v4.5
12 | Properties
13 |
14 |
15 |
16 | x86
17 |
18 |
19 | bin\Debug\
20 | True
21 | Full
22 | False
23 | True
24 | DEBUG;TRACE
25 |
26 |
27 | bin\Release\
28 | False
29 | None
30 | True
31 | False
32 | TRACE
33 |
34 |
35 |
36 | ..\BSLib.dll
37 |
38 |
39 | libs\OpenMcdf.dll
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | 3.5
48 |
49 |
50 |
51 |
52 |
53 | MainForm.cs
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | MainForm.cs
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/WCCTagsExtractor/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/clean.cmd:
--------------------------------------------------------------------------------
1 | rmdir .\.vs /s /q
2 |
3 | rmdir .\RSVTagsExtractor\bin /s /q
4 | rmdir .\RSVTagsExtractor\obj /s /q
5 |
6 | rmdir .\WCCTagsExtractor\bin /s /q
7 | rmdir .\WCCTagsExtractor\obj /s /q
8 |
--------------------------------------------------------------------------------
/libs/BSLib.Controls.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/libs/BSLib.Controls.dll
--------------------------------------------------------------------------------
/libs/BSLib.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/libs/BSLib.dll
--------------------------------------------------------------------------------
/libs/OpenMcdf.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/libs/OpenMcdf.dll
--------------------------------------------------------------------------------
/libs/ZedGraph.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/libs/ZedGraph.dll
--------------------------------------------------------------------------------
/libs/nunit.framework.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/libs/nunit.framework.dll
--------------------------------------------------------------------------------
/libs/x64/piapi.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/libs/x64/piapi.dll
--------------------------------------------------------------------------------
/libs/x86/piapi32.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Serg-Norseman/IndustrialToolkit/6ba038011e8099f31054bc1fb15e796faa1cde98/libs/x86/piapi32.dll
--------------------------------------------------------------------------------