//指令相关 private void button7_Click(object sender, EventArgs e) { //MessageBox.Show(linenum.ToString()); //MessageBox.Show(filelinepara[0].ToString()); if (linenum <= filelinepara[0]) //'未新建行时不允许操作 { _20_运动类型选择 f20 = new _20_运动类型选择(this, this.return_14_文件管理, null, null, null, null, null, null, null, null); f20.g_handle = g_handle; f20.vr = vr; //数组 f20.codespace = codespace; //数组 f20.manulradio = manulradio; //速度比例 f20.linenum = linenum; //行号 f20.filelinepara = filelinepara; f20.filelintempepara = filelintempepara; f20.codename = codename; f20.codetempspace = codetempspace; f20.linejump = linejump; f20.pagenum = pagenum; f20.filetoflash = filetoflash; f20.showidlist = showidlist; f20.Show();//新窗口显现 } else { Console.WriteLine("新建行"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "先插入行"; f52.ShowDialog(); } }
//新建 private void button3_Click(object sender, EventArgs e) { if (totalfilenum < FILENUMMAX) { if (pagenum == totalpagenum) { filetoflash[totalfilenum] = totalfilenum + 1; //ID表存flash块号 totalfilenum = totalfilenum + 1; //当前总数+1 filenum = totalfilenum; //当前选择ID更新 filename[0] = "New"; //文件名初始值 pagenum = (filenum - 1) / ONEPAGENUM + 1; totalpagenum = (totalfilenum - 1) / ONEPAGENUM + 1; int index = this.dataGridView1.Rows.Add(); if (index % 5 < ONEPAGENUM) { this.dataGridView1.Rows[index].Cells[0].Value = (pagenum - 1) * ONEPAGENUM + index + 1; this.dataGridView1.Rows[index].Cells[1].Value = filename[0]; } deal_fileflash(0); return; } pagenum = totalpagenum; LoadPage(); } else { _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "文件已满"; f52.ShowDialog(); } //if (totalfilenum < FILENUMMAX) //{ // for (int i = 0; i < FILENUMMAX; i++) // { // fileflag = FILEFLASHFLAG; // //flash_read i+1,fileflag // if (fileflag == FILEFLASHFLAG) //未使用 // { // filetoflash[totalfilenum] = i + 1; //ID表存flash块号 // totalfilenum = totalfilenum + 1; //当前总数+1 // filenum = totalfilenum; //当前选择ID更新 // filename="New"; //文件名初始值 // // FLASH_WRITE i+1,FILEFLASHFLAG,filename,filelinepara,setzero; //占用flash块, // //标志, 文件名, 指令允许, 指令空间, 指令起始, 数据0 // pagenum = (filenum - 1) / ONEPAGENUM + 1; // totalpagenum = (totalfilenum - 1) / ONEPAGENUM + 1; // break; // } // } // fileflag = 0; // deal_fileflash(0); //} //else //{ // _52_操作提示 f52 = new _52_操作提示(); // f52.V1 = "文件已满"; // f52.ShowDialog(); //} }
//确认 private void button2_Click(object sender, EventArgs e) { if (filenum < recordCount) { if (filenum != 0) { //flash_read filetoflash(filenum-1),fileflag,filename,filelinepara,codespace(0,MAXLINENUM*LINESPACE) '读取 //DMCPY codetempspace(0),codespace(0),MAXLINENUM*LINESPACE '赋值到临时数组 //dmcpy filelintempepara(0),filelinepara(0),10 //DMCPY filejudname(0),filename(0),FILENAMELENG } filetempnum = filenum; //DMCPY filetempname(0),filename(0),FILENAMELENG '赋值到临时数组 runlinenum = 0; //运行行号清0 this.Close(); this.return_10Start.Visible = true; //?*"当前编辑",filenum,filename } else { _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "文件不存在"; f52.ShowDialog(); } }
//跳转 private void button13_Click(object sender, EventArgs e) { linejump = textBox6.Text; MessageBox.Show(linejump); if (int.Parse(linejump) <= filelinepara[0]) { if (int.Parse(linejump) > 0) { linenum = int.Parse(linejump); } else { linejump = textBox6.Text; //还原 linenum = 1; } //wa(10) deal_lineload(linenum); } else { Console.WriteLine("超出范围"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "超出范围"; f52.ShowDialog(); } }
//上一页 private void btnPrev_Click(object sender, EventArgs e) { if (pagenum == 1) { Console.WriteLine("第一页"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "第一页"; f52.ShowDialog(); return; } pagenum--; filenum = (pagenum - 1) * ONEPAGENUM + 1; LoadPage(); }
//是 private void button1_Click(object sender, EventArgs e) { if (totalfilenum > 0) { if (filenum != 0) { if (filenum <= totalfilenum) { fileflag = 0; Console.WriteLine("清除flash:", filetoflash[filenum - 1]); //FLASH_WRITE filetoflash(filenum-1),fileflag,zeroname,filelinepara[0],setzero '释放flash块 //DMDEL filetoflash(filenum-1) '删除块号 filetoflash[FILENUMMAX - 1] = -1; //ID列表刷新 if (filenum == totalfilenum) { filenum = totalfilenum - 1; //最后一个上移 } totalfilenum = totalfilenum - 1; //文件数-1 pagenum = (filenum - 1) / ONEPAGENUM + 1; //页数刷新,启用每次删除跳转到最后 totalpagenum = (totalfilenum - 1) / ONEPAGENUM + 1; deal_fileflash(0); this.Close(); } else { this.Close(); Console.WriteLine("文件不存在"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "文件不存在"; f52.ShowDialog(); } } else { Console.WriteLine("未选择文件ID"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "未选择文件ID"; f52.ShowDialog(); } } else { Console.WriteLine("没有文件"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "没有文件"; f52.ShowDialog(); } }
//游览 private void button6_Click(object sender, EventArgs e) { if (filenum > 0) { browsepage = 1; deal_browseflash(); //HMI_SHOWWINDOW(30,0) } else { Console.WriteLine("未选择ID"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "未选择文件ID"; f52.ShowDialog(); } }
//复制 private void button5_Click(object sender, EventArgs e) { if (totalfilenum < FILENUMMAX) { if (filenum > 0) //判断选择文件 { Console.WriteLine("选择的flash", filetoflash[filenum - 1]); //flash_read filetoflash(filenum-1),fileflag,filename,tsfcopy '先将选择块数据赋值到中转数组 for (int i = 0; i < FILENUMMAX; i++) { fileflag = FILEFLASHFLAG; //先等于 //FLASH_READ i+1,fileflag; //读取判断 if (fileflag != FILEFLASHFLAG) { Console.WriteLine("空闲的flash", i + 1); filetoflash[totalfilenum] = i + 1; //ID表存flash块号 totalfilenum = totalfilenum + 1; //当前总数+1 filenum = totalfilenum; //当前选择ID更新 // filename=filename +"copy" '文件名初始值 // FLASH_WRITE i+1,FILEFLASHFLAG,filename,tsfcopy '中转数组数据赋值给块 pagenum = (filenum - 1) / ONEPAGENUM + 1; totalpagenum = (totalfilenum - 1) / ONEPAGENUM + 1; break; } } fileflag = 0; //判断标志置0 deal_fileflash(0); } else { Console.WriteLine("未选择文件ID"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "未选择文件ID"; f52.ShowDialog(); } } else { Console.WriteLine("没有文件"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "没有文件"; f52.ShowDialog(); } }
//加载 private void deal_lineload(int num) { codespace[(num - 1) * LINESPACE] = linejump; if (num <= filelinepara[0]) { templine[0] = int.Parse(codespace[(num - 1) * LINESPACE]); //dmcpy templine(0),codespace((num-1)*LINESPACE),LINESPACE; '复制到临时数组 linenum = num; //浏览界面跳转用 show_code(templine[0]); //刷新显示 } else if (num > filelinepara[0] && winnum == 30) //只有游览界面才提示 { Console.WriteLine("超过文件总行数"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "超过文件总行数"; f52.ShowDialog(); } }
//是 private void button1_Click(object sender, EventArgs e) { //uflag=file "COPY_TO",ZINDEX_ARRAY(unameindex((unum-1) mod ONEPAGENUM )),"SD"+tostr(filetoflash(filenum-1),1,0)+".bin" //关闭当前窗口 this.Close(); if (uflag == -1) { _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "下载成功"; f52.ShowDialog(); deal_fileflash(); } else { _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "下载失败"; f52.ShowDialog(); } }
//下一个 private void button2_Click(object sender, EventArgs e) { int row = this.dataGridView1.CurrentRow.Index + 1; if (row > this.dataGridView1.RowCount - 1) { Console.WriteLine("最后一个"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "最后一个"; f52.ShowDialog(); } else { deal_fileflash(0); filenum = (pagenum - 1) * ONEPAGENUM + row + 1; this.dataGridView1.CurrentCell = this.dataGridView1[0, row]; } //if((filenum<(totalfilenum+1))&&(filenum < FILENUMMAX)) //{ // filenum=filenum+1; //上一个ID // int temppage; // temppage = (filenum - 1) / ONEPAGENUM + 1; // if(pagenum!=temppage) // { // pagenum=temppage; // deal_fileflash(0); // } //} //else //{ // Console.WriteLine("最后一个"); // _52_操作提示 f52 = new _52_操作提示(); // f52.V1 = "最后一个"; // f52.ShowDialog(); //} }
//下一页 private void btnNext_Click(object sender, EventArgs e) { if ((filenum <= totalfilenum) && (totalfilenum % ONEPAGENUM == 0) && (totalfilenum < FILENUMMAX)) { asd = 123; } if ((pagenum < totalpagenum) || (asd == 123)) { pagenum++; filenum = (pagenum - 1) * ONEPAGENUM + 1; LoadPage(); } else { Console.WriteLine("最后一页"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "最后一页"; f52.ShowDialog(); return; } }
//回零 private void button8_Click(object sender, EventArgs e) { if (flag_state == 0) { //执行任务2 //td_home = new Thread(task_home); //if ((td_home.ThreadState & ThreadState.Unstarted) != 0 && f_home == 0) //{ // td_home.Start(); //启动线程 // f_home = 1; //标志启动了线程2 //} timer3.Enabled = true; timer3.Interval = 100; timer3.Start(); } else { Console.WriteLine("运行中无法操作"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "运行中无法操作"; f52.ShowDialog(); } }
//游览 private void button9_Click(object sender, EventArgs e) { if (filenum > 0) { browsepage = 1; deal_browseflash(); _30_游览文件 f30 = new _30_游览文件(this); f30.g_handle = g_handle; f30.pagenum = pagenum; f30.filetoflash = filetoflash; f30.showidlist = showidlist; this.Hide(); //隐藏现在这个窗口 f30.Show(); //新窗口显现 } else { Console.WriteLine("未选择ID"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "未选择ID"; f52.ShowDialog(); } }
//确认 private void button2_Click(object sender, EventArgs e) { if (filenum <= totalfilenum) { if (filenum != 0) { //flash_read filetoflash(filenum-1),fileflag,filename,filelinepara,codespace(0,MAXLINENUM*LINESPACE) '读取 //DMCPY codetempspace(0),codespace(0),MAXLINENUM*LINESPACE '赋值到临时数组 //dmcpy filelintempepara(0),filelinepara(0),10 //DMCPY filejudname(0),filename(0),FILENAMELENG filetempnum = filenum; //DMCPY filetempname(0),filename(0),FILENAMELENG; //赋值到临时数组 runlinenum = 0; //运行行号清0 this.Close(); this.return_10Start.filetempnum = filetempnum; this.return_10Start.Visible = true; Console.WriteLine("当前编辑 filenum={0}\filename={1}", filenum, filename); } else { Console.WriteLine("未选择ID"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "未选择文件ID"; f52.ShowDialog(); } } else { Console.WriteLine("文件不存在"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "文件不存在"; f52.ShowDialog(); } }
//上一个 private void button1_Click(object sender, EventArgs e) { //int row = this.dataGridView1.CurrentRow.Index - 1; //if (row < 0) //{ // Console.WriteLine("第一个"); // _52_操作提示 f52 = new _52_操作提示(); // f52.V1 = "第一个"; // f52.ShowDialog(); //} //else //{ // deal_fileflash(0); // filenum = (pagenum - 1) * ONEPAGENUM + row + 1; // this.dataGridView1.CurrentCell = this.dataGridView1[0, row]; //} if (filenum > 1) { filenum = filenum - 1; int temppage; temppage = (filenum - 1) / ONEPAGENUM + 1; if (pagenum != temppage) { pagenum = temppage; deal_fileflash(0); } } else { Console.WriteLine("第一个"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "第一个"; f52.ShowDialog(); } }
//启动 private void button5_Click(object sender, EventArgs e) { if (flag_state == 0) //启动 { if (flag_home == 1) //回零完成 { if (filetempnum != 0) { for (int i = 0; i < AXISMAX; i++) { f1 = vr[i * AXISSPACE + 1]; zmcaux.ZAux_Direct_SetSpeed(g_handle, i, f1); //还原速度 } //执行任务1 //td_run = new Thread(task_run); //if ((td_run.ThreadState & ThreadState.Unstarted) != 0 && f_run ==0) //{ // td_run.Start(); //启动线程 // f_run = 1; //标志启动了线程1 //} timer2.Enabled = true; timer2.Interval = 100; timer2.Start(); } else { Console.WriteLine("未选择文件"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "未选择文件"; f52.ShowDialog(); } } else { Console.WriteLine("机台复位未完成"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "机台复位未完成"; f52.ShowDialog(); } } else if (flag_state == 2) //恢复 { //恢复任务1 RESUMETASK 1 //if ((td_run.ThreadState & ThreadState.Suspended) != 0 && f_run == 1) //{ // td_run.Resume(); //恢复线程 //} //轴选择 base(0) //运动恢复 MOVE_RESUME statename.Text = "运行中:执行"; //状态显示 flag_state = 1; //运行 } else { Console.WriteLine("已在运行中"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "已在运行中"; f52.ShowDialog(); } }
//编辑 private void button8_Click(object sender, EventArgs e) { if (filenum <= totalfilenum) { if (filenum != 0) { //flash_read filetoflash(filenum-1),fileflag,filename,filelinepara,codespace(0,MAXLINENUM*LINESPACE) '读取 // char [] chArr = filename[0].ToCharArray(); // shownamelist[i % ONEPAGENUM].CopyTo(0,chArr,0,FILENAMELENG); //codetempspace[0].CopyTo(0,codespace[0].ToCharArray(),0,MAXLINENUM*LINESPACE); //String str = filelintempepara[0].ToString(); //str.CopyTo(0, filelinepara[0].ToString().ToCharArray(), 0, 10); //filelintempepara[0] = int.Parse(str); //filejudname[0].CopyTo(0, filename[0].ToCharArray(), 0, FILENAMELENG); //DMCPY codetempspace(0),codespace(0),MAXLINENUM*LINESPACE '赋值到临时数组 //dmcpy filelintempepara(0),filelinepara(0),10 //DMCPY filejudname(0),filename(0),FILENAMELENG MessageBox.Show(linenum.ToString()); // linenum = 1; _19_文件编辑 f19 = new _19_文件编辑(this); f19.g_handle = g_handle; f19.codename = codename; f19.filenum = filenum; filelinepara[0] = totalfilenum; f19.filelinepara = filelinepara; f19.filelintempepara = filelintempepara; f19.codespace = codespace; f19.codetempspace = codetempspace; f19.browsepage = browsepage; f19.manulradio = manulradio; //初始速度比 // f19.paratemp = paratemp; f19.vr = vr; f19.pagenum = pagenum; f19.filetoflash = filetoflash; f19.showidlist = showidlist; f19.linenum = linenum; this.Hide(); //隐藏现在这个窗口 f19.Show(); //新窗口显现 // deal_lineload(linenum); //加载第一行 // filename[0] = this.dataGridView1.Rows[linenum - 1].Cells[1].Value.ToString(); //获取文件名 Console.WriteLine("当前编辑 filenum={0}\filename={1}", filenum, filename); } else { Console.WriteLine("未选择ID"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "未选择文件ID"; f52.ShowDialog(); } } else { Console.WriteLine("文件不存在"); _52_操作提示 f52 = new _52_操作提示(); f52.V1 = "文件不存在"; f52.ShowDialog(); } }