Ejemplo n.º 1
0
        /// <summary>
        /// 上传真空温度数据
        /// </summary>
        /// <param name="uploadTVDs"></param>
        /// <returns></returns>
        public static async System.Threading.Tasks.Task UploadTvdInfoAsync(List <UploadTVD> uploadTVDs)
        {
            for (int i = 0; i < uploadTVDs.Count; i++)
            {
                try
                {
                    bool isClampUploadSuccess = true;

                    var uploadTVD = uploadTVDs[i];
                    var clamp     = new Clamp(uploadTVD.ClampId);
                    var station   = Station.StationList.FirstOrDefault(s => s.Id == clamp.OvenStationId);
                    if (station != null)
                    {
                        var floor = station.GetFloor();
                        var oven  = floor.GetOven();

                        if (clamp.Batteries.Count > 0)
                        {
                            var battery = clamp.Batteries[0];

                            var uploadDatas = new List <UploadData>();
                            var uploadData  = new UploadData();

                            uploadData.batch_number   = battery.Code.Split('-')[0];
                            uploadData.parameter_flag = uploadTVD.ParameterFlag.ToString();
                            uploadData.device_status  = uploadTVD.DeviceStatus.ToString();
                            uploadData.collector_time = uploadTVD.CollectorTime.ToString("yyyy-MM-dd HH:mm:ss");

                            uploadData.materialCodeInfo = new List <MaterialCodeInfo>();
                            uploadData.materialCodeInfo.Add(new MaterialCodeInfo()
                            {
                                materialCodeName = "电芯编号",
                                materialCode     = battery.Code
                            });

                            uploadData.deviceCodeInfo = new List <DeviceCodeInfo>();
                            uploadData.deviceCodeInfo.Add(new DeviceCodeInfo()
                            {
                                deviceCodeName = "机台号",
                                deviceCode     = oven.Number
                            });
                            uploadData.deviceCodeInfo.Add(new DeviceCodeInfo()
                            {
                                deviceCodeName = "烤箱编号",
                                deviceCode     = station.Number
                            });
                            uploadData.deviceCodeInfo.Add(new DeviceCodeInfo()
                            {
                                deviceCodeName = "料框编号",
                                deviceCode     = clamp.Code
                            });

                            uploadData.deviceParamData = new List <DeviceParamData>();
                            for (int k = 0; k < Option.TemperaturePointCount; k++)
                            {
                                uploadData.deviceParamData.Add(new DeviceParamData
                                {
                                    parameter_name  = Current.option.TemperNames[k] + "实际值",
                                    parameter_unit  = "℃",
                                    parameter_value = uploadTVD.T[k].ToString()
                                });
                            }

                            uploadData.deviceParamData.Add(new DeviceParamData
                            {
                                parameter_name  = "真空度实际值",
                                parameter_unit  = "Pa",
                                parameter_value = uploadTVD.V1.ToString()
                            });

                            uploadDatas.Add(uploadData);
                            if (await UploadAsync(uploadDatas))
                            {
                                //LogHelper.WriteInfo("上传MES成功 UploadTvdInfoAsync  battery.Id: " + battery.Id + " uploadData.collector_time:" + uploadData.collector_time);
                            }
                            else
                            {
                                isClampUploadSuccess = false;
                                break;
                            }
                        }
                    }

                    if (isClampUploadSuccess)
                    {
                        LogHelper.WriteInfo("上传MES成功 UploadTvdInfoAsync  uploadTVD.Id: " + uploadTVD.Id);
                        uploadTVD.IsUploaded = true;
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteError("上传MES出现错误,方法:UploadTvdInfoAsync 原因:" + ex.ToString());
                }
            }
        }
Ejemplo n.º 2
0
 public static bool Update(Clamp newClamp, out string msg)
 {
     msg = "";
     return(true);
     //return Database.NonQuery(string.Format("UPDATE [dbo].[{0}] SET [EnterTime] = '{1}', [OutTime] = '{2}', [BakingStartTime] = '{3}', [BakingStopTime] = '{4}', [Vacuum] = {5}, [Temperature] = {6}, [IsUploaded] = '{7}', [IsFinished] = '{8}' WHERE [Id] = {9}", TableName, newClamp.EnterTime, newClamp.OutTime, newClamp.BakingStartTime, newClamp.BakingStopTime, newClamp.Vacuum, newClamp.Temperature, newClamp.IsUploaded, newClamp.IsFinished, newClamp.Id), out msg);
 }
Ejemplo n.º 3
0
        public static void Run()
        {
            string msg = string.Empty;

            if (Current.TaskMode == TaskMode.自动任务)
            {
                ////烤箱只有一个空位时,不要搬运空夹具至烤箱

                //if (Task.TaskList.Where(t => t.FromClampStatus == ClampStatus.空夹具 && t.ToType == GetPutType.烤箱).ToList().Count(t => t.IsEnable) > 0)
                //{

                //}

                //List<Station> stations = Station.StationList.Where(s => s.IsAlive && s.GetPutType == GetPutType.烤箱 && s.FloorStatus == FloorStatus.无盘).ToList();
                //Task.TaskList.Where(t => t.FromClampStatus == ClampStatus.空夹具 && t.ToType == GetPutType.烤箱).ToList().
                //    ForEach(t => t.IsEnable = stations.Count > 1);



                if (Current.Task.Status == TaskStatus.完成)
                {
                    if (CurrentTask.ToSwitchManuTaskMode)
                    {
                        Current.Task.StartTime       = TengDa.Common.DefaultTime;
                        Current.Task.TaskId          = -1;
                        Current.Task.FromStationId   = -1;
                        Current.Task.ToStationId     = -1;
                        Current.Task.FromClampStatus = ClampStatus.未知;

                        Current.TaskMode = TaskMode.手动任务;
                        CurrentTask.ToSwitchManuTaskMode = false;
                        return;
                    }
                    ///任务遍历
                    foreach (Task task in Task.CanGetPutTaskList.Where(t => t.IsEnable))
                    {
                        List <Station> fromStations = Station.CanGetPutStationList
                                                      .Where(s => s.ClampOri == task.ClampOri &&
                                                             s.GetPutType == task.FromType && s.ClampStatus == task.FromClampStatus &&
                                                             s.Status == StationStatus.可取 &&
                                                             s.SampleStatus == task.FromSampleStatus)
                                                      .OrderBy(s => s.Priority)
                                                      .OrderBy(s => s.GetPutTime)
                                                      .ToList();
                        List <Station> toStations = Station.CanGetPutStationList
                                                    .Where(s => s.ClampOri == task.ClampOri &&
                                                           s.GetPutType == task.ToType && s.ClampStatus == task.ToClampStatus &&
                                                           s.Status == StationStatus.可放 &&
                                                           s.SampleStatus == task.ToSampleStatus)
                                                    .OrderBy(s => s.Priority)
                                                    .OrderBy(s => s.GetPutTime)
                                                    .ToList();

                        if (fromStations.Count > 0 && toStations.Count > 0)
                        {
                            if (task.FromClampStatus == ClampStatus.满夹具 && task.FromType == GetPutType.烤箱)
                            {
                                fromStations = fromStations.OrderBy(s => s.GetFillClampPriority).ToList();
                            }
                            if (task.FromClampStatus == ClampStatus.空夹具 && task.FromType == GetPutType.烤箱)
                            {
                                fromStations = fromStations.OrderBy(s => s.GetEmptyClampPriority).ToList();
                            }
                            if (task.FromClampStatus == ClampStatus.满夹具 && task.ToType == GetPutType.烤箱)
                            {
                                toStations = toStations.OrderBy(s => s.PutFillClampPriority).ToList();
                            }
                            if (task.FromClampStatus == ClampStatus.空夹具 && task.ToType == GetPutType.烤箱)
                            {
                                toStations = toStations.Where(s => s.CanPutEmptyClamp).OrderBy(s => s.PutEmptyClampPriority).ToList();
                            }

                            Station fromStation = fromStations.First();
                            Station toStation   = toStations.First();
                            Current.Task.StartTime       = DateTime.Now;
                            Current.Task.TaskId          = task.Id;
                            Current.Task.FromStationId   = fromStation.Id;
                            Current.Task.ToStationId     = toStation.Id;
                            Current.Task.FromClampStatus = fromStation.ClampStatus;
                            Current.Task.PreCycleOrder   = task.CycleOrder;
                            Current.Task.Status          = TaskStatus.就绪;
                            break;
                        }
                        else
                        {
                            Current.Task.StartTime       = TengDa.Common.DefaultTime;
                            Current.Task.TaskId          = -1;
                            Current.Task.FromStationId   = -1;
                            Current.Task.ToStationId     = -1;
                            Current.Task.FromClampStatus = ClampStatus.未知;
                            Current.Task.Status          = TaskStatus.完成;
                        }
                    }
                }

                else if (Current.Task.FromStationId > 0 && Current.Task.ToStationId > 0 && Current.Task.FromStation != null && Current.Task.ToStation != null)
                {
                    if (Current.Task.Status == TaskStatus.就绪)
                    {
                        if (Current.Task.FromStation.DoorStatus != DoorStatus.打开)
                        {
                            Current.Task.FromStation.OpenDoor();
                        }

                        if (Current.Task.FromStation.DoorStatus == DoorStatus.打开)
                        {
                            Current.Task.Status = TaskStatus.可取;
                        }
                    }
                    else if (Current.Task.Status == TaskStatus.可取 && Current.Task.FromStation != null)
                    {
                        byte pos = byte.Parse(Current.Task.FromStation.RobotValues.Split(',')[0]);
                        if (Current.Robot.IsReadyGet)
                        {
                            if (Current.Robot.GetOrPut(pos))
                            {
                            }
                        }

                        if (Current.Robot.IsGettingOrPutting)
                        {
                            Current.Task.Status = TaskStatus.正取;
                        }
                    }
                    else if (Current.Task.Status == TaskStatus.正取 && Current.Task.FromStation != null)
                    {
                        //提前把放盘位门打开
                        if (Current.Task.ToStation.DoorStatus != DoorStatus.打开 && Current.Task.ToStation != null && Current.Task.ToStation.GetPutType == GetPutType.烤箱)
                        {
                            Current.Task.ToStation.OpenDoor();
                        }

                        if (Current.Robot.ClampStatus != ClampStatus.无夹具)
                        {
                            Current.Robot.ClampStatus            = Current.Task.FromClampStatus;
                            Current.Task.FromStation.ClampStatus = ClampStatus.无夹具;
                            if (Current.Task.FromStation.ClampId > 0)
                            {
                                Current.Robot.ClampId = Current.Task.FromStation.ClampId;
                            }
                        }

                        if (!Current.Robot.IsGettingOrPutting)
                        {
                            Current.Task.Status = TaskStatus.取完;
                        }
                    }
                    else if (Current.Task.Status == TaskStatus.取完 && Current.Task.ToStation != null)
                    {
                        if (Current.Task.ToStation.DoorStatus != DoorStatus.打开)
                        {
                            Current.Task.ToStation.OpenDoor();
                        }
                        else
                        {
                            Current.Task.Status = TaskStatus.可放;
                        }
                    }
                    else if (Current.Task.Status == TaskStatus.可放 && Current.Task.ToStation != null)
                    {
                        byte pos = byte.Parse(Current.Task.ToStation.RobotValues.Split(',')[1]);

                        if (Current.Robot.IsReadyPut)
                        {
                            if (Current.Robot.GetOrPut(pos))
                            {
                            }
                        }

                        if (Current.Robot.IsGettingOrPutting)
                        {
                            Current.Task.Status = TaskStatus.正放;
                        }
                    }
                    else if (Current.Task.Status == TaskStatus.正放 && Current.Task.ToStation != null)
                    {
                        if (Current.Robot.ClampStatus == ClampStatus.无夹具)
                        {
                            Current.Task.ToStation.ClampStatus   = Current.Task.FromClampStatus;
                            Current.Task.ToStation.FromStationId = Current.Task.FromStationId;

                            if (Current.Task.ToStation.ClampId < 1 && Current.Task.ToStation.GetPutType == GetPutType.料机 && Current.Task.FromClampStatus == ClampStatus.空夹具)
                            {
                                int oldClampId = -1;
                                if (Current.Task.FromStation != null)
                                {
                                    oldClampId = Current.Task.FromStation.ClampId;
                                }
                                if (oldClampId < 1)
                                {
                                    oldClampId = Current.Robot.ClampId;
                                }

                                int clampId = Clamp.Add(new Clamp(oldClampId).Code, out msg);
                                if (clampId > 0)
                                {
                                    Current.Task.ToStation.ClampId = clampId;
                                }
                                else
                                {
                                    LogHelper.WriteError(msg);
                                }
                            }
                            else
                            {
                                if (Current.Task.FromStation != null && Current.Task.FromStation.ClampId > 0)
                                {
                                    Current.Task.ToStation.ClampId = Current.Task.FromStation.ClampId;
                                }
                                else if (Current.Robot.ClampId > 0)
                                {
                                    Current.Task.ToStation.ClampId = Current.Robot.ClampId;
                                }
                            }
                            Current.Robot.ClampId = -1;
                            if (Current.Task.FromStation != null)
                            {
                                Current.Task.FromStation.ClampId = -1;
                            }
                        }

                        if (!Current.Robot.IsGettingOrPutting)
                        {
                            if (!TaskLog.Add(out msg))//记录
                            {
                                Error.Alert("保存搬运记录失败:" + msg);
                            }
                            Current.Task.Status = TaskStatus.完成;
                        }
                    }
                }
            }
            else if (Current.TaskMode == TaskMode.手动任务)
            {
                if (Current.Task.Status == TaskStatus.完成)
                {
                    Current.Task.StartTime       = TengDa.Common.DefaultTime;
                    Current.Task.TaskId          = -1;
                    Current.Task.FromStationId   = -1;
                    Current.Task.ToStationId     = -1;
                    Current.Task.FromClampStatus = ClampStatus.未知;
                    Current.Task.Status          = TaskStatus.完成;

                    if (Current.Task.NextFromStationId > 0)
                    {
                        Current.Task.FromStationId     = Current.Task.NextFromStationId;
                        Current.Task.NextFromStationId = -1;
                        Current.Task.FromClampStatus   = Current.Task.FromStation.ClampStatus;
                        Current.Task.Status            = TaskStatus.就绪;
                    }
                }
                else if (Current.Task.Status == TaskStatus.就绪 && Current.Task.FromStation != null)
                {
                    if (Current.Task.FromStation.DoorStatus != DoorStatus.打开)
                    {
                        Tip.Alert(Current.Task.FromStation.Name + "门未打开!");
                    }

                    if (Current.Task.FromStation.DoorStatus == DoorStatus.打开)
                    {
                        Current.Task.Status = TaskStatus.可取;
                    }
                }
                else if (Current.Task.Status == TaskStatus.可取 && Current.Task.FromStation != null)
                {
                    byte pos = byte.Parse(Current.Task.FromStation.RobotValues.Split(',')[0]);
                    if (Current.Robot.IsReadyGet)
                    {
                        if (Current.Robot.GetOrPut(pos))
                        {
                        }
                    }

                    if (Current.Robot.IsGettingOrPutting)
                    {
                        Current.Task.Status = TaskStatus.正取;
                    }
                }
                else if (Current.Task.Status == TaskStatus.正取 && Current.Task.FromStation != null)
                {
                    if (Current.Robot.ClampStatus != ClampStatus.无夹具)
                    {
                        Current.Robot.ClampStatus            = Current.Task.FromClampStatus;
                        Current.Task.FromStation.ClampStatus = ClampStatus.无夹具;
                        if (Current.Task.FromStation.ClampId > 0)
                        {
                            Current.Robot.ClampId = Current.Task.FromStation.ClampId;
                        }
                    }

                    if (!Current.Robot.IsGettingOrPutting)
                    {
                        Current.Task.Status = TaskStatus.取完;
                    }
                }
                else if (Current.Task.Status == TaskStatus.取完)
                {
                    if (Current.Task.NextToStationId > 0)
                    {
                        Current.Task.ToStationId     = Current.Task.NextToStationId;
                        Current.Task.NextToStationId = -1;
                    }
                    if (Current.Task.ToStation != null)
                    {
                        if (Current.Task.ToStation.DoorStatus != DoorStatus.打开)
                        {
                            Tip.Alert(Current.Task.ToStation.Name + "门未打开!");
                        }
                        if (Current.Task.ToStation.DoorStatus == DoorStatus.打开)
                        {
                            Current.Task.Status = TaskStatus.可放;
                        }
                    }
                }
                else if (Current.Task.Status == TaskStatus.可放 && Current.Task.ToStation != null)
                {
                    byte pos = byte.Parse(Current.Task.ToStation.RobotValues.Split(',')[1]);

                    if (Current.Robot.IsReadyPut)
                    {
                        if (Current.Robot.GetOrPut(pos))
                        {
                        }
                    }

                    if (Current.Robot.IsGettingOrPutting)
                    {
                        Current.Task.Status = TaskStatus.正放;
                    }
                }
                else if (Current.Task.Status == TaskStatus.正放 && Current.Task.ToStation != null)
                {
                    if (Current.Robot.ClampStatus == ClampStatus.无夹具)
                    {
                        Current.Task.ToStation.ClampStatus   = Current.Task.FromClampStatus;
                        Current.Task.ToStation.FromStationId = Current.Task.FromStationId;

                        if (Current.Task.ToStation.ClampId < 1 && Current.Task.ToStation.GetPutType == GetPutType.料机 && Current.Task.FromClampStatus == ClampStatus.空夹具)
                        {
                            int oldClampId = -1;
                            if (Current.Task.FromStation != null)
                            {
                                oldClampId = Current.Task.FromStation.ClampId;
                            }
                            if (oldClampId < 1)
                            {
                                oldClampId = Current.Robot.ClampId;
                            }

                            int clampId = Clamp.Add(new Clamp(oldClampId).Code, out msg);
                            if (clampId > 0)
                            {
                                Current.Task.ToStation.ClampId = clampId;
                            }
                            else
                            {
                                LogHelper.WriteError(msg);
                            }
                        }
                        else
                        {
                            if (Current.Task.FromStation != null && Current.Task.FromStation.ClampId > 0)
                            {
                                Current.Task.ToStation.ClampId = Current.Task.FromStation.ClampId;
                            }
                            else if (Current.Robot.ClampId > 0)
                            {
                                Current.Task.ToStation.ClampId = Current.Robot.ClampId;
                            }
                        }
                        Current.Robot.ClampId = -1;
                        if (Current.Task.FromStation != null)
                        {
                            Current.Task.FromStation.ClampId = -1;
                        }
                    }

                    if (!Current.Robot.IsGettingOrPutting)
                    {
                        if (!TaskLog.Add(out msg))//记录
                        {
                            Error.Alert("保存搬运记录失败:" + msg);
                        }
                        Current.Task.Status = TaskStatus.完成;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public static bool Delete(Clamp delClamp, out string msg)
 {
     return(Database.NonQuery(string.Format("DELETE FROM [dbo].[{0}] WHERE [Code] = '{1}'", TableName, delClamp.Code), out msg));
 }