Ejemplo n.º 1
0
        public FileConvertToMachine()
        {
            csvOp         = new CsvStreamReader();
            UserSplitType = new List <sizeLstByDoorType>();
            FormulaType   = new List <sizeFormula>();
            exop          = new ExcelNpoi();
            if (ReadSplitTypeFromCsvData() != 0)
            {
                MessageBox.Show("门型计算数据导入错误!");
            }

            valCol = new Dictionary <string, int>();

            valCol.Add("总序号", 0);
            valCol.Add("生产总编号", 1);
            valCol.Add("分厂日期", 3);
            valCol.Add("材质", 4);
            valCol.Add("序号", 5);
            valCol.Add("产品名称", 6);
            valCol.Add("高", 7);
            valCol.Add("宽", 8);
            valCol.Add("厚", 9);
            valCol.Add("门扇条码", 15);
            valCol.Add("线别", 18);
            valCol.Add("查找项", 19);
            valCol.Add("数量", 10);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 如果用户需要重新制定读取一些D区 M区的话可以先设置保存读取PLC 内容的文件
        /// 读取后生成命令
        /// </summary>
        public void SetPlcReadDMData(string filename)
        {
            if (XJPLCcmd.CmdReadDMDataOut != null)
            {
                XJPLCcmd.CmdReadDMDataOut = null;
            }

            if (CSVData != null)
            {
                CSVData.Dispose();
                CSVData = null;
            }

            CSVData = new CsvStreamReader();
            string s = Path.GetExtension(filename);

            if (File.Exists(filename) && (Path.GetExtension(filename).Equals(Constant.CSVFileEX)))
            {
                CSVData.FileName = filename;
            }
            //确认表格 //这个要隔离出来 方便以后可以单独调用 针对用户更改读取内容
            if (CSVData.CheckCSVFile(Constant.PLCstrCol))
            {
                dataForm = CSVData.OpenCSV(CSVData.FileName);
                if (dataForm != null && dataForm.Rows.Count > 0)
                {
                    PackCmdReadDMDataOut(dataForm);
                    //在建立连接的时候 切换表格数据源
                }
            }
            //GC.Collect();
            //GC.WaitForPendingFinalizers();
        }
Ejemplo n.º 3
0
        public XJDevice(List <string> filestr, ServerInfo s0)
        {
            XJPLCcmd    = new XJPLCPackCmdAndDataUnpack();
            DataFormLst = new List <DataTable>();
            CSVData     = new CsvStreamReader();
            dgShowLst   = new List <DataGridView>();

            //获取监控数据 dataformLst 填充
            GetPlcDataTableFromFile(filestr);

            //监控第一个列表数据 考虑下 这个还要不要 因为已经有一个 shift在后面了
            if (dataFormLst.Count > 0)
            {
                SetPlcReadDMData(dataFormLst[0]);
            }

            //设置端口
            SetComm(s0);

            //监控通讯
            WatchCommTimer = new System.Timers.Timer(Constant.XJRestartTimeOut);  //这里1.5 秒别改 加到常量里 工控机性能不行

            WatchCommTimer.Enabled = false;

            WatchCommTimer.AutoReset = true;

            WatchCommTimer.Elapsed += new System.Timers.ElapsedEventHandler(WatchTcpTimerEvent);
        }
Ejemplo n.º 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // ConstantMethod.AppExit();
            strDataFormPath = new List <string>();
            strDataFormPath.Add(Constant.PlcDataFilePathAuto);
            strDataFormPath.Add(Constant.PlcDataFilePathHand);
            strDataFormPath.Add(Constant.PlcDataFilePathParam);
            CSVData = new CsvStreamReader();
            test();

            return;
        }
