Пример #1
0
 private int Ca(Mo a, Mo b)
 {
     if (a.d > b.d)
     {
         return(1);
     }
     else if (a.d < b.d)
     {
         return(-1);
     }
     else if (a.y > b.y)
     {
         return(1);
     }
     else if (a.y < b.y)
     {
         return(-1);
     }
     else if (a.x < b.x)
     {
         return(1);
     }
     else if (a.x > b.x)
     {
         return(-1);
     }
     else
     {
         return(0);
     }
 }
Пример #2
0
        public OperationResult ActionGood(string usercode, string rescode, string card)
        {
            OperationResult operationResult = ActionGoodCheck(usercode, rescode, card);

            if (operationResult.ResultType == OperationResultType.Error)
            {
                return(operationResult);
            }
            Simulation lastSimulation = SimulationFormService.Simulations().SingleOrDefault(s => s.RCARD == card);
            Res        res            = (Res)ResFormService.FindEntity(rescode).AppendData;

            lastSimulation.OpCode     = res.Op.OPCODE;
            lastSimulation.LACTION    = "Good";
            lastSimulation.ACTIONLIST = "Good";
            lastSimulation.MUSER      = usercode;
            int      nowOp  = Route2OpFormService.Route2Ops().SingleOrDefault(r => r.routeCode == lastSimulation.ROUTECODE && r.opCode == lastSimulation.OpCode).seq;
            Route2Op nextOp = Route2OpFormService.Route2Ops().Where(r => r.routeCode == lastSimulation.ROUTECODE && r.seq > nowOp).OrderByDescending(r => r.seq).FirstOrDefault();

            //是最后一道工序
            if (nextOp.opCode == res.Op.OPCODE)
            {
                lastSimulation.ISCOM = "1";
                Mo mo = (Mo)MoFormService.FindEntity(lastSimulation.MOCODE).AppendData;
                mo.MOACTQTY += 1;
                SimulationReportFormService.AddEntity(new SimulationReport(lastSimulation));
            }
            else
            {
                SimulationReportFormService.AddEntity(new SimulationReport(lastSimulation));
            }
            operationResult.Message = card + Properties.Resources.String_FrmGoodNGService_CollectSuccess;
            return(operationResult);
        }
Пример #3
0
    public Gs(int[][] a, int p)
    {
        int n = a.Length, q = 2;

        arr = new Mo[n];
        for (int i = 0; i < n; i++)
        {
            if (i != p)
            {
                arr[i] = new Mo(Math.Atan2(a[i][1] - a[p][1], a[i][0] - a[p][0]) * 180 / Math.PI, i, a[i][0], a[i][1]);
            }
        }
        arr[p] = new Mo(-512, p, a[p][0], a[p][1]);
        Array.Sort(arr, Ca);
        li.Add(arr[0]);
        li.Add(arr[1]);
        while (q != n)
        {
            li.Add(arr[q]);
            q++;
            while (li.Count > 2 && (li[li.Count - 1].x - li[li.Count - 2].x) * (li[li.Count - 3].y - li[li.Count - 2].y) - (li[li.Count - 1].y - li[li.Count - 2].y) * (li[li.Count - 3].x - li[li.Count - 2].x) <= 0)
            {
                li.RemoveAt(li.Count - 2);
            }
        }
    }
Пример #4
0
        public async Task <Mo> UpdateMo(Mo mo)
        {
            _context.Mo.Update(mo);
            await _context.SaveChangesAsync();

            return(mo);
        }
Пример #5
0
    }                                                   //

    public void Ud(int q, long b)
    {
        q += m - 1 - f;
        if (dat[q] == du)
        {
            int z = q;
            dat[q] = new Mo(b, q - (m - 1 - f));
            while (q > 0 && Compare(dat[z], dat[(q - 1) / 2]))
            {
                dat[(q - 1) / 2] = dat[z];
                q = (q - 1) / 2;
            }
        }
        else
        {
            dat[q].d = du.d;
            dat[q]   = new Mo(b, q - (m - 1 - f));
            q        = (q - 1) / 2;
            while (q >= 0)
            {
                Mo o = Compare(dat[2 * q + 1], dat[2 * q + 2])?dat[2 * q + 1]:dat[2 * q + 2];
                if (dat[q] == o)
                {
                    break;
                }
                dat[q] = o;
                q      = (q - 1) / 2;
            }
        }
    }
