Example #1
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);
 }
Example #2
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));
 }
Example #3
0
        public bool GetInfo()
        {
            lock (this)
            {
                if (!this.Plc.IsPingSuccess)
                {
                    this.Plc.IsAlive = false;
                    LogHelper.WriteError("无法连接到 " + this.Plc.IP);
                    return(false);
                }

                string msg    = string.Empty;
                string output = string.Empty;

                try
                {
                    #region 获取信息
                    var plcCompany = (PlcCompany)Enum.Parse(typeof(PlcCompany), this.Plc.Company);

                    var addr = Option.LineNum == 1 ? "DB17.0" : "DB17.4";

                    if (!this.Plc.GetInfo(false, plcCompany, true, addr, (ushort)0, out ushort db17_0, out msg))
                    {
                        Error.Alert(msg);
                        this.Plc.IsAlive = false;
                        return(false);
                    }
                    this.PutStation.ClampStatus = db17_0 == 2 ? ClampStatus.无夹具 : ClampStatus.满夹具;
                    this.PutStation.Status      = db17_0 == 2 ? StationStatus.可放 : StationStatus.工作中;

                    if (db17_0 == 2)
                    {
                        this.PutStation.ClampId = -1;
                    }

                    addr = Option.LineNum == 1 ? "DB17.2" : "DB17.6";
                    if (!this.Plc.GetInfo(false, plcCompany, true, addr, (ushort)0, out ushort db17_2, out msg))
                    {
                        Error.Alert(msg);
                        this.Plc.IsAlive = false;
                        return(false);
                    }

                    if (db17_2 == 2 && this.GetStation.ClampStatus != ClampStatus.满夹具 && this.GetStation.ClampId < 1)
                    {
                        var clampCode = Current.Feeder.PopClampCode();
                        if (!string.IsNullOrEmpty(clampCode))
                        {
                            this.GetStation.ClampId = Clamp.Add(clampCode);
                        }
                        else
                        {
                            //没有缓存条码时生成随机码
                            this.GetStation.ClampId = Clamp.Add(Guid.NewGuid().ToString().Substring(0, 8).ToUpper());
                        }
                    }

                    this.GetStation.ClampStatus = db17_2 == 2 ? ClampStatus.满夹具 : ClampStatus.无夹具;
                    this.GetStation.Status      = db17_2 == 2 ? StationStatus.可取 : StationStatus.工作中;

                    //获取夹具扫码信号
                    if (Current.ClampScaner.IsEnable)
                    {
                        addr = Option.LineNum == 1 ? "DB17.8" : "DB17.12";
                        if (!this.Plc.GetInfo(false, plcCompany, true, addr, (ushort)0, out ushort db17_8, out msg))
                        {
                            Error.Alert(msg);
                            this.Plc.IsAlive = false;
                            return(false);
                        }

                        if (db17_8 == 2)
                        {
                            if (!Current.ClampScaner.IsReady)
                            {
                                Current.ClampScaner.CanScan = true;
                            }
                            Current.ClampScaner.IsReady = true;
                        }
                        else
                        {
                            Current.ClampScaner.IsReady = false;
                            Current.ClampScaner.CanScan = false;
                        }
                    }

                    //心跳
                    addr = Option.LineNum == 1 ? "DB17.28" : "DB17.30";

                    if (!this.Plc.GetInfo(false, plcCompany, false, addr, this.HeartValue, out ushort db17_28, out msg))
                    {
                        Error.Alert(msg);
                        this.Plc.IsAlive = false;
                    }

                    this.HeartValue = this.HeartValue == 0 ? (ushort)2 : (ushort)0;

                    //自动手动模式传给上料机
                    addr = Option.LineNum == 1 ? "DB17.32" : "DB17.34";

                    var value = (ushort)0;
                    if (Current.TaskMode == TaskMode.自动任务 && Current.RGV.IsAuto)
                    {
                        value = (ushort)2;
                    }

                    if (!this.Plc.GetInfo(false, plcCompany, false, addr, value, out ushort db17_32, out msg))
                    {
                        Error.Alert(msg);
                        this.Plc.IsAlive = false;
                    }

                    #endregion
                    Thread.Sleep(20);
                }
                catch (Exception ex)
                {
                    Error.Alert(ex);
                }

                this.Plc.IsAlive       = true;
                this.AlreadyGetAllInfo = true;
            }

            this.TriLamp = this.Plc.IsAlive ? TriLamp.Green : TriLamp.Unknown;
            return(true);
        }
