chore: 初始化合力差速器MES采集程序

This commit is contained in:
yexingqiang
2026-06-08 10:59:21 +08:00
commit 1591062eef
1379 changed files with 181389 additions and 0 deletions

View File

@@ -0,0 +1,103 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MisDataName
{
class FunctionForm_HashiTable
{
public static Hashtable OpName_Hash = new Hashtable();
public static object OpName_Hash_Read(string Key)
{
if (OpName_Hash.ContainsKey(Key))
{
return OpName_Hash[Key];
}
else
{
return null;
}
}
public static void OpName_Hash_Write(string Key, object obj)
{
if (OpName_Hash.ContainsKey(Key))
{
OpName_Hash[Key] = obj;
}
else
{
OpName_Hash.Add(Key, obj);
}
}
public static Hashtable SignalName = new Hashtable();
public static string SignalName_Hash_Read(string Key)
{
if (SignalName.ContainsKey(Key))
{
return SignalName[Key].ToString ();
}
else
{
return null;
}
}
public static void SignalName_Hash_Write(string Key, string str)
{
if (SignalName.ContainsKey(Key))
{
SignalName[Key] = str;
}
else
{
SignalName.Add(Key, str);
}
}
public static Hashtable SignalConfig = new Hashtable();
public static object SignalConfig_Hash_Read(string Key)
{
if (SignalConfig.ContainsKey(Key))
{
return SignalConfig[Key];
}
else
{
return null;
}
}
public static void SignalConfig_Write(string Key, object str)
{
if (SignalConfig.ContainsKey(Key))
{
SignalConfig[Key] = str;
}
else
{
SignalConfig.Add(Key, str);
}
}
}
}

View File

@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SystemFramework;
namespace MisDataName
{
public partial class SecondForm
{
void InitMainSignalEvent()
{
MisData.PlcChange = new PlcChangeEvent(MainSignalChange);
}
void MainSignalChange(OpcData.CustomeEvetnArgs msgEvent)
{
try
{
int tagType;
string opName, tagValue;
if (msgEvent.TagValue == null) return;
tagType = Convert.ToInt32(msgEvent.TagType);
opName = msgEvent.OpName.ToString();
switch (Convert.ToInt32(msgEvent.TagValueType))
{
case 11:
tagValue = (Convert.ToInt32(msgEvent.TagValue)).ToString();
break;
default:
tagValue = msgEvent.TagValue.ToString();
break;
}
if (Convert.ToInt32(msgEvent.TagValueType)==11)
{
WriteWorkStationSignal(opName, tagType.ToString(), Convert.ToBoolean(Convert.ToInt32(tagValue)));
}
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Message);
}
}
}
}

View File

