public IHttpActionResult PutWeigh(int id, Weigh weigh)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != weigh.Id)
            {
                return(BadRequest());
            }

            db.Entry(weigh).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WeighExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        private void Customs_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Weigh      tw = new Weigh();
            MainWindow mw = System.Windows.Window.GetWindow(this) as MainWindow;

            mw.ContentSource = new Uri("/Pages/Tran/Customs.xaml", UriKind.RelativeOrAbsolute);
        }
Esempio n. 3
0
 public static void  Total(Weigh weigh)
 {
     if (MeasureMath.FirstId == MeasureMath.SecondId)
     {
         weigh.WeighMaterial = MeasureMath.SecondWeighFull - MeasureMath.SecondWeighPacking - MeasureMath.FirstWeighFull - MeasureMath.FirstWeighPacking;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 设置数据点的值
        /// </summary>
        public void SetValue(string lineChartName, Weigh w)
        {
            int counts = Convert.ToInt32(w.Flow.Counts);

            if (Exsit(lineChartName))
            {
                LineChart lc    = GetLineChart(lineChartName);
                int       index = (w.GroupIndex - 1) * counts + w.CountIndex - 1;

                switch (w.Flow.AisleIdShow)
                {
                case "1":
                {
                    if (lc.ListData1.Contains(w))
                    {
                        lc.ListData1[index].WeighValue = w.WeighValue;
                        lc.ListData1[index].WeighTp    = w.WeighTp;
                    }
                    else
                    {
                        lc.ListData1.Add(w);
                    }
                }
                break;

                case "2":
                {
                    if (lc.ListData2.Contains(w))
                    {
                        lc.ListData2[index].WeighValue = w.WeighValue;
                        lc.ListData2[index].WeighTp    = w.WeighTp;
                    }
                    else
                    {
                        lc.ListData2.Add(w);
                    }
                }
                break;

                case "3":
                {
                    if (lc.ListData3.Contains(w))
                    {
                        lc.ListData3[index].WeighValue = w.WeighValue;
                        lc.ListData3[index].WeighTp    = w.WeighTp;
                    }
                    else
                    {
                        lc.ListData3.Add(w);
                    }
                }
                break;

                default:
                    break;
                }
                _drawLine(lc);
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Weigh weigh = db.Weighs.Find(id);

            db.Weighs.Remove(weigh);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 6
0
 public static void FirstMeasure(Weigh weigh)
 {
     if (weigh.WeighPacking == null)
     {
         weigh.WeighPacking = 0;
     }
     MeasureMath.FirstWeighPacking = weigh.WeighPacking;
     MeasureMath.FirstWeighFull    = weigh.WeighFull;
     MeasureMath.FirstId           = weigh.OrderId;
 }
Esempio n. 7
0
 public static void SecondMeasure(Weigh weigh)
 {
     if (weigh.WeighPacking == null)
     {
         weigh.WeighPacking = 0;
     }
     MeasureMath.SecondWeighPacking = weigh.WeighPacking;
     MeasureMath.SecondWeighFull    = weigh.WeighFull;
     MeasureMath.SecondId           = weigh.OrderId;
 }
 public ActionResult Edit([Bind(Include = "Id,WeighFull,WeighPacking,WeighMaterial,WeighType,WeighDetermine,WeighContamination,OrderId,AuditDate")] Weigh weigh)
 {
     if (ModelState.IsValid)
     {
         db.Entry(weigh).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OrderId = new SelectList(db.Orders, "Id", "Id", weigh.OrderId);
     return(View(weigh));
 }
        public IHttpActionResult GetWeigh(int id)
        {
            Weigh weigh = db.Weighs.Find(id);

            if (weigh == null)
            {
                return(NotFound());
            }

            return(Ok(weigh));
        }
        public IHttpActionResult PostWeigh(Weigh weigh)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Weighs.Add(weigh);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = weigh.Id }, weigh));
        }
Esempio n. 11
0
 public static void SelectMeasure(Weigh weigh)
 {
     if (weigh.WeighDetermine == false)
     {
         MeasureMath.SecondMeasure(weigh);
     }
     if (weigh.WeighDetermine == true)
     {
         MeasureMath.FirstMeasure(weigh);
     }
     Total(weigh);
 }
        // GET: Weighs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Weigh weigh = db.Weighs.Find(id);

            if (weigh == null)
            {
                return(HttpNotFound());
            }
            return(View(weigh));
        }
        public ActionResult Create(Weigh weigh)
        {
            if (ModelState.IsValid)
            {
                db.Weighs.Add(weigh);
                MeasureMath.SelectMeasure(weigh);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            ViewBag.OrderId = new SelectList(db.Orders, "Id", "Id", weigh.OrderId);
            return(View(weigh));
        }
        public IHttpActionResult DeleteWeigh(int id)
        {
            Weigh weigh = db.Weighs.Find(id);

            if (weigh == null)
            {
                return(NotFound());
            }

            db.Weighs.Remove(weigh);
            db.SaveChanges();

            return(Ok(weigh));
        }
        // GET: Weighs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Weigh weigh = db.Weighs.Find(id);

            if (weigh == null)
            {
                return(HttpNotFound());
            }
            ViewBag.OrderId = new SelectList(db.Orders, "Id", "Id", weigh.OrderId);
            return(View(weigh));
        }
