Пример #1
0
        /// <summary>
        /// 성형 기계시작
        /// </summary>
        public void MachineStart(int toqty, Item_MoldPair pair)
        {
            this.toqty    = toqty;
            this.totalqty = toqty;

            Log.WriteInfo("성형 시작...");
            timer           = new System.Timers.Timer(interval);
            timer.Enabled   = true;
            timer.Elapsed  += (sender, eventargs) => { Mold_Elapsed(pair); };
            timer.AutoReset = true;
        }
Пример #2
0
        /// <summary>
        /// 성형기계
        /// </summary>
        /// <param name="pair"></param>
        private void Mold_Elapsed(Item_MoldPair pair)
        {
            iCnt++;
            Random rnd    = new Random((int)DateTime.UtcNow.Ticks);
            int    badcnt = rnd.Next(0, 3);
            int    outqty = pair.Line_Per_Qty;

            prdcnt = outqty - badcnt;

            stackqty += prdcnt;

            StreamWriter sw = null;

            toqty = toqty - prdcnt;
            if (toqty < 0)
            {
                outqty = outqty + toqty; prdcnt = prdcnt + toqty;
            }
            runevent?.Invoke(stackqty, totalqty, prdcnt, outqty);
            try
            {
                DateTime now = DateTime.Now;
                sw = new StreamWriter($"{writefolder}\\{now.ToString("yyyyMMddHHmmss")}MoldingLog_{machineID}_{iCnt}.log", false);
                string msg = $"{now.ToString("yyyyMMdd HH:mm:ss")}/Machine_{machineID}/{workorderno}/{userid}/{wccode}/{pair.Moldcode}/{pair.Itemcode}/{outqty}/{badcnt}";
                sw.WriteLine(msg);
                sw.Flush();
                sw.Close();
            }
            catch (Exception ee)
            {
                Log.WriteError("오류 : ", ee);
            }
            if (toqty < 0)
            {
                MachineStop(MachineType.Molding, pair.Moldcode);
            }
        }