@@ -0,0 +1,138 @@
using MesControl;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using SystemFramework;
namespace MisDataName
{
public delegate void ControlConnectPLC();
public partial class SecondForm
{
ControlConnectPLC PlcConnectTimer;
void InitFormDynamicControls()
{
try
{
// DataTable dt_OpName=(DataTable) FunctionForm_HashiTable.OpName_Hash_Read("OpNameList");
List<MesBoolSignal> signalItems = InitWorkStationSignal();
RecordWorkStationSignal(signalItems);
int RowsWidth = SignalPanel.Width-20;
int RowsNum = RowsWidth / 133;
int i = 0;
foreach (var opName in MesWork.PlcLinkForm.opNameList)
{
PlcWorkStationSignal plcWorkStationSignal = new PlcWorkStationSignal();
plcWorkStationSignal.BackColor = System.Drawing.Color.Transparent;
plcWorkStationSignal.Location = new System.Drawing.Point(3 + ((i % RowsNum) * 133), (i / RowsNum) * ((signalItems.Count * 25) + 60));
plcWorkStationSignal.MaximumSize = new System.Drawing.Size(0, 0);
plcWorkStationSignal.MinimumSize = new System.Drawing.Size(0, 0);
plcWorkStationSignal.Name = "plcWorkStationSignal_" + opName;
plcWorkStationSignal.Size = new System.Drawing.Size(136, 60);
plcWorkStationSignal.TabIndex = i;
plcWorkStationSignal.SignalItems = signalItems;
plcWorkStationSignal.WorkStationNameText = opName;
plcWorkStationSignal.WS_PlcLabelText = "PLC连接";
plcWorkStationSignal.TestPLC_Interval = 10000;
plcWorkStationSignal.TestPLC_Enable = true;
PlcConnectTimer += plcWorkStationSignal.ExternalTimerExcute;
this.SignalPanel.Controls.Add(plcWorkStationSignal);
i++;
}
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Message);
}
}
public List<MesBoolSignal> InitWorkStationSignal()
{
try
{
List<MesBoolSignal> signalItems = new List<MesBoolSignal>();
MesBoolSignal MBS;
signalItems.Clear();
XDocument SystemConfig = XDocument.Load("SystemConfig.xml");
IEnumerable<XElement> plc = SystemConfig.Descendants ("PLC");
IEnumerable<XElement> plcSignal = plc.Elements();
foreach (XElement PlcSignal in plcSignal)
{
XElement Name = PlcSignal.Element("Name");
XElement TagType = PlcSignal.Element("TagType");
XElement Text = PlcSignal.Element("Text");
XElement Index = PlcSignal.Element("Index");
XElement Enabled = PlcSignal.Element("Enabled");
MBS = new MesBoolSignal();
MBS.Name = "TagType_" + TagType.Value ;
MBS.SignalText = Text.Value ;
MBS.SignalImage = MesBoolSignal.SignalImage_Enum.none;
if (Convert.ToBoolean(Enabled.Value))
{
signalItems.Add(MBS);
}
}
IEnumerable<XElement> mes = SystemConfig.Descendants("MES");
IEnumerable<XElement> mesSignal = mes.Elements();
foreach (XElement MesSignal in mesSignal)
{
XElement Name = MesSignal.Element("Name");
XElement TagType = MesSignal.Element("TagType");
XElement Text = MesSignal.Element("Text");
XElement Index = MesSignal.Element("Index");
XElement Enabled = MesSignal.Element("Enabled");
MBS = new MesBoolSignal();
MBS.Name = "TagType_" + TagType.Value;
MBS.SignalText = Text.Value;
MBS.SignalImage = MesBoolSignal.SignalImage_Enum.none;
if (Convert .ToBoolean ( Enabled .Value))
{
signalItems.Add(MBS);
}
}
return signalItems;
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Message);
return null;
}
}
string[] SignalNames = new string[50];
void RecordWorkStationSignal(List<MesBoolSignal> items)
{
for (int i=0;i< items.Count;i++)
{
SignalNames[i] = items[i].Name;
}
}
}
}

View File

@@ -0,0 +1,91 @@
namespace MisDataName
{
partial class SecondForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.SignalPanel = new System.Windows.Forms.Panel();
this.groupBox_PlcSignal = new System.Windows.Forms.GroupBox();
this.timer_ControlInternalChange = new System.Windows.Forms.Timer(this.components);
this.groupBox_PlcSignal.SuspendLayout();
this.SuspendLayout();
//
// SignalPanel
//
this.SignalPanel.AutoScroll = true;
this.SignalPanel.Location = new System.Drawing.Point(6, 20);
this.SignalPanel.Name = "SignalPanel";
this.SignalPanel.Size = new System.Drawing.Size(706, 650);
this.SignalPanel.TabIndex = 0;
//
// groupBox_PlcSignal
//
this.groupBox_PlcSignal.Controls.Add(this.SignalPanel);
this.groupBox_PlcSignal.Location = new System.Drawing.Point(12, 12);
this.groupBox_PlcSignal.Name = "groupBox_PlcSignal";
this.groupBox_PlcSignal.Size = new System.Drawing.Size(718, 676);
this.groupBox_PlcSignal.TabIndex = 1;
this.groupBox_PlcSignal.TabStop = false;
this.groupBox_PlcSignal.Text = "LineStatus";
//
// timer_ControlInternalChange
//
this.timer_ControlInternalChange.Enabled = true;
this.timer_ControlInternalChange.Interval = 400;
this.timer_ControlInternalChange.Tick += new System.EventHandler(this.timer_ControlInternalChange_Tick);
//
// SecondForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(741, 700);
this.Controls.Add(this.groupBox_PlcSignal);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(757, 738);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(757, 738);
this.Name = "SecondForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "PlcSignal";
this.TopMost = true;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SecondForm_FormClosing);
this.LocationChanged += new System.EventHandler(this.SecondForm_LocationChanged);
this.groupBox_PlcSignal.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel SignalPanel;
private System.Windows.Forms.GroupBox groupBox_PlcSignal;
private System.Windows.Forms.Timer timer_ControlInternalChange;
}
}