Пример #6
0
    public int CompareTo(object obj)
    {
        Mo <T> mymo = (Mo <T>)obj;

        if (mymo.n > n)
        {
            return(-1);
        }
        else if (mymo.n < n)
        {
            return(1);
        }
        else if (mymo.m > m)
        {
            return(-1);
        }
        else if (mymo.m < m)
        {
            return(1);
        }
        else
        {
            return(0);
        }
    }
Пример #7
0
        public void TestInc()
        {
            var mo = Mo.Inc("A", 10);

            var expected = new Document("$inc", new Document("A", 10));

            Assert.AreEqual(expected, mo);
        }
Пример #8
0
        public void TestSet()
        {
            var mo = Mo.Set("A", 10);

            var expected = new Document("$set", new Document("A", 10));

            Assert.AreEqual(expected, mo);
        }
Пример #9
0
        public void TestPopFirst()
        {
            var mo = Mo.PopFirst("A");

            var expected = new Document("$pop", new Document("A", -1));

            Assert.AreEqual(expected, mo);
        }
Пример #10
0
        public void TestUnset()
        {
            var mo = Mo.Unset("A");

            var expected = new Document("$unset", new Document("A", 1));

            Assert.AreEqual(expected, mo);
        }
Пример #11
0
        public void TestPush()
        {
            var mo = Mo.Push("A", 1);

            var expected = new Document("$push", new Document("A", 1));

            Assert.AreEqual(expected, mo);
        }
Пример #12
0
 private bool AtDest(GridPos dest, Mo mo)
 {
     if (mo.gridPos.x == dest.x && mo.gridPos.y == dest.y)
     {
         return(true);
     }
     return(false);
 }
Пример #13
0
        public void TestAddToSet()
        {
            var mo = Mo.AddToSet("A", 1);

            var expected = new Document("$addToSet", new Document("A", 1));

            Assert.AreEqual(expected, mo);
        }
Пример #14
0
        private compassDir FindCompassDir(GridPos dest, Mo mo)
        {
            // calculate the angle and set limits within 30 degrees for each direction.
            Int64 deltaX = dest.x - mo.gridPos.x;
            Int64 deltaY = dest.y - mo.gridPos.y;

            Int64 angleInDegrees = Convert.ToInt64(Math.Atan2(deltaY, deltaX) * 180 / Math.PI);

            // now I have the angle in degrees... what direction is the triangle facing?

            if (angleInDegrees > 0)
            {
                if (angleInDegrees >= 0 && angleInDegrees <= 15)
                {
                    return(compassDir.E);
                }
                else if (angleInDegrees >= 15 && angleInDegrees <= 60)
                {
                    return(compassDir.SE);
                }
                else if (angleInDegrees >= 60 && angleInDegrees <= 105)
                {
                    return(compassDir.S);
                }
                else if (angleInDegrees >= 105 && angleInDegrees <= 150)
                {
                    return(compassDir.SW);
                }
                else if (angleInDegrees >= 150 && angleInDegrees <= 180)
                {
                    return(compassDir.W);
                }
            }
            else
            {
                if (angleInDegrees <= 0 && angleInDegrees >= -15)
                {
                    return(compassDir.E);
                }
                else if (angleInDegrees <= -15 && angleInDegrees >= -60)
                {
                    return(compassDir.NE);
                }
                else if (angleInDegrees <= -60 && angleInDegrees >= -105)
                {
                    return(compassDir.N);
                }
                else if (angleInDegrees <= -105 && angleInDegrees >= -150)
                {
                    return(compassDir.NW);
                }
                else if (angleInDegrees <= -150 && angleInDegrees >= -180)
                {
                    return(compassDir.W);
                }
            }
            return(compassDir.N);
        }
Пример #15
0
        public void TestAddToSetArray()
        {
            var array = new object[] { 1, "C" };
            var mo    = Mo.AddToSet("A", array);

            var expected = new Document("$addToSet", new Document("A", new Document("$each", array)));

            Assert.AreEqual(expected, mo);
        }
Пример #16
0
        public void TestUnsetArray()
        {
            var array = new[] { "A", "B" };
            var mo    = Mo.Unset(array);

            var expected = new Document("$unset", new Document("A", 1).Add("B", 1));

            Assert.AreEqual(expected, mo);
        }
