123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- 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<string> listPLC_IniIO = new List<string>();
- public static Dictionary<string, PLCInitIO> dictPLC_InitIO = new Dictionary<string, PLCInitIO>();
- public static List<string> listPLC_M01M02Alm = new List<string>();
- public static Dictionary<string,ClsAlm> dictM01M02_Alm = new Dictionary<string,ClsAlm>();
- public static List<string> listPLC_M03Alm = new List<string>();
- public static Dictionary<string, ClsAlm> dictM03_Alm = new Dictionary<string, ClsAlm>();
- public static List<string> listPLC_M04M05Alm = new List<string>();
- public static Dictionary<string, ClsAlm> dictM04M05_Alm = new Dictionary<string, ClsAlm>();
- //public static List<string> listM03_IniIO = new List<string>();
- //public static Dictionary<string, PLCInitIO> dictM03_InitIO = new Dictionary<string, PLCInitIO>();
- //public static List<string> listM04M05_IniIO = new List<string>();
- //public static Dictionary<string, PLCInitIO> dictM04M05_InitIO = new Dictionary<string, PLCInitIO>();
- //M01M02
- public static List<string> listM01M02_上料工位 = new List<string>();
- public static List<string> listM01M02_取出工位 = new List<string>();
- public static List<string> listM01M02_提升机工位 = new List<string>();
- public static List<string> listM01M02_称重工位 = new List<string>();
- public static List<string> listM01M02_出口工位 = new List<string>();
- public static Dictionary<string, ClsPLCIO> dictM01M02_上料工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM01M02_取出工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM01M02_提升机工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM01M02_称重工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM01M02_出口工位 = new Dictionary<string, ClsPLCIO>();
-
- //M03
- public static List<string> listM03_整平工位 = new List<string>();
- public static List<string> listM03_装冲工位 = new List<string>();
- public static List<string> listM03_压合工位 = new List<string>();
- public static List<string> listM03_清洗工位 = new List<string>();
- public static List<string> listM03_下流线工位 = new List<string>();
- public static List<string> listM03_出料口工位 = new List<string>();
- public static Dictionary<string, ClsPLCIO> dictM03_整平工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM03_装冲工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM03_压合工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM03_清洗工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM03_下流线工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM03_出料口工位 = new Dictionary<string, ClsPLCIO>();
- //M04M05
- public static List<string> listM04M05_ST0进口门工位 = new List<string>();
- public static List<string> listM04M05_取出工位 = new List<string>();
- public static List<string> listM04M05_清洗工位 = new List<string>();
- public static List<string> listM04M05_提升机工位 = new List<string>();
- public static List<string> listM04M05_测量工位 = new List<string>();
- public static List<string> listM04M05_装盘工位 = new List<string>();
- public static List<string> listM04M05_出盘工位 = new List<string>();
- public static List<string> listM04M05_下流线工位 = new List<string>();
- public static List<string> listM04M05_下料站工位 = new List<string>();
- public static Dictionary<string, ClsPLCIO> dictM04M05_ST0进口门工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM04M05_取出工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM04M05_清洗工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM04M05_提升机工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM04M05_测量工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM04M05_装盘工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM04M05_出盘工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM04M05_下流线工位 = new Dictionary<string, ClsPLCIO>();
- public static Dictionary<string, ClsPLCIO> dictM04M05_下料站工位 = new Dictionary<string, ClsPLCIO>();
- 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);
- }
- }
- }
- }
|