View File

@@ -0,0 +1,231 @@
using MesControl;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SystemFramework;
namespace MisDataName
{
public partial class SecondForm : Form
{
public SecondForm(Point Position)
{
InitializeComponent();
InitFormDynamicControls();
InitMainSignalEvent();
FormPositionInit(Position);
InitOtherFormAction();
SyncForm_Init();
}
Form MainForm;
public SecondForm(object mainForm)
{
MainForm = (Form)mainForm;
InitializeComponent();
InitFormDynamicControls();
InitMainSignalEvent();
Point Position = new Point(MainForm.Left + MainForm.Width, MainForm.Top);
FormPositionInit(Position);
InitOtherFormAction();
SyncForm_Init();
}
void WorkStation_RefreshWorkStationStatus(string OpName, bool value)
{
try
{
PlcWorkStationSignal plcWorkStationSignal = (PlcWorkStationSignal)Controls.Find("plcWorkStationSignal_" + OpName, true)[0];
plcWorkStationSignal.PlcConnectStatusChange(value);
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Message);
}
}
void WriteWorkStationSignal(string OpName,string SignalName,bool value)
{
try
{
if (Array.IndexOf(SignalNames, "TagType_"+SignalName)!=-1)
{
PlcWorkStationSignal plcWorkStationSignal = (PlcWorkStationSignal)Controls.Find("plcWorkStationSignal_" + OpName, true)[0];
plcWorkStationSignal.SignalChange("TagType_"+SignalName, value);
if (SignalName=="14")
{
WorkStation_RefreshWorkStationStatus(OpName, value);
}
}
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Message);
}
}
private void SecondForm_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
MisData.PlcChange =null;
if (MisData.SyncSecondForm != null)
{
SyncForm_Cancel();
}
CancelOtherFormAction();
MainForm.BeginInvoke(MainMenuRefresh, "ToolStripMenuItem_VWSStatus");
this.Dispose();
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Message);
}
}
void SyncForm_Init()
{
try
{
MisData.SyncSecondForm = new SyncOtherForm(FormSync);
MisData.MainFormActive = new MisDataName.SyncOtherForm(MainFormActive);
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Message);
}
}
void SyncForm_Cancel()
{
MisData.SyncSecondForm = null;
MisData.MainFormActive = null;
}
void FormPositionInit(Point Position)
{
try
{
this.Location = (Point)new Size(Position);
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Message);
}
}
void FormSync(object Position)
{
try
{
this.Location = (Point)Position;
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Message);
}
}
void MainFormActive(object obj)
{
if(Convert .ToBoolean (obj ))
{
this.TopMost = true;
this.TopMost = false;
}
}
void InitOtherFormAction()
{
try
{
MisData.SecondFormClose = new MainAct(this.Close);
MisData.OtherFormHide = new MainAct(HideThisForm);
MisData.OtherFormShow = new MainAct(ShowThisForm);
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Message);
}
}
void CancelOtherFormAction()
{
MisData.SecondFormClose = null;
MisData.OtherFormHide = null;
MisData.OtherFormShow = null;
}
void ShowThisForm()
{
this.Show();
this.WindowState = FormWindowState.Normal;
}
void HideThisForm()
{
this.Hide();
}
private void SecondForm_LocationChanged(object sender, EventArgs e)
{
try
{
Point MainPosation=(Point)MisData.QueryMainFormPosition(null);
if(Math.Abs ( MainPosation .X -this .Left)<25&& Math.Abs(MainPosation.Y - this.Top ) < 20)
{
if (MisData.SyncSecondForm == null)
{
SyncForm_Init();
MainForm.Invoke(MisData.MainActived);
FormSync(MainPosation);
}
}
else
{
if (MisData.SyncSecondForm != null)
{
SyncForm_Cancel();
}
}
}
catch (Exception err)
{
ApplicationLog.WriteLog(err, err.Message);
}
}
private void timer_ControlInternalChange_Tick(object sender, EventArgs e)
{
if(PlcConnectTimer!=null)
{
PlcConnectTimer();
}
}
}
}

View File

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

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MisDataName
{
public delegate void SecondAct(string ControlName);
public partial class SecondForm
{
public static SecondAct MainMenuRefresh;
}
}

Binary file not shown.