Esempio n. 16
0
 /// <summary>
 /// 发送获取称量值
 /// </summary>
 /// <param name="w"></param>
 public void SendGetValue(Weigh w)
 {
     model.SendGetValue(w);
 }
Esempio n. 17
0
        /// <summary>
        /// 加液
        /// </summary>
        public void AddLiquid(Flow flow, int groupIndex)
        {
            IsEndAdd = false;
            XmlDocument xd = new XmlDocument();

            xd.Load("Config/CmdConfig.xml");
            XmlNode cmdNode = xd.SelectSingleNode("Cmds/Cmd/DispatchCmd[@strMemo='加液']");
            XmlAttributeCollection attList = cmdNode.FirstChild.FirstChild.Attributes;
            //循环次数发送加液命令
            int counts = Convert.ToInt32(flow.Counts);

            for (int i = 1; i <= counts; i++)
            {
                attList["strLqdName"].Value = flow.ChargingPrecision;
                Console.WriteLine("加液量 = " + flow.AddFluidVolume);

                attList["dwTipsMask"].Value = flow.AisleId;
                if (flow.AisleId.Equals("4"))
                {
                    attList["pchRackName"].Value = "ReacationStripRack1,ReacationStripRack1," + flow.AddFluidPos.Split('-')[0];
                    attList["awHoleArr"].Value   = "0,0," + flow.AddFluidPos.Split('-')[1];
                    attList["awVolArr"].Value    = "0,0" + flow.AddFluidVolume.ToString();
                }
                else
                {
                    if (flow.AisleId.Equals("1"))
                    {
                        attList["pchRackName"].Value = flow.AddFluidPos.Split('-')[0] + ",ReacationStripRack1,ReacationStripRack1";
                        attList["awHoleArr"].Value   = flow.AddFluidPos.Split('-')[1] + ",0,0";
                        attList["awVolArr"].Value    = flow.AddFluidVolume.ToString() + ",0,0";
                    }
                    else if (flow.AisleId.Equals("2"))
                    {
                        attList["pchRackName"].Value = "ReacationStripRack1," + flow.AddFluidPos.Split('-')[0] + ",ReacationStripRack1";
                        attList["awHoleArr"].Value   = "0," + flow.AddFluidPos.Split('-')[1] + ",0";
                        attList["awVolArr"].Value    = "0," + flow.AddFluidVolume.ToString() + ",0";
                    }
                }
                XmlElement el = cmdNode as XmlElement;
                //Console.WriteLine("-----发送去皮指令");
                if (i == 1)
                {
                    Thread.Sleep(4000);
                }
                WaitEvent.Reset();
                ManagerPlant.serialPortManager.SendRemoveThePeel();
                //ManagerPlant.sendDataManager.WaitEvent.Set();
                //Thread.Sleep(3000);
                WaitEvent.WaitOne();

                WaitEvent.Reset();
                ManagerPlant.aiKangManager.ClsModule.SendXmlElement(el, "Module_AiKang_Service");
                //Console.WriteLine("加液等待");
                WaitEvent.WaitOne();
                //Console.WriteLine("加液等待结束");

                //Console.WriteLine("等待6秒天平稳定");
                //等待两秒天平稳定
                Thread.Sleep(6000);
                //Console.WriteLine("6秒后,开始获取称量值");

                //获取读数
                Weigh w = flow.Dict[groupIndex][i - 1];
                if (w == null)
                {
                    ManagerPlant.logManager.WriteLog("获取称量值失败,称量值对象为NULL。");
                }
                else
                {
                    WaitEvent.Reset();
                    ManagerPlant.serialPortManager.SendGetValue(w);
                    //Console.WriteLine("获取称量值等待");
                    WaitEvent.WaitOne();
                    //Console.WriteLine("获取称量值等待结束");
                }

                if (IsEndAdd)
                {
                    break;
                }
            }
        }