using BaseLibRWFile; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace HRT_Measure { public class PLCCylinder { public static List listPLC_IniIO = new List(); public static Dictionary dictPLC_InitIO = new Dictionary(); public static List listPLC_M01M02Alm = new List(); public static Dictionary dictM01M02_Alm = new Dictionary(); public static List listPLC_M03Alm = new List(); public static Dictionary dictM03_Alm = new Dictionary(); public static List listPLC_M04M05Alm = new List(); public static Dictionary dictM04M05_Alm = new Dictionary(); //public static List listM03_IniIO = new List(); //public static Dictionary dictM03_InitIO = new Dictionary(); //public static List listM04M05_IniIO = new List(); //public static Dictionary dictM04M05_InitIO = new Dictionary(); //M01M02 public static List listM01M02_上料工位 = new List(); public static List listM01M02_取出工位 = new List(); public static List listM01M02_提升机工位 = new List(); public static List listM01M02_称重工位 = new List(); public static List listM01M02_出口工位 = new List(); public static Dictionary dictM01M02_上料工位 = new Dictionary(); public static Dictionary dictM01M02_取出工位 = new Dictionary(); public static Dictionary dictM01M02_提升机工位 = new Dictionary(); public static Dictionary dictM01M02_称重工位 = new Dictionary(); public static Dictionary dictM01M02_出口工位 = new Dictionary(); //M03 public static List listM03_整平工位 = new List(); public static List listM03_装冲工位 = new List(); public static List listM03_压合工位 = new List(); public static List listM03_清洗工位 = new List(); public static List listM03_下流线工位 = new List(); public static List listM03_出料口工位 = new List(); public static Dictionary dictM03_整平工位 = new Dictionary(); public static Dictionary dictM03_装冲工位 = new Dictionary(); public static Dictionary dictM03_压合工位 = new Dictionary(); public static Dictionary dictM03_清洗工位 = new Dictionary(); public static Dictionary dictM03_下流线工位 = new Dictionary(); public static Dictionary dictM03_出料口工位 = new Dictionary(); //M04M05 public static List listM04M05_ST0进口门工位 = new List(); public static List listM04M05_取出工位 = new List(); public static List listM04M05_清洗工位 = new List(); public static List listM04M05_提升机工位 = new List(); public static List listM04M05_测量工位 = new List(); public static List listM04M05_装盘工位 = new List(); public static List listM04M05_出盘工位 = new List(); public static List listM04M05_下流线工位 = new List(); public static List listM04M05_下料站工位 = new List(); public static Dictionary dictM04M05_ST0进口门工位 = new Dictionary(); public static Dictionary dictM04M05_取出工位 = new Dictionary(); public static Dictionary dictM04M05_清洗工位 = new Dictionary(); public static Dictionary dictM04M05_提升机工位 = new Dictionary(); public static Dictionary dictM04M05_测量工位 = new Dictionary(); public static Dictionary dictM04M05_装盘工位 = new Dictionary(); public static Dictionary dictM04M05_出盘工位 = new Dictionary(); public static Dictionary dictM04M05_下流线工位 = new Dictionary(); public static Dictionary dictM04M05_下料站工位 = new Dictionary(); public static Ini newIni; #region Cylinder public static void GetM01M02Add() { newIni = new Ini(Application.StartupPath + "\\Config\\PLCAddressM01M02.ini"); int count上料工位 = Convert.ToInt32(newIni.ReadIni("System", "上料工位Count", "20")); int count取出工位 = Convert.ToInt32(newIni.ReadIni("System", "取出工位Count", "20")); int count提升机工位 = Convert.ToInt32(newIni.ReadIni("System", "提升机工位Count", "20")); int count称重工位 = Convert.ToInt32(newIni.ReadIni("System", "称重工位Count", "20")); int count出口工位 = Convert.ToInt32(newIni.ReadIni("System", "出口工位Count", "20")); for (int i = 0; i < count上料工位; i++) { string str = newIni.ReadIni("上料工位手动", (i + 1).ToString(), "20"); listM01M02_上料工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M01M02", str); dictM01M02_上料工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count取出工位; i++) { string str = newIni.ReadIni("取出工位手动", (i + 1).ToString(), "20"); listM01M02_取出工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M01M02", str); dictM01M02_取出工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count提升机工位; i++) { string str = newIni.ReadIni("提升机工位手动", (i + 1).ToString(), "20"); listM01M02_提升机工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M01M02", str); dictM01M02_提升机工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count称重工位; i++) { string str = newIni.ReadIni("称重工位手动", (i + 1).ToString(), "20"); listM01M02_称重工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M01M02", str); dictM01M02_称重工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count出口工位; i++) { string str = newIni.ReadIni("出口工位手动", (i + 1).ToString(), "20"); listM01M02_出口工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M01M02", str); dictM01M02_出口工位.Add(str.Split(',')[0], clsPLCIO); } } public static void GetM03Add() { newIni = new Ini(Application.StartupPath + "\\Config\\PLCAddressM03.ini"); int count整平工位 = Convert.ToInt32(newIni.ReadIni("System", "整平工位Count", "20")); int count装冲工位 = Convert.ToInt32(newIni.ReadIni("System", "装冲工位Count", "20")); int count压合工位 = Convert.ToInt32(newIni.ReadIni("System", "压合工位Count", "20")); int count清洗工位 = Convert.ToInt32(newIni.ReadIni("System", "清洗工位Count", "20")); int count下流线工位 = Convert.ToInt32(newIni.ReadIni("System", "下流线工位Count", "20")); int count出料口工位 = Convert.ToInt32(newIni.ReadIni("System", "出料口工位Count", "20")); for (int i = 0; i < count整平工位; i++) { string str = newIni.ReadIni("整平工位手动", (i + 1).ToString(), "20"); listM03_整平工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M03", str); dictM03_整平工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count装冲工位; i++) { string str = newIni.ReadIni("装冲工位手动", (i + 1).ToString(), "20"); listM03_装冲工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M03", str); dictM03_装冲工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count压合工位; i++) { string str = newIni.ReadIni("压合工位手动", (i + 1).ToString(), "20"); listM03_压合工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M03", str); dictM03_压合工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count清洗工位; i++) { string str = newIni.ReadIni("清洗工位手动", (i + 1).ToString(), "20"); listM03_清洗工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M03", str); dictM03_清洗工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count下流线工位; i++) { string str = newIni.ReadIni("下流线工位手动", (i + 1).ToString(), "20"); listM03_下流线工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M03", str); dictM03_下流线工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count出料口工位; i++) { string str = newIni.ReadIni("出料口工位手动", (i + 1).ToString(), "20"); listM03_出料口工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M03", str); dictM03_出料口工位.Add(str.Split(',')[0], clsPLCIO); } } public static void GetM04M05Add() { newIni = new Ini(Application.StartupPath + "\\Config\\PLCAddressM04M05.ini"); int countST0进口门工位 = Convert.ToInt32(newIni.ReadIni("System", "ST0进口门工位Count", "20")); int count取出工位 = Convert.ToInt32(newIni.ReadIni("System", "取出工位Count", "20")); int count清洗工位 = Convert.ToInt32(newIni.ReadIni("System", "清洗工位Count", "20")); int count提升机工位 = Convert.ToInt32(newIni.ReadIni("System", "提升机工位Count", "20")); int count测量工位 = Convert.ToInt32(newIni.ReadIni("System", "测量工位Count", "20")); int count装盘工位 = Convert.ToInt32(newIni.ReadIni("System", "装盘工位Count", "20")); int count出盘工位 = Convert.ToInt32(newIni.ReadIni("System", "出盘工位Count", "20")); int count下流线工位 = Convert.ToInt32(newIni.ReadIni("System", "下流线工位Count", "20")); int count下料站工位 = Convert.ToInt32(newIni.ReadIni("System", "下料站工位Count", "20")); for (int i = 0; i < countST0进口门工位; i++) { string str = newIni.ReadIni("ST0进口门工位手动", (i + 1).ToString(), "20"); listM04M05_ST0进口门工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M04M05", str); dictM04M05_ST0进口门工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count取出工位; i++) { string str = newIni.ReadIni("取出工位手动", (i + 1).ToString(), "20"); listM04M05_取出工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M04M05", str); dictM04M05_取出工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count清洗工位; i++) { string str = newIni.ReadIni("清洗工位手动", (i + 1).ToString(), "20"); listM04M05_清洗工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M04M05", str); dictM04M05_清洗工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count提升机工位; i++) { string str = newIni.ReadIni("提升机工位手动", (i + 1).ToString(), "20"); listM04M05_提升机工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M04M05", str); dictM04M05_提升机工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count测量工位; i++) { string str = newIni.ReadIni("测量工位手动", (i + 1).ToString(), "20"); listM04M05_测量工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M04M05", str); dictM04M05_测量工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count装盘工位; i++) { string str = newIni.ReadIni("装盘工位手动", (i + 1).ToString(), "20"); listM04M05_装盘工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M04M05", str); dictM04M05_装盘工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count出盘工位; i++) { string str = newIni.ReadIni("出盘工位手动", (i + 1).ToString(), "20"); listM04M05_出盘工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M04M05", str); dictM04M05_出盘工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count下流线工位; i++) { string str = newIni.ReadIni("下流线工位手动", (i + 1).ToString(), "20"); listM04M05_下流线工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M04M05", str); dictM04M05_下流线工位.Add(str.Split(',')[0], clsPLCIO); } for (int i = 0; i < count下料站工位; i++) { string str = newIni.ReadIni("下料站工位手动", (i + 1).ToString(), "20"); listM04M05_下料站工位.Add(str); ClsPLCIO clsPLCIO = new ClsPLCIO("M04M05", str); dictM04M05_下料站工位.Add(str.Split(',')[0], clsPLCIO); } } #endregion public static void GetInitIO() { //strHandOrAuto = "DB20.494.5"; //strInitDone = "DB48.24.4"; //strWait = "DB20.495.1"; //strAutoRunning = "DB20.495.2"; //strAlm = "DB20.495.0"; //初始化按钮,异常消除按钮,停止按钮,启动按钮,手动模式, string strIOM01M02 = "DB20.494.5,DB48.24.4,DB20.495.1,DB20.495.2,DB20.495.0,DB48.25.3,DB20.494.2,DB20.494.4,DB48.24.0,DB20.494.5"; listPLC_IniIO.Add(strIOM01M02); PLCInitIO pLCInitIOM01M02 = new PLCInitIO("M01M02", strIOM01M02); dictPLC_InitIO.Add("M01M02", pLCInitIOM01M02); //strHandOrAuto = "DB20.4.5"; //strInitDone = "DB48.24.4"; //strWait = "DB20.5.1"; //strAutoRunning = "DB20.5.2"; //strAlm = "DB20.5.0"; string strIOM03 = "DB20.4.5,DB48.24.4,DB20.5.1,DB20.5.2,DB20.5.0,DB48.25.3,DB20.4.2,DB20.4.4,DB48.24.0,DB20.4.5"; listPLC_IniIO.Add(strIOM03); PLCInitIO pLCInitIOM03 = new PLCInitIO("M03", strIOM03); dictPLC_InitIO.Add("M03", pLCInitIOM03); //strHandOrAuto = "DB20.0.5"; //strInitDone = "DB48.24.4"; //strWait = "DB20.1.1"; //strAutoRunning = "DB20.1.2"; //strAlm = "DB20.1.0"; string strIOM04M05 = "DB20.0.5,DB48.24.4,DB20.1.1,DB20.1.2,DB20.1.0,DB48.25.3,DB20.0.2,DB20.0.4,DB48.24.0,DB48.24.3,"; listPLC_IniIO.Add(strIOM04M05); PLCInitIO pLCInitIOM04M05 = new PLCInitIO("M04M05", strIOM04M05); dictPLC_InitIO.Add("M04M05", pLCInitIOM04M05); } public static void GetAlm() { newIni = new Ini(Application.StartupPath + "\\Config\\PLCAlmM01M02.ini"); int countM01M02 = Convert.ToInt32(newIni.ReadIni("System", "Count", "20")); for (int i = 0; i < countM01M02; i++) { string str = newIni.ReadIni("报警", (i + 1).ToString(), "20"); listPLC_M01M02Alm.Add(str); ClsAlm clsAlm = new ClsAlm("M01M02", str); dictM01M02_Alm.Add(str.Split(',')[0], clsAlm); } newIni = new Ini(Application.StartupPath + "\\Config\\PLCAlmM03.ini"); int countM03 = Convert.ToInt32(newIni.ReadIni("System", "Count", "20")); for (int i = 0; i < countM03; i++) { string str = newIni.ReadIni("报警", (i + 1).ToString(), "20"); listPLC_M03Alm.Add(str); ClsAlm clsAlm = new ClsAlm("M03", str); dictM03_Alm.Add(str.Split(',')[0], clsAlm); } newIni = new Ini(Application.StartupPath + "\\Config\\PLCAlmM04M05.ini"); int countM04M05 = Convert.ToInt32(newIni.ReadIni("System", "Count", "20")); for (int i = 0; i < countM04M05; i++) { string str = newIni.ReadIni("报警", (i + 1).ToString(), "20"); listPLC_M04M05Alm.Add(str); ClsAlm clsAlm = new ClsAlm("M04M05", str); dictM04M05_Alm.Add(str.Split(',')[0], clsAlm); } } } }