public bool PutClampIsNotOkAlarm() { if (!this.Plc.IsPingSuccess) { LogHelper.WriteError("无法连接到 " + this.Plc.IP); return(false); } string msg = string.Empty; try { bool m = false; if (!this.Plc.GetInfo(false, PlcCompany.Mitsubishi, false, Current.option.PutClampIsNotOkAlarmAdd, true, out m, out msg)) { Error.Alert(msg); this.Plc.IsAlive = false; return(false); } LogHelper.WriteInfo(string.Format("给RGV发送报警指令------{0}:true ", Current.option.PutClampIsNotOkAlarmAdd)); } catch (Exception ex) { Error.Alert(ex); } return(true); }
public static void GetInfo(out string lbProcessText, out string lbStationText, out string msg) { string ip = MES.IPAddr.ToString(); ProcessInfo pi = Tafel.MES.MES.GetProcessInfo(new IP { IPAddress = ip }, out msg); if (string.IsNullOrEmpty(msg))//成功获取到 { lbProcessText = string.Format("{0}[{1}]", pi.ProcessName, pi.ProcessCode); Current.option.CurrentProcess = string.Format("{0},{1}", pi.ProcessName, pi.ProcessCode); } else { Error.Alert(msg); string[] s = Current.option.CurrentProcess.Split(','); lbProcessText = string.Format("{0}[{1}]", s[0], s[1]); } StationInfo si = Tafel.MES.MES.GetStationInfo(new IpAndProcess { IPAddress = ip, ProcessCode = pi.ProcessCode }, out msg); if (string.IsNullOrEmpty(msg))//成功获取到 { lbStationText = string.Format("{0}[{1}]", si.StationName, si.StationCode); Current.option.CurrentStation = string.Format("{0},{1}", si.StationName, si.StationCode); } else { string[] s = Current.option.CurrentStation.Split(','); lbStationText = string.Format("{0}[{1}]", s[0], s[1]); } }
public bool StartGetPut() { if (!this.Plc.IsPingSuccess) { LogHelper.WriteError("无法连接到 " + this.Plc.IP); return(false); } //if (this.M76) //{ // return true; //} string msg = string.Empty; try { bool m = false; if (!this.Plc.GetInfo(false, PlcCompany.Mitsubishi, false, Current.option.RgvStartGetPutAdd, true, out m, out msg)) { Error.Alert(msg); this.Plc.IsAlive = false; return(false); } LogHelper.WriteInfo(string.Format("给RGV发送开始取放指令------{0}:true ", Current.option.RgvStartGetPutAdd)); } catch (Exception ex) { Error.Alert(ex); } return(true); }
public PLC(int id) { if (id < 0) { this.Id = -1; return; } string msg = string.Empty; DataTable dt = Database.Query("SELECT * FROM [dbo].[" + TableName + "] WHERE Id = " + id, out msg); if (!string.IsNullOrEmpty(msg)) { Error.Alert(msg); return; } if (dt == null || dt.Rows.Count == 0) { return; } Init(dt.Rows[0]); //释放资源 dt.Dispose(); }
public static List <MachineInfo> GetList(string sql, out string msg) { List <MachineInfo> list = new List <MachineInfo>(); DataTable dt = Database.Query(sql, out msg); if (!string.IsNullOrEmpty(msg)) { Error.Alert(msg); return(list); } if (dt == null || dt.Rows.Count == 0) { return(list); } else { for (int i = 0; i < dt.Rows.Count; i++) { MachineInfo machineInfo = new MachineInfo(); machineInfo.InitFields(dt.Rows[i]); list.Add(machineInfo); } } return(list); }
public UserGroup(int id) { if (id < 0) { this.Id = -1; return; } DataTable dt = null; string msg = string.Empty; dt = Database.Query("SELECT * FROM [dbo].[TengDa.UserGroup] WHERE Id = " + id, out msg); if (!string.IsNullOrEmpty(msg)) { Error.Alert(msg); LogHelper.WriteError(msg); return; } if (dt == null || dt.Rows.Count == 0) { return; } Init(dt.Rows[0]); //释放资源 dt.Dispose(); }
public static List <Battery> GetList(string sql, out string msg) { List <Battery> list = new List <Battery>(); DataTable dt = Database.Query(sql, out msg); if (!string.IsNullOrEmpty(msg)) { Error.Alert(msg); return(list); } if (dt == null || dt.Rows.Count == 0) { return(list); } else { for (int i = 0; i < dt.Rows.Count; i++) { Battery battery = new Battery(); battery.InitFields(dt.Rows[i]); list.Add(battery); } } return(list); }
public static void Save() { List <TVD> tvds = new List <TVD>(); for (int i = 0; i < Current.ovens.Count; i++) { if (Current.ovens[i].IsAlive) { for (int j = 0; j < Current.ovens[i].Floors.Count; j++) { if (Current.ovens[i].Floors[j].IsBaking) { //for(int k = 0;k< Current.ovens[i].Floors[j].Stations.Count; k++) //{ TVD tvd = new TVD(); tvd.FloorId = Current.ovens[i].Floors[j].Id; tvd.UserId = TengDa.WF.Current.user.Id; tvd.RunMinutes = Current.ovens[i].Floors[j].RunMinutes; tvd.T = Current.ovens[i].Floors[j].Temperatures; tvds.Add(tvd); //} } } } } string msg = string.Empty; if (!TVD.Add(tvds, out msg)) { Error.Alert(msg); } }
public static List <TechStandard> Get(int ClampId, out string msg) { List <TechStandard> techStandards = new List <TechStandard>(); DataTable dt = Database.Query(string.Format("SELECT * FROM [dbo].[{0}] WHERE ClampId = {1}", TableName, ClampId), out msg); if (!string.IsNullOrEmpty(msg)) { Error.Alert(msg); return(techStandards); } if (dt == null || dt.Rows.Count == 0) { return(techStandards); } for (int i = 0; i < dt.Rows.Count; i++) { TechStandard techStandard = new TechStandard(); techStandard.INSPECTION_ITEM = dt.Rows[i]["INSPECTION_ITEM"].ToString(); techStandard.INSPECTION_DESC = dt.Rows[i]["INSPECTION_DESC"].ToString(); techStandard.STANDARD = dt.Rows[i]["STANDARD"].ToString(); techStandard.UPPER_LIMIT = dt.Rows[i]["UPPER_LIMIT"].ToString(); techStandard.LOWER_LIMIT = dt.Rows[i]["LOWER_LIMIT"].ToString(); techStandards.Add(techStandard); } return(techStandards); }
public static List <Clamp> GetList(string sql, out string msg) { List <Clamp> list = new List <Clamp>(); DataTable dt = Database.Query(sql, out msg); if (!string.IsNullOrEmpty(msg)) { Error.Alert(msg); return(list); } if (dt == null || dt.Rows.Count == 0) { return(list); } else { for (int i = 0; i < dt.Rows.Count; i++) { Clamp clamp = new Clamp(); clamp.InitFields(dt.Rows[i]); list.Add(clamp); } } return(list); }
private void Button_Click(object sender, RoutedEventArgs e) { try { if ((BitmapImage)NewProfileImage.Source == null) { Tip.Alert("尚未选中新头像"); return; } var newProfilePicture = ((BitmapImage)NewProfileImage.Source).UriSource.ToString(); if (Current.App.UserProfilePicture == newProfilePicture) { Tip.Alert("请选择不同的头像"); return; } Current.App.UserProfilePicture = ((BitmapImage)NewProfileImage.Source).UriSource.ToString(); TengDa.Wpf.Context.UserContext.SaveChanges(); OperationHelper.ShowTips("更换头像成功!", true); } catch (Exception ex) { Error.Alert(ex); } }
public User(string name) { if (string.IsNullOrEmpty(name)) { this.Id = -1; return; } string msg = string.Empty; DataTable dt = Database.Query(string.Format("SELECT * FROM [dbo].[TengDa.Users] WHERE [Name] = '{0}'", name), out msg); if (!string.IsNullOrEmpty(msg)) { Error.Alert(msg); return; } if (dt == null || dt.Rows.Count == 0) { return; } Init(dt.Rows[0]); //释放资源 dt.Dispose(); }
public static List <User> GetList(string sql, out string msg) { List <User> list = new List <User>(); DataTable dt = Database.Query(sql, out msg); if (!string.IsNullOrEmpty(msg)) { Error.Alert(msg); return(list); } if (dt == null || dt.Rows.Count == 0) { return(list); } else { for (int i = 0; i < dt.Rows.Count; i++) { User user = new User(); user.InitFields(dt.Rows[i]); list.Add(user); } } return(list); }
public static void Add() { List <TVD> TVDs = new List <TVD>(); for (int i = 0; i < Current.ovens.Count; i++) { if (Current.ovens[i].IsAlive) { for (int j = 0; j < Current.ovens[i].Floors.Count; j++) { if (Current.ovens[i].Floors[j].IsBaking) { TVD tvd = new TVD(); tvd.FloorId = Current.ovens[i].Floors[j].Id; tvd.UserId = TengDa.WF.Current.user.Id; tvd.RunMinutes = Current.ovens[i].Floors[j].RunMinutes; tvd.T = Current.ovens[i].Floors[j].Temperatures; tvd.V1 = Current.ovens[i].Floors[j].Vacuum; TVDs.Add(tvd); } } } } string msg = string.Empty; if (!TVD.Add(TVDs, out msg)) { Error.Alert(msg); } }
/// <summary> /// 机器人报警复位 /// </summary> /// <param name="msg"></param> /// <returns></returns> public bool AlarmReset(out string msg) { new Thread(() => { //string msg = ""; if (!Current.Robot.Plc.SetInfo("D1101", (ushort)1, out string msg1)) { Error.Alert(msg1); this.Plc.IsAlive = false; } Thread.Sleep(2000); if (!Current.Robot.Plc.SetInfo("D1101", (ushort)0, out string msg2)) { Error.Alert(msg2); this.Plc.IsAlive = false; } if (string.IsNullOrEmpty(msg1) && string.IsNullOrEmpty(msg2)) { LogHelper.WriteInfo(string.Format("给机器人发送报警复位指令------{0}:先{1}后{2} ", "D1101", 1, 0)); } }).Start(); msg = ""; return(true); }
/// <summary> /// 根据SQL语句查询数据 /// </summary> /// <param name="sql"></param> /// <param name="msg"></param> /// <returns></returns> public static List <UploadTVD> GetList(string sql, out string msg) { var list = new List <UploadTVD>(); var dt = Database.Query(sql, out msg); if (!string.IsNullOrEmpty(msg)) { Error.Alert(msg); return(list); } if (dt == null || dt.Rows.Count == 0) { return(list); } else { for (int i = 0; i < dt.Rows.Count; i++) { var data = new UploadTVD(); data.InitFields(dt.Rows[i]); list.Add(data); } } return(list); }
public bool SetScanBatteryResult(ScanResult[] scanResults, out string msg) { ushort val; if (scanResults[0] == ScanResult.OK && scanResults[1] == ScanResult.OK) { val = (ushort)2; } else if (scanResults[0] == ScanResult.Error && scanResults[1] == ScanResult.OK) { val = (ushort)8; } else if (scanResults[0] == ScanResult.OK && scanResults[1] == ScanResult.Error) { val = (ushort)16; } else { val = (ushort)4; } if (!this.Plc.SetInfo("D1002", val, out msg)) { Error.Alert(msg); this.Plc.IsAlive = false; return(false); } LogHelper.WriteInfo(string.Format("成功发送电池扫码结果到{0} D1002:{1}【2:OK OK, 4:NG NG, 8: NG OK, 16: OK NG】", this.Plc.Name, val)); return(true); }
public void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { Byte[] InputBuf = new Byte[128]; try { if (IsPassiveReceiveSerialPort) { //接收数据 ReceiveString = ""; IsGetNewData = false; do { int count = SerialPort.BytesToRead; if (count <= 0) { break; } byte[] readBuffer = new byte[count]; SerialPort.Read(readBuffer, 0, count); ReceiveString += System.Text.Encoding.Default.GetString(readBuffer).Trim('\0').Trim('\r').Trim('\n'); Thread.Sleep(10); } while (SerialPort.BytesToRead > 0); IsAlive = true; IsGetNewData = true; } } catch (Exception ex) { IsAlive = false; Error.Alert(ex); } }
public static void DbClearAll() { string msg = string.Empty; if (!Database.NonQuery(string.Format("UPDATE [dbo].[{0}] SET [Col1] = '', [Col2] = '', [Col3] = ''", TableName), out msg)) { Error.Alert(msg); } }
public void AddLog(string message) { string msg = string.Empty; if (!AddLog(message, out msg)) { Error.Alert("炉层日志保存失败,原因:" + msg); } }
/// <summary> /// 条码是否属于当前批次 /// </summary> /// <param name="code"></param> /// <returns></returns> public bool IsMatchingCurrentBatch(string code) { var currentBatch = ""; var isMatchBatch = false; Current.Lines.ForEach(o1 => { o1.ChildLines.ForEach(o2 => { o2.Scaners.ForEach(o3 => { if (o3.Id == this.Id) { currentBatch = o1.CurrentBatch; isMatchBatch = o1.IsMatchBatch; } }); }); }); if (!isMatchBatch) { return(true); //不需要匹配批次 直接返回true } try { if (currentBatch.Length < 7) { throw new Exception("批次号长度小于7:" + currentBatch); } if (code.Length < 24) { throw new Exception("条码长度小于24:" + code); } } catch (Exception ex) { Error.Alert(ex); return(false); } //currentBatch: AESS84C //batch1: AESS var batch1 = currentBatch.Substring(0, 4); //batch2: 84C var batch2 = currentBatch.Substring(4, 3); bool matchingFlag = code.Substring(7, 4) == batch1 && code.Substring(14, 3) == batch2;//是否匹配 if (matchingFlag) { LogHelper.WriteInfo(string.Format("条码匹配批次号成功:{0}", code)); } else { LogHelper.WriteInfo(string.Format("条码匹配批次号失败:{0}", code)); } return(matchingFlag); }
protected void UpdateDbField(string field, object value) { string msg = string.Empty; if (!Database.UpdateField(Id, TableName, field, value.ToString(), out msg)) { Error.Alert(msg); } }
public static void Update(int i, int j, int k, string code) { string msg = string.Empty; if (!Database.NonQuery(string.Format("UPDATE [dbo].[{0}] SET [Col{1}] = '{2}' WHERE ClampId = {3} AND RowId = {4}", TableName, k + 1, code, i + 1, j + 1), out msg)) { Error.Alert(msg); } }
public static DataTable GetDataTable() { string msg = string.Empty; DataTable dt = Database.Query("SELECT * FROM [dbo].[" + TableName + "]", out msg); if (!string.IsNullOrEmpty(msg)) { Error.Alert(msg); } return(dt); }
/// <summary> /// 增加一条操作日志 /// </summary> /// <param name="userId">当前用户Id</param> /// <param name="description">操作内容字符串</param> /// <returns>返回是否插入日志成功</returns> public static bool Add(string description) { string msg = string.Empty; bool isSuccess = Database.NonQuery(string.Format("INSERT INTO [dbo].[{0}] ([UserId],[Description],[TIME]) VALUES ({1},'{2}',GETDATE());", TableName, Current.user.Id, description), out msg); if (!isSuccess) { Error.Alert(msg); } return(isSuccess); }
private void BtnBatteryBindInit_Click(object sender, EventArgs e) { if (Battery.BatteryBindInit(out string msg)) { Tip.Alert("电池绑定初始化成功!"); } else { Error.Alert("电池绑定初始化失败!msg:" + msg); } }
/// <summary> /// 启动机器人 /// </summary> /// <returns></returns> public bool Start(out string msg) { if (!Current.Robot.Plc.SetInfo("D1100", (ushort)1, out msg)) { Error.Alert(msg); this.Plc.IsAlive = false; return(false); } LogHelper.WriteInfo(string.Format("给机器人发送启动指令------{0}:{1} ", "D1100", 1)); return(true); }
/// <summary> /// 更新配置 /// </summary> /// <param name="key"></param> /// <param name="value"></param> /// <returns></returns> public static bool SetOption(string key, string value) { string msg = string.Empty; bool isSuccess = Database.NonQuery(string.Format("UPDATE [dbo].[{0}] SET [Value] = '{1}' WHERE [Key] = '{2}'", TableName, value, key), out msg); if (!isSuccess) { Error.Alert(msg); return(false); } return(isSuccess); }
/// <summary> /// 更新产量 /// </summary> /// <param name="key"></param> /// <param name="value"></param> /// <returns></returns> public static bool Set(YieldKey key, int value) { string msg = string.Empty; bool isSuccess = Database.NonQuery(string.Format("UPDATE [dbo].[{0}] SET [Value] = {1} WHERE [Key] = '{2}'", TableName, value, key), out msg); if (!string.IsNullOrEmpty(msg)) { Error.Alert(msg); return(false); } return(isSuccess); }
/// <summary> /// 控制货叉伸入 /// </summary> /// <returns></returns> public bool Enter(out string msg) { if (!this.Plc.SetInfo("D1010", (ushort)1, out msg)) { Error.Alert(msg); this.Plc.IsAlive = false; return(false); } LogHelper.WriteInfo(string.Format("给RGV发送货叉伸入指令------{0}:{1} ", "D1010", 1)); return(true); }