/// <summary> /// //发送列切刀使能位 /// </summary> /// <param name="highByte"></param> /// <param name="lowByte"></param> public static void send_ColState(byte highByte, byte lowByte) { byte[] data = new byte[5]; if (Global.my_start == 1) { return; //运行时不操作 } data[0] = 0x02; //cmd colState data[1] = highByte; //data data[2] = lowByte; //data while (!send_cmd(Device_Id[0], data)) { System.Threading.Thread.Sleep(50); } while (!send_cmd(Device_Id[1], data)) { System.Threading.Thread.Sleep(50); } //切刀使能位保存到文件中 Global.savebuf[0] = Global.col_data_high = data[1]; Global.savebuf[1] = Global.col_data_low = data[2]; FileOperation.WriteByteFile("config.txt", Global.savebuf);//保存列状态 }
private void data_Init()//从文件读取数据,并下发电路板 { Global.savebuf = FileOperation.ReadByteFile("config.txt", Global.savebuf); Global.col_data_high = Global.savebuf[0]; //列切刀 Global.col_data_low = Global.savebuf[1]; Global.row_num = Global.savebuf[2]; //排数 Global.bord_length = Global.savebuf[3]; //前边距 Global.bed_num = (short)(Global.savebuf[4] << 8 | Global.savebuf[5]); //张数 Global.work_mode = Global.savebuf[6]; //工作模式 for (int i = 0; i < 13; i++) //0-12电磁阀的胶量 { Global.glueNum[i] = Global.savebuf[i + 10]; } //下发电路板各状态 SerialServer.send_ColState(Global.col_data_high, Global.col_data_low); //列切刀 SerialServer.send_RowNum(Global.row_num); //排数 SerialServer.send_length(Global.bord_length); //前边距 SerialServer.send_BedNum((short)Global.bed_num); //张数 SerialServer.send_work_mode(Global.work_mode); //工作模式 for (int i = 0; i < 13; i++) { SerialServer.send_glue_num((byte)i, Global.glueNum[i]);//0-12电磁阀的胶量 } //更新列切刀使能位显示 if ((Global.col_data_low & 0x01) != 0) { Col_1_Btn.BackColor = Color.Green; } else { Col_1_Btn.BackColor = Color.DarkGray; } if ((Global.col_data_low & 0x02) != 0) { Col_2_Btn.BackColor = Color.Green; } else { Col_2_Btn.BackColor = Color.DarkGray; } if ((Global.col_data_low & 0x04) != 0) { Col_3_Btn.BackColor = Color.Green; } else { Col_3_Btn.BackColor = Color.DarkGray; } if ((Global.col_data_low & 0x08) != 0) { Col_4_Btn.BackColor = Color.Green; } else { Col_4_Btn.BackColor = Color.DarkGray; } if ((Global.col_data_low & 0x10) != 0) { Col_5_Btn.BackColor = Color.Green; } else { Col_5_Btn.BackColor = Color.DarkGray; } if ((Global.col_data_low & 0x20) != 0) { Col_6_Btn.BackColor = Color.Green; } else { Col_6_Btn.BackColor = Color.DarkGray; } if ((Global.col_data_low & 0x40) != 0) { Col_7_Btn.BackColor = Color.Green; } else { Col_7_Btn.BackColor = Color.DarkGray; } if ((Global.col_data_low & 0x80) != 0) { Col_8_Btn.BackColor = Color.Green; } else { Col_8_Btn.BackColor = Color.DarkGray; } if ((Global.col_data_high & 0x01) != 0) { Col_9_Btn.BackColor = Color.Green; } else { Col_9_Btn.BackColor = Color.DarkGray; } if ((Global.col_data_high & 0x02) != 0) { Col_10_Btn.BackColor = Color.Green; } else { Col_10_Btn.BackColor = Color.DarkGray; } if ((Global.col_data_high & 0x04) != 0) { Col_11_Btn.BackColor = Color.Green; } else { Col_11_Btn.BackColor = Color.DarkGray; } if ((Global.col_data_high & 0x08) != 0) { Col_12_Btn.BackColor = Color.Green; } else { Col_12_Btn.BackColor = Color.DarkGray; } if ((Global.col_data_high & 0x10) != 0) { Col_13_Btn.BackColor = Color.Green; } else { Col_13_Btn.BackColor = Color.DarkGray; } //前边距显示更新 boradLenth0Btn.BackColor = Color.DarkGray; boradLenth1Btn.BackColor = Color.DarkGray; boradLenth2Btn.BackColor = Color.DarkGray; boradLenth3Btn.BackColor = Color.DarkGray; boradLenth4Btn.BackColor = Color.DarkGray; boradLenth5Btn.BackColor = Color.DarkGray; boradLenth6Btn.BackColor = Color.DarkGray; boradLenth7Btn.BackColor = Color.DarkGray; if (Global.bord_length == 0) { boradLenth0Btn.BackColor = Color.Green; } else if (Global.bord_length == 1) { boradLenth1Btn.BackColor = Color.Green; } else if (Global.bord_length == 2) { boradLenth2Btn.BackColor = Color.Green; } else if (Global.bord_length == 3) { boradLenth3Btn.BackColor = Color.Green; } else if (Global.bord_length == 4) { boradLenth4Btn.BackColor = Color.Green; } else if (Global.bord_length == 5) { boradLenth5Btn.BackColor = Color.Green; } else if (Global.bord_length == 6) { boradLenth6Btn.BackColor = Color.Green; } else if (Global.bord_length == 7) { boradLenth7Btn.BackColor = Color.Green; } //更新排数 rowNumLabel.Text = Global.row_num.ToString(); //更新张数 bedNumLabel.Text = Global.bed_num.ToString(); //更新工作模式 holeAndGlueAndMagnetBtn.BackColor = Color.DarkGray; glueAndMagnetBtn.BackColor = Color.DarkGray; onlyGlueBtn.BackColor = Color.DarkGray; onlyMagnetBtn.BackColor = Color.DarkGray; flowLineBtn.BackColor = Color.DarkGray; flowLineBackBtn.BackColor = Color.DarkGray; cleanGlueBtn.BackColor = Color.DarkGray; if (Global.work_mode == 0) { holeAndGlueAndMagnetBtn.BackColor = Color.Green; } else if (Global.work_mode == 1) { glueAndMagnetBtn.BackColor = Color.Green; } else if (Global.work_mode == 2) { onlyGlueBtn.BackColor = Color.Green; } else if (Global.work_mode == 3) { onlyMagnetBtn.BackColor = Color.Green; } else if (Global.work_mode == 4) { flowLineBtn.BackColor = Color.Green; } else if (Global.work_mode == 5) { flowLineBackBtn.BackColor = Color.Green; } else if (Global.work_mode == 6) { cleanGlueBtn.BackColor = Color.Green; } //更新胶量 glue1NumLabel.Text = Global.glueNum[0].ToString(); glue2NumLabel.Text = Global.glueNum[1].ToString(); glue3NumLabel.Text = Global.glueNum[2].ToString(); glue4NumLabel.Text = Global.glueNum[3].ToString(); glue5NumLabel.Text = Global.glueNum[4].ToString(); glue6NumLabel.Text = Global.glueNum[5].ToString(); glue7NumLabel.Text = Global.glueNum[6].ToString(); glue8NumLabel.Text = Global.glueNum[7].ToString(); glue9NumLabel.Text = Global.glueNum[8].ToString(); glue10NumLabel.Text = Global.glueNum[9].ToString(); glue11NumLabel.Text = Global.glueNum[10].ToString(); glue12NumLabel.Text = Global.glueNum[11].ToString(); glue13NumLabel.Text = Global.glueNum[12].ToString(); }