using System;
|
using System.Collections.Generic;
|
using System.Reflection;
|
using System.Threading;
|
using System.Windows.Forms;
|
|
namespace SHARP_CLAS_UI.Screen
|
{
|
public partial class Form_Maintenance_IO : Form
|
{
|
Form_Frame _Parent;
|
|
List<uc_Input_Vlaue> Inputs = new List<uc_Input_Vlaue>();
|
List<uc_Input_Vlaue> Input_1 = new List<uc_Input_Vlaue>();
|
List<uc_Input_Vlaue> Input_2 = new List<uc_Input_Vlaue>();
|
List<uc_Input_Vlaue> Input_3 = new List<uc_Input_Vlaue>();
|
List<uc_Input_Vlaue> Input_4 = new List<uc_Input_Vlaue>();
|
List<uc_Input_Vlaue> Input_5 = new List<uc_Input_Vlaue>();
|
List<uc_Input_Vlaue> Input_6 = new List<uc_Input_Vlaue>();
|
List<uc_Input_Vlaue> Input_7 = new List<uc_Input_Vlaue>();
|
List<uc_Input_Vlaue> Input_8 = new List<uc_Input_Vlaue>();
|
List<uc_Input_Vlaue> Input_9 = new List<uc_Input_Vlaue>();
|
List<uc_Input_Vlaue> Input_10 = new List<uc_Input_Vlaue>();
|
List<uc_Input_Vlaue> Input_11 = new List<uc_Input_Vlaue>();
|
List<uc_Input_Vlaue> Input_12 = new List<uc_Input_Vlaue>();
|
|
List<uc_Output_Vlaue> Outputs = new List<uc_Output_Vlaue>();
|
List<uc_Output_Vlaue> Output_1 = new List<uc_Output_Vlaue>();
|
List<uc_Output_Vlaue> Output_2 = new List<uc_Output_Vlaue>();
|
List<uc_Output_Vlaue> Output_3 = new List<uc_Output_Vlaue>();
|
List<uc_Output_Vlaue> Output_4 = new List<uc_Output_Vlaue>();
|
List<uc_Output_Vlaue> Output_5 = new List<uc_Output_Vlaue>();
|
List<uc_Output_Vlaue> Output_6 = new List<uc_Output_Vlaue>();
|
Thread Data_Update_Th;
|
|
/// <summary>
|
/// colum 425 row 50
|
/// </summary>
|
/// <param name="_parent"></param>
|
public Form_Maintenance_IO(Form_Frame _Parent)
|
{
|
InitializeComponent();
|
this._Parent = _Parent;
|
Init_InputData();
|
Init_OutputData();
|
Data_Update_Th = new Thread(Data_Update_Th_Set);
|
Data_Update_Th.Start();
|
}
|
|
public void Init_InputData()
|
{
|
byte[] input;
|
string[] descriptions = Input_Memory_Address.Get_Name_of_Memory_Address();
|
|
_Parent.sm.Get_SharedMemorybytes(out input, 1000, descriptions.Length);
|
|
if (descriptions.Length % 16 != 0)
|
return;
|
|
int iosplit = 32;
|
int iolength = descriptions.Length / iosplit;
|
|
for (int i = 0; i < iolength; i++)
|
{
|
for (int j = 0; j < iosplit; j++)
|
{
|
string ioname = ((iosplit * i) + j).ToString("X3");
|
Inputs.Add(new uc_Input_Vlaue(ioname, descriptions[(iosplit * i) + j], Convert.ToBoolean(input[(iosplit * i) + j])));
|
}
|
}
|
|
for (int i = 0; i < iolength; i++)
|
{
|
for (int j = 0; j < iosplit; j++)
|
{
|
switch(i)
|
{
|
case 0:
|
{
|
Input_1.Add(Inputs[(iosplit * i) + j]);
|
break;
|
}
|
case 1:
|
{
|
Input_2.Add(Inputs[(iosplit * i) + j]);
|
break;
|
}
|
case 2:
|
{
|
Input_3.Add(Inputs[(iosplit * i) + j]);
|
break;
|
}
|
case 3:
|
{
|
Input_4.Add(Inputs[(iosplit * i) + j]);
|
break;
|
}
|
case 4:
|
{
|
Input_5.Add(Inputs[(iosplit * i) + j]);
|
break;
|
}
|
case 5:
|
{
|
Input_6.Add(Inputs[(iosplit * i) + j]);
|
break;
|
}
|
case 6:
|
{
|
Input_7.Add(Inputs[(iosplit * i) + j]);
|
break;
|
}
|
case 7:
|
{
|
Input_8.Add(Inputs[(iosplit * i) + j]);
|
break;
|
}
|
case 8:
|
{
|
Input_9.Add(Inputs[(iosplit * i) + j]);
|
break;
|
}
|
case 9:
|
{
|
Input_10.Add(Inputs[(iosplit * i) + j]);
|
break;
|
}
|
case 10:
|
{
|
Input_11.Add(Inputs[(iosplit * i) + j]);
|
break;
|
}
|
case 11:
|
{
|
Input_12.Add(Inputs[(iosplit * i) + j]);
|
break;
|
}
|
}
|
}
|
}
|
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_1.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_1[i]);
|
tlp_Input.Controls.Add(Input_1[i + Input_1.Count / 2]);
|
}
|
}
|
|
public void Init_OutputData()
|
{
|
byte[] output;
|
string[] descriptions = Output_Memory_Address.Get_Name_of_Memory_Address();
|
|
_Parent.sm.Get_SharedMemorybytes(out output, 1500, descriptions.Length);
|
|
|
if (descriptions.Length % 16 != 0)
|
return;
|
|
int iosplit = 32;
|
int iolength = descriptions.Length / iosplit;
|
|
int i = 0;
|
foreach(ushort axis in Enum.GetValues(typeof(OutputAxis)))
|
{
|
for (int j = 0; j < iosplit; j++)
|
{
|
string ioname = ((iosplit * i) + j).ToString("X3");
|
uc_Output_Vlaue data = new uc_Output_Vlaue(ioname, descriptions[(iosplit * i) + j], (OutputAxis)axis, j, Convert.ToBoolean(output[(iosplit * i) + j]));
|
data.Add_Click_Event(Output_Click);
|
Outputs.Add(data);
|
}
|
i++;
|
}
|
|
for (i = 0; i < iolength; i++)
|
{
|
for (int j = 0; j < iosplit; j++)
|
{
|
switch (i)
|
{
|
case 0:
|
{
|
Output_1.Add(Outputs[(iosplit * i) + j]);
|
break;
|
}
|
case 1:
|
{
|
Output_2.Add(Outputs[(iosplit * i) + j]);
|
break;
|
}
|
case 2:
|
{
|
Output_3.Add(Outputs[(iosplit * i) + j]);
|
break;
|
}
|
case 3:
|
{
|
Output_4.Add(Outputs[(iosplit * i) + j]);
|
break;
|
}
|
case 4:
|
{
|
Output_5.Add(Outputs[(iosplit * i) + j]);
|
break;
|
}
|
case 5:
|
{
|
Output_6.Add(Outputs[(iosplit * i) + j]);
|
break;
|
}
|
}
|
}
|
}
|
|
tlp_Output.Controls.Clear();
|
|
for (i = 0; i < Output_1.Count / 2; i++)
|
{
|
tlp_Output.Controls.Add(Output_1[i]);
|
tlp_Output.Controls.Add(Output_1[i + Output_1.Count / 2]);
|
}
|
}
|
|
private void Output_Click(object sender, EventArgs e)
|
{
|
Label data = (Label)sender;
|
uc_Output_Vlaue output_value = (uc_Output_Vlaue)data.Parent;
|
|
int row = Convert.ToInt32(output_value.name, 16);
|
OutputData output;
|
Enum.TryParse(Enum.GetName(typeof(OutputData), (object)row), out output);
|
|
_Parent._equip.Board_Control.IO_manager.Set_Output(output, !output_value.status);
|
}
|
|
private void Data_Update_Th_Set()
|
{
|
while (!_Parent.IsDisposed)
|
{
|
Thread.Sleep(10);
|
Data_Update();
|
}
|
}
|
|
private void Data_Update()
|
{
|
try
|
{
|
DateTime dt = DateTime.Now;
|
Update_Input_Data();
|
Update_Output_Data();
|
TimeSpan ts = DateTime.Now - dt;
|
}
|
catch (Exception ex)
|
{
|
_Parent.WriteExceptionLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex);
|
}
|
}
|
|
public void Update_Input_Data()
|
{
|
byte[] input;
|
_Parent.sm.Get_SharedMemorybytes(out input, 1000, Input_Memory_Address.Get_Address_Infos().Length);
|
|
int iolength = input.Length / 32;
|
|
for (int i = 0; i < iolength; i++)
|
{
|
for (int j = 0; j < 32; j++)
|
{
|
bool status = Convert.ToBoolean(input[(32 * i) + j]);
|
Inputs[(32 * i) + j].Change_Status(status);
|
}
|
}
|
}
|
|
public void Update_Output_Data()
|
{
|
byte[] input;
|
_Parent.sm.Get_SharedMemorybytes(out input, 1500, Output_Memory_Address.Get_Address_Infos().Length);
|
|
int iolength = input.Length / 32;
|
|
for (int i = 0; i < iolength; i++)
|
{
|
for (int j = 0; j < 32; j++)
|
{
|
bool status = Convert.ToBoolean(input[(32 * i) + j]);
|
Outputs[(32 * i) + j].Change_Status(status);
|
}
|
}
|
}
|
|
private void btn_In_1_Click(object sender, EventArgs e)
|
{
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_1.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_1[i]);
|
tlp_Input.Controls.Add(Input_1[i + Input_1.Count / 2]);
|
}
|
}
|
|
private void btn_In_2_Click(object sender, EventArgs e)
|
{
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_2.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_2[i]);
|
tlp_Input.Controls.Add(Input_2[i + Input_2.Count / 2]);
|
}
|
}
|
|
private void btn_In_3_Click(object sender, EventArgs e)
|
{
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_3.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_3[i]);
|
tlp_Input.Controls.Add(Input_3[i + Input_3.Count / 2]);
|
}
|
}
|
|
private void btn_In_4_Click(object sender, EventArgs e)
|
{
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_4.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_4[i]);
|
tlp_Input.Controls.Add(Input_4[i + Input_4.Count / 2]);
|
}
|
}
|
|
private void btn_In_5_Click(object sender, EventArgs e)
|
{
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_1.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_5[i]);
|
tlp_Input.Controls.Add(Input_5[i + Input_5.Count / 2]);
|
}
|
}
|
|
private void btn_In_6_Click(object sender, EventArgs e)
|
{
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_6.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_6[i]);
|
tlp_Input.Controls.Add(Input_6[i + Input_6.Count / 2]);
|
}
|
|
}
|
|
private void btn_In_7_Click(object sender, EventArgs e)
|
{
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_1.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_7[i]);
|
tlp_Input.Controls.Add(Input_7[i + Input_7.Count / 2]);
|
}
|
}
|
|
private void btn_In_8_Click(object sender, EventArgs e)
|
{
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_8.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_8[i]);
|
tlp_Input.Controls.Add(Input_8[i + Input_8.Count / 2]);
|
}
|
}
|
|
private void btn_In_9_Click(object sender, EventArgs e)
|
{
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_9.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_9[i]);
|
tlp_Input.Controls.Add(Input_9[i + Input_9.Count / 2]);
|
}
|
}
|
|
private void btn_In_10_Click(object sender, EventArgs e)
|
{
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_1.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_10[i]);
|
tlp_Input.Controls.Add(Input_10[i + Input_10.Count / 2]);
|
}
|
}
|
|
private void btn_In_11_Click(object sender, EventArgs e)
|
{
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_1.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_11[i]);
|
tlp_Input.Controls.Add(Input_11[i + Input_11.Count / 2]);
|
}
|
}
|
|
private void btn_In_12_Click(object sender, EventArgs e)
|
{
|
tlp_Input.Controls.Clear();
|
|
for (int i = 0; i < Input_1.Count / 2; i++)
|
{
|
tlp_Input.Controls.Add(Input_12[i]);
|
tlp_Input.Controls.Add(Input_12[i + Input_12.Count / 2]);
|
}
|
}
|
|
private void btn_Out_1_Click(object sender, EventArgs e)
|
{
|
tlp_Output.Controls.Clear();
|
|
for (int i = 0; i < Output_1.Count / 2; i++)
|
{
|
tlp_Output.Controls.Add(Output_1[i]);
|
tlp_Output.Controls.Add(Output_1[i + Output_1.Count / 2]);
|
}
|
}
|
|
private void btn_Out_2_Click(object sender, EventArgs e)
|
{
|
tlp_Output.Controls.Clear();
|
|
for (int i = 0; i < Output_2.Count / 2; i++)
|
{
|
tlp_Output.Controls.Add(Output_2[i]);
|
tlp_Output.Controls.Add(Output_2[i + Output_2.Count / 2]);
|
}
|
}
|
|
private void btn_Out_3_Click(object sender, EventArgs e)
|
{
|
tlp_Output.Controls.Clear();
|
|
for (int i = 0; i < Output_3.Count / 2; i++)
|
{
|
tlp_Output.Controls.Add(Output_3[i]);
|
tlp_Output.Controls.Add(Output_3[i + Output_3.Count / 2]);
|
}
|
}
|
|
private void btn_Out_4_Click(object sender, EventArgs e)
|
{
|
tlp_Output.Controls.Clear();
|
|
for (int i = 0; i < Output_4.Count / 2; i++)
|
{
|
tlp_Output.Controls.Add(Output_4[i]);
|
tlp_Output.Controls.Add(Output_4[i + Output_4.Count / 2]);
|
}
|
}
|
|
private void btn_Out_5_Click(object sender, EventArgs e)
|
{
|
tlp_Output.Controls.Clear();
|
|
for (int i = 0; i < Output_5.Count / 2; i++)
|
{
|
tlp_Output.Controls.Add(Output_5[i]);
|
tlp_Output.Controls.Add(Output_5[i + Output_5.Count / 2]);
|
}
|
}
|
|
private void btn_Out_6_Click(object sender, EventArgs e)
|
{
|
tlp_Output.Controls.Clear();
|
|
for (int i = 0; i < Output_6.Count / 2; i++)
|
{
|
tlp_Output.Controls.Add(Output_6[i]);
|
tlp_Output.Controls.Add(Output_6[i + Output_6.Count / 2]);
|
}
|
}
|
}
|
}
|