Пример #17
0
        public void TestPushAll()
        {
            var array = new object[] { 1, "C" };
            var mo    = Mo.PushAll("A", array);

            var expected = new Document("$pushAll", new Document("A", array));

            Assert.AreEqual(expected, mo);
        }
Пример #18
0
        public void TestMultipleModifiers()
        {
            var mo = Mo.Inc("A", 1) & Mo.Inc("B", 2) & Mo.Set("C", 3);

            var expected = new Document("$inc", new Document("A", 1).Add("B", 2))
                           .Add("$set", new Document("C", 3));

            Assert.AreEqual(expected, mo);
        }
Пример #19
0
    private Mo Fdg(int a, int b, int k, int l, int r)
    {
        if (r < a || b < l)
        {
            return(du);
        }
        if (a <= l && r <= b)
        {
            return(dat[k]);
        }
        Mo p = Fdg(a, b, k * 2 + 1, l, (l + r) / 2);
        Mo q = Fdg(a, b, k * 2 + 2, (l + r + 1) / 2, r);

        return(Compare(p, q)?p:q);
    }
Пример #20
0
        public void FindAndModifyIncOperatorWorks()
        {
            var collection = DB.GetCollection <Sequence>();

            collection.Remove(new Document());
            collection.Insert(new Sequence {
                Name = "test", Value = 1
            });

            var spec   = new Document().Add("Name", "test");
            var update = Mo.Inc("Value", 1);

            var document = collection.FindAndModify(update, spec, true);

            Assert.AreEqual(2, document.Value);
        }
Пример #21
0
        public OperationResult FindSnCheck(string moString)
        {
            if (moString == null)
            {
                return(new OperationResult(OperationResultType.Error, Properties.Resources.String_FrmGoodNGService_MoCanNotNull));
            }

            OperationResult operationResult = MoFormService.FindEntity(moString);

            if (operationResult.ResultType == OperationResultType.Success)
            {
                Mo           mo           = (Mo)operationResult.AppendData;
                Item2SnCheck item2SnCheck = Item2SnCheckFormService.Item2SnChecks().SingleOrDefault(i => i.ITEMCODE == mo.ITEMCODE);
                operationResult.AppendData = item2SnCheck;
            }
            return(operationResult);
        }
Пример #22
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     listBox1.Items.Clear();
     try
     {
         //string CPUtprt = 0;
         System.Management.ManagementObjectSearcher MOS = new System.Management.ManagementObjectSearcher("root\\CIMV2",
                                                                                                         "SELECT * FROM Win32_NetworkAdapter  ");
         foreach (System.Management.ManagementObject Mo in MOS.Get())
         {
             //CPUtprt = Mo.GetPropertyValue("Status".ToString());
             listBox1.Items.Add(Mo.GetPropertyValue("NetConnectionStatus".ToString()));
         }
     }
     catch (ManagementException ex)
     {
         MessageBox.Show("Ошибка получения данных " + ex.Message);
     }
 }
Пример #23
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     try
     {
         Double CPUtprt = 0;
         System.Management.ManagementObjectSearcher MOS = new System.Management.ManagementObjectSearcher("root\\WMI",
                                                                                                         "SELECT * FROM MSAcpi_ThermalZoneTemperature");
         foreach (System.Management.ManagementObject Mo in MOS.Get())
         {
             CPUtprt          = Convert.ToDouble(Convert.ToDouble(Mo.GetPropertyValue("CurrentTemperature".ToString())) - 2732) / 10.0;
             cpb_CPUTemp.Text = string.Format("{0}°С", (int)CPUtprt);
             cpb_CPUTemp.SetValue((int)CPUtprt);
             break;
         }
     }
     catch (ManagementException ex)
     {
         MessageBox.Show("Ошибка получения данных " + ex.Message);
     }
 }
