public int Run()//启动 { if (OSRM.Startup()) { if (m_strport == "4000") //if (m_strport == "80") { CRCStatus status = new CRCStatus(); status.CRCNum = m_strSRMNo; status.AisleNumber = aisle.ToString(); CRCItems.Add(status); } GetSCStatusTimer.Start(); ShowText("C", "连接成功,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport); return(1); } else { CheckConnectTimer.Start(); ShowText("C", "连接失败,IP地址" + m_ip + ",堆垛机编号" + m_strSRMNo + ",端口" + m_strport); return(0); } }
public void UpdateCRCStatus(string num, string str, string aisle) { string[] msg = str.Split(new char[] { ';' }); CRCStatus css = CRCItems.Find( delegate(CRCStatus info) { return(info.CRCNum == num); } ); if (css != null) { if (str == "Break") { css.CrcStatus = EQUIPMENT_ERROR; css.CraneMode = "0"; css.LabelInfo = "位置:" + css.Position + ".模式:关闭.状态:无.起止:" + css.Fromstation + "-->" + css.Tostation + "."; dal.UpdateSCStatusNTI(css.CRCNum, css.CrcStatus); } else if (msg.Length > 38) { string mode = EQUIPMENT_ERROR; int[] functionmode = FunctionMode(int.Parse(msg[23])); int[] cranemode = FunctionMode(int.Parse(msg[38])); if (functionmode[0] == 1 && functionmode[4] == 1 && msg[38] == "1") { mode = EQUIPMENT_OK; } int t = int.Parse(msg[20].ToString()) * 256 + int.Parse(msg[21].ToString()); if (t != 0 && t.ToString() != css.TaskNo) { dal.UpdateTaskStatus(t.ToString(), "SC", "2", "1"); } //dal.UpdateTaskStatus(t.ToString(), "SC", "2", "1"); css.TaskNo = t.ToString(); css.CraneMode = msg[38]; //css.FunctionReportH = msg[38]; css.FunctionMode = msg[23]; css.FunctionReport = msg[22]; css.CrcStatus = mode; css.ZAlarm = functionmode[7]; css.ActionPoint = msg[26]; css.AisleNumber = msg[27]; css.RackSide = msg[28]; css.RackPosition = msg[29]; css.RackPlace = msg[30]; css.RackLevel = msg[31]; css.RackDepth = msg[32]; css.Position = GetLocation(num, int.Parse(msg[27]), int.Parse(msg[28]), int.Parse(msg[29]), int.Parse(msg[30]), int.Parse(msg[31]), int.Parse(msg[32])); css.AlarmMessage = GetAlarmInfo(num, "", false); css.LabelInfo = "任务号:" + css.TaskNo + ".位置:" + css.Position + ".模式:" + GetFunctionMode(functionmode, cranemode) + ".状态:" + GetTaskStatusBase(msg[22], msg[38]) + ".起止:" + css.Fromstation + "-->" + css.Tostation + "." + css.AlarmMessage; if (css.LabelInfo == css.OldLabelInfo) { css.Change = false; } else { css.OldLabelInfo = css.LabelInfo; css.Change = true; dal.UpdateSCStatusNTI(css.CRCNum, css.CrcStatus); //UpdateEquipmentStatus(t.ToString(), css.Position, GetFunctionMode(functionmode, cranemode), GetTaskStatusBase(msg[22],msg[38]), css.Fromstation, css.Tostation, css.AlarmMessage, num); } if (css.CrcStatus == EQUIPMENT_ERROR) { css.CrcTaskFlag = "0"; } else { css.CrcTaskFlag = "1"; } CRCObject co = crclist.Find( delegate(CRCObject cob) { return(cob.ScNo == num && cob.Port == 2000); } ); if (co != null) { if (System.String.IsNullOrEmpty(css.Fromstation) || System.String.IsNullOrEmpty(css.Tostation)) { string[] ss = new string[2]; ss = dal.GetTostation(css.TaskNo); if (ss != null) { css.Fromstation = ss[0]; css.Tostation = ss[1]; } } string destr = ""; if (!System.String.IsNullOrEmpty(css.Tostation)) { if (css.Tostation.Contains("A")) { destr = css.Tostation.Replace("A", ""); } else { destr = css.Tostation; } } if (css.FunctionReport == CR_GETC_EXECUTED) { #region CR_GETC_EXECUTED 取货完成 if (css.Fromstation != null && css.Fromstation.Length == 4 && css.TaskNo.Length > 4) { string[] clear = new string[11]; string[] info = ReadStationInfo(int.Parse(css.Fromstation)); for (int i = 0; i < 11; i++) { clear[i] = "0"; } clear[0] = css.Fromstation; co.BllSrm.SendCode(num, CR_PUTC, 0, int.Parse(css.TaskNo), destr.Replace("A", "").Replace("B", "")); if (info[1] == css.TaskNo) { logsta.WriteLog("清除入库口任务" + clear[0]); bool clearstation = WriteStationInfo(clear); if (clearstation) { logsta.WriteLog("清除入库口任务成功"); } } } //发指令调试注释 else { //co.BllSrm.SendCode(num, CR_PUTC, 0, int.Parse(css.TaskNo), css.Tostation.Replace("A","")); co.BllSrm.SendCode(num, CR_PUTC, 0, int.Parse(css.TaskNo), destr); } //发指令调试注释 #endregion } else if (css.FunctionReport == CR_PUTC_EXECUTED) { #region CR_PUTC_EXECUTED 放货完成 if (css.TaskNo != null && css.TaskNo.Length > 4) { //co.BllSrm.SendCode(num, CR_NO_FUNC, 0, int.Parse(css.TaskNo), destr); //dal.UpdateTaskStatus(css.TaskNo, "SC", "1", "1"); if (co.BllSrm.SendCode(num, CR_NO_FUNC, 0, int.Parse(css.TaskNo), destr)) { dal.UpdateTaskStatus(css.TaskNo, "SC", "1", "1"); #region Tostation.Length == 4 if (css.Tostation != null && css.Tostation.Length == 4) { string itemtype; string barcode, addressstation = "0"; barcode = dal.GetBarcode(css.TaskNo); string[] info = barcode.Split(new char[] { ',' }); if (info.Length > 2) { addressstation = info[2]; } //else // addressstation = num == "CRC001" ? "5066" : "5071"; if (info[0] == "99999999") { itemtype = "2"; } else { itemtype = "3"; } string[] strsta = new string[11]; strsta[0] = css.Tostation; strsta[1] = css.TaskNo; int upbarcode1 = int.Parse(info[0]) / 65536; int upbarcode2 = int.Parse(info[0]) % 65536; strsta[2] = upbarcode1.ToString(); strsta[3] = upbarcode2.ToString(); strsta[4] = itemtype; strsta[5] = css.Tostation; strsta[6] = addressstation;//info[2];//css.STAToStation; strsta[7] = "0"; strsta[8] = "0"; strsta[9] = "0"; strsta[10] = "0"; if (WriteStationInfo(strsta)) { dal.UpdateTaskStatus(css.TaskNo, "STA", "2", "1"); //#region 出库放货后取入库任务 //if (num.Equals("CRC001")) //{ // string task5041 = ReadStationInfo(5041)[1]; // if (Int32.Parse(task5041) > 9999) // { // DataSet dstemp = dal.CheckInTask_1073(task5041); // if (dstemp != null && dstemp.Tables.Count > 0 && dstemp.Tables[0].Rows.Count > 0) // { // String taskno = dstemp.Tables[0].Rows[0][0].ToString(); // String fromstation = dstemp.Tables[0].Rows[0][1].ToString(); // String tostation = dstemp.Tables[0].Rows[0][2].ToString(); // if (crc.UpdateCRCTaskInfo(num, fromstation, tostation, "0", "Task_InBound")) // { // bool sendflag = co.BllSrm.SendCode(num, CR_GETC, 0, int.Parse(taskno), fromstation); // if (sendflag) // dal.UpdateTaskStatus(taskno, "SC", "2", "1"); // //dal.UpdateTaskStatus(taskno, "SC", "2", "1"); // } // } // } //} //if (num.Equals("CRC002")) //{ // string task5049 = ReadStationInfo(5049)[1]; // if (Int32.Parse(task5049) > 9999) // { // DataSet dstemp = dal.CheckInTask_1073(task5049); // if (dstemp != null && dstemp.Tables.Count > 0 && dstemp.Tables[0].Rows.Count > 0) // { // String taskno = dstemp.Tables[0].Rows[0][0].ToString(); // String fromstation = dstemp.Tables[0].Rows[0][1].ToString(); // String tostation = dstemp.Tables[0].Rows[0][2].ToString(); // if (crc.UpdateCRCTaskInfo(num, fromstation, tostation, "0", "Task_InBound")) // { // bool sendflag = co.BllSrm.SendCode(num, CR_GETC, 0, int.Parse(taskno), fromstation); // if (sendflag) // dal.UpdateTaskStatus(taskno, "SC", "2", "1"); // //dal.UpdateTaskStatus(taskno, "SC", "2", "1"); // } // } // } //} //#endregion } } #endregion } } #endregion } //else if (css.FunctionReport == CR_NO_FUNC.ToString()) //{ // if (num.Equals("CRC001")) // { // string task5041 = ReadStationInfo(5041)[1]; // if (Int32.Parse(task5041) > 9999) // { // DataSet dstemp = dal.CheckInTask_1073(task5041); // if (dstemp != null && dstemp.Tables.Count > 0 && dstemp.Tables[0].Rows.Count > 0) // { // String taskno = dstemp.Tables[0].Rows[0][0].ToString(); // String fromstation = dstemp.Tables[0].Rows[0][1].ToString(); // String tostation = dstemp.Tables[0].Rows[0][2].ToString(); // if (crc.UpdateCRCTaskInfo(num, fromstation, tostation, "0", "Task_InBound")) // { // bool sendflag = co.BllSrm.SendCode(num, CR_GETC, 0, int.Parse(taskno), fromstation); // if(sendflag) // dal.UpdateTaskStatus(taskno, "SC", "2", "1"); // //dal.UpdateTaskStatus(taskno, "SC", "2", "1"); // } // } // } // } // if (num.Equals("CRC002")) // { // string task5049 = ReadStationInfo(5049)[1]; // if (Int32.Parse(task5049) > 9999) // { // DataSet dstemp = dal.CheckInTask_1073(task5049); // if (dstemp != null && dstemp.Tables.Count > 0 && dstemp.Tables[0].Rows.Count > 0) // { // String taskno = dstemp.Tables[0].Rows[0][0].ToString(); // String fromstation = dstemp.Tables[0].Rows[0][1].ToString(); // String tostation = dstemp.Tables[0].Rows[0][2].ToString(); // if (crc.UpdateCRCTaskInfo(num, fromstation, tostation, "0", "Task_InBound")) // { // bool sendflag = co.BllSrm.SendCode(num, CR_GETC, 0, int.Parse(taskno), fromstation); // if(sendflag) // dal.UpdateTaskStatus(taskno, "SC", "2", "1"); // //dal.UpdateTaskStatus(taskno, "SC", "2", "1"); // } // } // } // } //} } } } else { CRCStatus status = new CRCStatus(); status.CRCNum = num; status.AisleNumber = aisle; CRCItems.Add(status); } }