Example #4
0
 public static int Add(Clamp addClamp, out string msg)
 {
     return(Database.Insert(string.Format("INSERT INTO [dbo].[{0}] ([Code], [UserId], [OvenStationId], [Location], [BakingStartTime], [BakingStopTime], [ScanTime], [InOvenTime], [OutOvenTime], [IsFinished], [IsUploaded], [IsDownloaded], [Temperature], [Vacuum], [SampleInfo], [MoCode], [BakingResult], [Shift], [BakingTime]) VALUES ('{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', '{14}', '{15}', '{16}', '{17}', '{18}', '{19}')", TableName,
                                          addClamp.Code, TengDa.WF.Current.user.Id, addClamp.OvenStationId, addClamp.Location, addClamp.BakingStartTime, addClamp.BakingStopTime, addClamp.ScanTime, addClamp.InOvenTime, addClamp.OutOvenTime, addClamp.IsFinished, addClamp.IsUploaded, addClamp.IsDownloaded, addClamp.Temperature, addClamp.Vacuum, addClamp.SampleInfo, addClamp.MoCode, addClamp.BakingResult, addClamp.Shift, addClamp.BakingTime), out msg));
 }
Example #5
0
        public static bool UploadSecondaryHighTempData(Clamp clamp)
        {
            try
            {
                if (!Current.mes.IsPingSuccess)
                {
                    throw new Exception("无法连接到MES服务器:" + Current.mes.Host);
                }

                var batteries = clamp.Batteries;
                if (batteries.Count == 0)
                {
                    LogHelper.WriteInfo(string.Format("二次高温电池数据上传MES时,检测到{0}无绑定的电池数据,ID:{1}", clamp.Code, clamp.Id));
                    clamp.IsUploaded = true;
                    return(true);
                }

                List <ProductionDataUploadRequest.TestData> testDataList = new List <ProductionDataUploadRequest.TestData>();
                batteries.ForEach(o =>
                {
                    testDataList.Add(new ProductionDataUploadRequest.TestData()
                    {
                        MoCode            = clamp.MoCode,
                        TrayBarcode       = clamp.Code,
                        Barcode           = o.Code,
                        Position          = o.Location,
                        Result            = clamp.BakingResult,
                        BakingTime        = clamp.BakingTime.ToString(),
                        BakingTemperature = clamp.Temperature.ToString("#0.00")
                    });
                });

                var request = new ProductionDataUploadRequest()
                {
                    DeviceId       = Current.mes.DeviceId,
                    Operator       = Current.mes.Username,
                    ProcessCode    = Current.mes.ProcessCode,
                    StationCode    = Current.mes.StationCode,
                    ProductionTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    TestDatas      = testDataList.ToArray(),
                    Shift          = clamp.Shift
                };

                var xmlRequest  = XmlHelper.Serialize(request).Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
                var xmlResponse = ProductionDataUploadProxy.UploadSecondaryHighTempData(xmlRequest);
                var response    = XmlHelper.Deserialize <ProductionDataUploadResponse>(xmlResponse);
                if (response.Result)
                {
                    //LogHelper.WriteInfo(string.Format("二次高温电池数据上传MES成功,xmlRequest:{0},xmlResponse:{1}", xmlRequest, xmlResponse));
                    //LogHelper.WriteInfo(string.Format("二次高温电池数据上传MES成功"));
                }
                else
                {
                    LogHelper.WriteInfo(string.Format("二次高温电池数据上传MES失败,原因:{0} xmlRequest:{1},xmlResponse:{2}", response.Message, xmlRequest, xmlResponse));
                }
                clamp.IsUploaded = true;
                return(response.Result);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex);
                LogHelper.WriteInfo(string.Format("烤箱状态上传MES报错:{0}", ex.Message));
            }
            return(false);
        }