Пример #24
0
        public static void CancelPrintJobs()
        {
            try
            {
                ManagementObjectSearcher   mos = new ManagementObjectSearcher("SELECT * FROM Win32_PrintJob");
                ManagementObjectCollection moc = mos.Get();

                foreach (ManagementObject Mo in moc)
                {
                    Mo.Delete();
                    Mo.Dispose();
                }

                moc.Dispose();
                mos.Dispose();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #25
0
 public St(int f, int n, int mm)
 {
     this.f = f;
     n     += f ^ 1;
     if (mm == 0)
     {
         du = new Mo(long.MinValue, -1); compare = CoMax;
     }
     else
     {
         du = new Mo(long.MaxValue, -1); compare = CoMin;
     }
     while (m < n)
     {
         m *= 2;
     }
     dat = new Mo[m + n - 1];
     for (int i = 0; i < m + n - 1; i++)
     {
         dat[i] = du;
     }
 }
Пример #26
0
 private bool CoMax(Mo x, Mo y)
 {
     return(x.d > y.d);
 }
Пример #27
0
 private bool Compare(Mo x, Mo y)
 {
     return(x.d < y.d);
 }                                                   //
Пример #28
0
 private bool CoMin(Mo x, Mo y)
 {
     return(x.d < y.d);
 }
Пример #29
0
        public OperationResult CardGoMo(string moString, string lengthString, string prefixString, string card, string rescode, string usercode)
        {
            bool tbag = false;

            OperationResult operationResult = CardGoMoCheck(moString, lengthString, prefixString, card, rescode, usercode);

            if (operationResult.ResultType == OperationResultType.Error)
            {
                return(operationResult);
            }

            Mo               mo               = (Mo)MoFormService.FindEntity(moString).AppendData;
            Simulation       nowSimulation    = SimulationFormService.Simulations().SingleOrDefault(s => s.RCARD == card && s.MOCODE == mo.MoCode);
            SimulationReport simulationReport = new SimulationReport();
            Item             item             = ItemFormService.Items().SingleOrDefault(i => i.ITEMCODE == mo.ITEMCODE);

            if (nowSimulation == null)
            {
                nowSimulation = new Simulation();
                tbag          = true;
            }
            MoRcard moRcard = new MoRcard();


            //TBLSimulation
            nowSimulation.ROUTECODE     = mo.Route.ROUTECODE;
            nowSimulation.OpCode        = mo.Route.Ops.First().OPCODE;
            nowSimulation.LACTION       = "GOMO";
            nowSimulation.ACTIONLIST    = ";GOMO;";
            nowSimulation.RCARD         = card;
            nowSimulation.TCARD         = card;
            nowSimulation.TCARDSEQ      = 1;
            nowSimulation.SCARD         = card;
            nowSimulation.SCARDSEQ      = 1;
            nowSimulation.MOCODE        = mo.MoCode;
            nowSimulation.ITEMCODE      = mo.ITEMCODE;
            nowSimulation.MODELCODE     = item.Model.MODELCODE;
            nowSimulation.IDMERGERULE   = mo.IDMERGERULE;
            nowSimulation.ISCOM         = "0";
            nowSimulation.RESCODE       = rescode;
            nowSimulation.PRODUCTSTATUS = "GOOD";
            nowSimulation.FROMOP        = "";
            nowSimulation.FROMROUTE     = "";
            nowSimulation.CARTONCODE    = "";
            nowSimulation.LOTNO         = "";
            nowSimulation.PALLETCODE    = "";
            nowSimulation.NGTIMES       = 0;
            nowSimulation.ISHOLD        = 0;
            nowSimulation.MOSEQ         = mo.MOSEQ;
            nowSimulation.MUSER         = usercode;

            //TBLSimulationReport
            simulationReport.ROUTECODE     = mo.Route.ROUTECODE;
            simulationReport.OPCODE        = mo.Route.Ops.First().OPCODE;
            simulationReport.LACTION       = "GOMO";
            simulationReport.ACTIONLIST    = ";GOMO;";
            simulationReport.RCARD         = card;
            simulationReport.TCARD         = card;
            simulationReport.TCARDSEQ      = 1;
            simulationReport.SCARD         = card;
            simulationReport.SCARDSEQ      = 1;
            simulationReport.MOCODE        = mo.MoCode;
            simulationReport.ITEMCODE      = mo.ITEMCODE;
            simulationReport.MODELCODE     = item.Model.MODELCODE;
            simulationReport.IDMERGERULE   = mo.IDMERGERULE;
            simulationReport.ISCOM         = "0";
            simulationReport.RESCODE       = rescode;
            simulationReport.PRODUCTSTATUS = "GOOD";
            simulationReport.FROMOP        = "";
            simulationReport.FROMROUTE     = "";
            simulationReport.CARTONCODE    = "";
            simulationReport.LOTNO         = "";
            simulationReport.PALLETCODE    = "";
            simulationReport.NGTIMES       = 0;
            simulationReport.ISHOLD        = 0;
            simulationReport.MOSEQ         = mo.MOSEQ;
            simulationReport.MUSER         = usercode;

            //TBLONWIP

            //TBLMo
            mo.MOINPUTQTY = mo.MOINPUTQTY + 1;
            //TBLMoRcard
            moRcard.MoCode      = mo.MoCode;
            moRcard.Seq         = 1;
            moRcard.MoCardStart = card;
            moRcard.MoCardEnd   = card;
            moRcard.Muser       = usercode;
            moRcard.MoSeq       = mo.MOSEQ;

            MoFormService.UpdateEntity(mo, false);
            SimulationReportFormService.AddEntity(simulationReport, false);
            MoRcardFormService.AddEntity(moRcard, false);
            if (tbag)
            {
                SimulationFormService.AddEntity(nowSimulation);
            }
            else
            {
                SimulationFormService.UpdateEntity(nowSimulation);
            }

            operationResult.ResultType = OperationResultType.Success;
            operationResult.Message    = card + Properties.Resources.String_FrmGoodNGService_CollectSuccess;
            return(operationResult);
        }
Пример #30
0
        public OperationResult CardGoMoCheck(string moString, string lengthString, string prefixString, string card, string rescode, string usercode)
        {
            GoMoModel model = new GoMoModel {
                MoString = moString, LengthString = lengthString, PrefixString = prefixString, Card = card, Rescode = rescode, Usercode = usercode
            };

            Validator.ValidateObject(model, new ValidationContext(model));
            OperationResult operationResult = new OperationResult(OperationResultType.Error);

            Mo mo = (Mo)MoFormService.FindEntity(moString).AppendData;

            if (mo == null)
            {
                operationResult.Message = moString + Properties.Resources.String_FrmGoodNGService_MoNotExit;
                return(operationResult);
            }
            if (!(mo.MOSTATUS == MoStatus.RELEASE || mo.MOSTATUS == MoStatus.OPEN))
            {
                operationResult.Message = moString + Properties.Resources.String_FrmGoodNGService_MoStatusError;
                return(operationResult);
            }
            if (mo.Route == null)
            {
                operationResult.Message = moString + Properties.Resources.String_FrmGoodNGService_MoDontHaveRoute;
                return(operationResult);
            }
            MoRcard moRcard = MoRcardFormService.MoRcards().SingleOrDefault(r => r.MoCode == mo.MoCode && r.MoCardStart == card);

            if (moRcard != null)
            {
                operationResult.Message = card + Properties.Resources.String_FrmGoodNGService_SnHadInMo;
                return(operationResult);
            }

            if (mo.Route.Ops.First().Reses.SingleOrDefault(r => r.RESCODE == rescode) == null)
            {
                operationResult.Message = rescode + Properties.Resources.String_FrmGoodNGService_ResNotFirst;
                return(operationResult);
            }
            Simulation lastSimulation = SimulationFormService.Simulations().SingleOrDefault(r => r.MOCODE == mo.MoCode && r.RCARD == card);

            if (lastSimulation != null)
            {
                if (lastSimulation.ISCOM == "0")
                {
                    operationResult.Message = card + Properties.Resources.String_FrmGoodNGService_SnIsRunning;
                    return(operationResult);
                }
            }

            Item item = ItemFormService.Items().SingleOrDefault(i => i.ITEMCODE == mo.ITEMCODE);

            if (item.CHKITEMOP == null || item.CHKITEMOP.Trim().Length == 0)
            {
                operationResult.Message = Properties.Resources.String_FrmGoodNGService_LotNotOp;
                return(operationResult);
            }
            if (mo.ISCONINPUT == 1)
            {
                if (mo.MOPLANQTY - mo.MOINPUTQTY + mo.OFFMOQTY - mo.IDMERGERULE <= 0)
                {
                    operationResult.Message = mo.MoCode + Properties.Resources.String_FrmGoodNGService_MoEnough;
                    return(operationResult);
                }
            }
            operationResult.ResultType = OperationResultType.Success;
            operationResult.Message    = card + Properties.Resources.String_FrmGoodNGService_CheckSuccess;
            return(operationResult);
        }