241 lines
7.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using DoAn.Core;
using DoAn.Core.global;
using DoAn.Core.UI;
using DoAn.PLC;
using DoAn.servicce;
using DoAn.SugarModels;
using HslCommunication.Profinet.Omron;
using HslCommunication.Profinet.Siemens;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DoAn.UI
{
/// <summary>
/// 公共变量定义类
/// </summary>
public class global
{
/// <summary>
/// 表分页信息
/// </summary>
public static int pageCurrent = 1; //当前页号
public static int pageSize = 100; //每页显示行数
// ============================================================================================================
/// <summary>
/// 测试数据所有表格字段
/// </summary>
public static string tableFiles;
// 关于这里的“字段名称”和数据表中的“字段名称”关系
// datagridview中的字段集合是数据表中的字段集合的子集
/// <summary>
/// datagridview标题定义
/// </summary>
/// title---获取标题名称
/// propery----获取标题字段
/// iArrayWidth----字段宽度
public static string[] HeaderText;
public static string[] PropertyName;
public static bool[] GirdFieldVisible;
public static int[] iArrayWidth;
public static bool ManualAuto = false;
/// <summary>
/// 程序所有相关的配置
/// </summary>
public static AppConfig appConfig = new AppConfig();
public static void InitialInfoAboutGlobal()
{
appConfig.InitialProperty();
appConfig.ReadConfigFromExcel();
global.tableFiles = appConfig.DataFields;
global.HeaderText = appConfig.LstFieldsName.ToArray();
global.PropertyName = appConfig.LstFields.ToArray();
global.iArrayWidth = appConfig.LstFieldsWidth.ToArray();
global.GirdFieldVisible = appConfig.LstFieldsVisible.ToArray();
global.PLCIP = appConfig.PLCIP;
}
/// <summary>
/// 定义
/// </summary>
/// MaterialAllName---扫到的所有物料名称
/// MaterialCodeAll---扫到的所有物料条码
/// ScanCode---当前扫的内容
public static string MaterialAllName = string.Empty;
public static string MaterialCodeAll = string.Empty;
public static string ScanCode = string.Empty;
// ============================================================================================================
/// <summary>
/// 串口通讯相关
/// </summary>
/// sendOpenData---打开串口
/// sendCloseData---关闭串口
public static byte[] sendOpenData = new byte[] { 0x00, 0x16, 0x54, 0x0D };
public static byte[] sendCloseData = new byte[] { 0x00, 0x16, 0x55, 0x0D };
// ============================================================================================================
/// <summary>
/// PLC相关
/// </summary>
/// PlcName---PLC名称
/// PLCIP---PLC IP地址
/// blockValue---获取PLC数据数组
/// PlcAddr---获取所有PLC寄存器地址
/// PLCArr--PLC地址分割成数组
public static string PlcAddr;
public static string[] PlcAddrArr;
public static string[] PLCArr;
public static string PlcName;
public static string[] PlcNameArr;
public static string PLCIP;
public static void InitialInfoAboutPLC()
{
//global.PlcAddr = inifile.ContentReader("CurrentStation", "PLC-Addr", "", appConfig.AppConfigPath);
//global.PlcAddrArr = global.PlcAddr.Split(new char[] { ';' });
//global.PLCArr = global.PlcAddrArr[0].Split(new char[] { ',' });
//global.PlcName = inifile.ContentReader("CurrentStation", "PLC-Name", "", appConfig.AppConfigPath);
//global.PlcNameArr = global.PlcName.Split(new char[] { ',' });
}
// ============================================================================================================
// 产品类型
public static ProductManager productManager = null;
public static void InitialProductType(UIComboBox cmbx, string[] lst)
{
if (productManager == null) productManager = new ProductManager(appConfig.ProductTypePath);
else productManager.ClearProductInfo();
productManager.ReadProductInfo();
//cmbx.Items.AddRange(productManager.GetProductNameList());
cmbx.BeginInvoke(new MethodInvoker(() =>
{
if(lst!=null)
{
cmbx.Items.Clear();
cmbx.Items.AddRange(lst);
}
}));
//cmbx.SelectedIndex = 0;
}
public static NewProductItem ProductCodeFromName(string name)
{
return productManager.FindProductByName(name);
}
public static double[] ProductParasFromName(string name)
{
return productManager.GetProductParas(name);
}
// ==========================================================
//
//
// 产量统计
//
public static int StatisticsOksLeft = 0;
public static int StatisticsNgsLeft = 0;
public static int StatisticsOksRight = 0;
public static int StatisticsNgsRight = 0;
public static bool HeartAction = false;
public static double ValueA100;
public static double ValueA101;
public static string ScanContent = string.Empty;
public static string TypeSelect = string.Empty;
public static bool AppLoadDone = false;
public static int InputState = 0;
public static bool AutoMode = false;
public static ushort AutoFlow = 0;
public static ushort AutoFlow2 = 0;
public static ushort HighLow = 0;
// 实时螺丝可数1
public static string LsValue01 = "0";
// 实时螺丝颗数2
public static string LsValue02 = "0";
// 设置螺丝颗数1
public static string LsValue03 = "0";
// 设置螺丝颗数2
public static string LsValue04 = "0";
// 设置螺丝颗数3
public static string LsValue05 = "0";
// 当前选择产品对象
public static NewProductItem curProductItem = null;
public static double[] dataManualSetValue = new double[20];
public static double[] dataManualReadValue = new double[20];
public static bool reReadPartList = false;
// ==========================================================
//
//
// 新增的变量 2023-09-01
//
public static string tipMsg = "-";
public static string CurrentProject = "-";
public static string CurrentStation = "-";
public static string CurrentLineName = "-";
public static string PreFCStation = "-1";
public static bool isPrint = false;
// 暂存变量
public static bool checkEndIsRework = false;
// 当前配置
public static ResGeelyAssemblyPart curAssemblyPart = null;
public static string currentPartSelect = string.Empty;
public static string currentPartColor = string.Empty;
public static bool disableStation = false;
public static int writeProgramID = 0;
public static int readProgramID = 0;
public static int ProjectType = 0;
}
}