Ejemplo n.º 5
0
        public XJDevice(List <string> filestr, PortParam p0)
        {
            IsCommSet   = true;
            XJPLCcmd    = new XJPLCPackCmdAndDataUnpack();
            DataFormLst = new List <DataTable>();
            CSVData     = new CsvStreamReader();
            dgShowLst   = new List <DataGridView>();

            //获取监控数据 dataformLst 填充
            GetPlcDataTableFromFile(filestr);

            //找一下串口 不存在就报错 退出
            portParam = p0;// ConstantMethod.LoadPortParam(Constant.ConfigSerialportFilePath);

            if (!SerialPort.GetPortNames().Contains(portParam.m_portName))
            {
                MessageBox.Show(Constant.NoSerialPort + portParam.m_portName);
                ConstantMethod.AppExit();
            }

            //监控第一个列表数据 考虑下 这个还要不要 因为已经有一个 shift在后面了
            if (dataFormLst.Count > 0)
            {
                SetPlcReadDMData(dataFormLst[0]);
            }

            //设置端口
            SetComm(p0);

            //监控通讯
            WatchCommTimer = new System.Timers.Timer(Constant.XJRestartTimeOut);  //这里1.5 秒别改 加到常量里 工控机性能不行

            WatchCommTimer.Enabled = false;

            WatchCommTimer.AutoReset = true;

            WatchCommTimer.Elapsed += new System.Timers.ElapsedEventHandler(WatchTimerEvent);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 针对信捷PLC 进行设备的存在获取
        /// </summary>
        /// <returns></returns>


        public XJDevice(List <string> filestr)
        {
            XJPLCcmd    = new XJPLCPackCmdAndDataUnpack();
            DataFormLst = new List <DataTable>();
            CSVData     = new CsvStreamReader();
            dgShowLst   = new List <DataGridView>();

            //获取监控数据 dataformLst 填充
            GetPlcDataTableFromFile(filestr);

            //找一下串口 不存在就报错 退出
            if (!ConstantMethod.XJFindPort(1))
            {
                MessageBox.Show(DeviceId + Constant.ConnectMachineFail);
                //报错 在外面调试 需要隐藏
                //ConstantMethod.AppExit();
            }

            portParam = ConstantMethod.LoadPortParam(Constant.ConfigSerialportFilePath);

            //监控第一个列表数据 考虑下 这个还要不要 因为已经有一个 shift在后面了
            if (dataFormLst.Count > 0)
            {
                SetPlcReadDMData(dataFormLst[0]);
            }

            //设置端口
            SetComm(portParam);

            //监控通讯
            WatchCommTimer = new System.Timers.Timer(Constant.XJRestartTimeOut);  //这里1.5 秒别改 加到常量里 工控机性能不行


            WatchCommTimer.AutoReset = true;

            WatchCommTimer.Elapsed += new System.Timers.ElapsedEventHandler(WatchTimerEvent);
        }
Ejemplo n.º 7
0
        void Init(List <string> filestr)
        {
            DataFormLst = new List <DataTable>();
            CSVData     = new CsvStreamReader();
            dgShowLst   = new List <DataGridView>();

            //获取监控数据 dataformLst 填充
            GetPlcDataTableFromFile(filestr);

            //找一下串口 不存在就报错 退出
            if (!ConstantMethod.DTFindPort())
            {
                MessageBox.Show(Constant.ConnectMachineFail);
                System.Environment.Exit(0);
            }

            portParam = ConstantMethod.LoadPortParam(Constant.ConfigSerialportFilePath);

            //监控第一个列表数据
            if (dataFormLst.Count > 0)
            {
                SetPlcReadDMData(dataFormLst[0]);
            }

            //设置端口
            SetComm(portParam);

            //监控通讯
            WatchCommTimer = new System.Timers.Timer(Constant.XJRestartTimeOut);  //这里1.5 秒别改 加到常量里 工控机性能不行

            //测试先隐藏
            WatchCommTimer.Enabled = false;

            WatchCommTimer.AutoReset = true;

            WatchCommTimer.Elapsed += new System.Timers.ElapsedEventHandler(WatchTimerEvent);
        }