コード例 #1
0
ファイル: StatusCounterTest.cs プロジェクト: cip4/JDFLibNet
        public virtual void testAddPhase()
        {
            bool bChanged = sc.setPhase(EnumNodeStatus.InProgress, "i", EnumDeviceStatus.Running, "r");

            Assert.IsTrue(bChanged);
            JDFDoc      docJMF = sc.getDocJMFPhaseTime();
            JDFResponse sig    = (JDFResponse)docJMF.getJMFRoot().getMessageElement(EnumFamily.Response, EnumType.Status, 0);
            JDFJobPhase jp     = sig.getDeviceInfo(0).getJobPhase(0);

            Assert.AreEqual(200, jp.getAmount(), 0);
            sc.addPhase(resID, 0, 100, true);
            sc.setTrackWaste(resID, true);
            JDFResourceLink rlXM = n.getLink(xpMedia, null);

            for (int loop = 1; loop < 4; loop++)
            {
                bChanged = sc.setPhase(EnumNodeStatus.InProgress, "i", EnumDeviceStatus.Running, "r");
                Assert.IsFalse(bChanged);
                docJMF = sc.getDocJMFPhaseTime();
                sig    = (JDFResponse)docJMF.getJMFRoot().getMessageElement(EnumFamily.Response, EnumType.Status, 0);
                jp     = sig.getDeviceInfo(0).getJobPhase(0);
                Assert.AreEqual(200, jp.getAmount(), 0, "multiple setPhase calls do not modify");
                Assert.AreEqual(200, rlXM.getActualAmount(new JDFAttributeMap("Condition", "Good")), 0, "multiple setPhase calls do not modify: " + loop);
                Assert.AreEqual(200.0, jp.getPercentCompleted(), 0, "% " + loop);
                sc.addPhase(resID, 0, 100, true);
                Assert.AreEqual(loop * 100, jp.getWaste(), 0, "" + loop);
                Assert.AreEqual(100 * loop, rlXM.getActualAmount(new JDFAttributeMap("Condition", "Waste")), 0, "multiple setPhase calls do Stack: " + loop);
            }
            sc.setWorkType(EnumWorkType.Alteration);
            bChanged = sc.setPhase(EnumNodeStatus.InProgress, "ii", EnumDeviceStatus.Running, "r");
            Assert.IsTrue(bChanged);
            docJMF = sc.getDocJMFPhaseTime();
            sig    = (JDFResponse)docJMF.getJMFRoot().getMessageElement(EnumFamily.Response, EnumType.Status, 0);
            jp     = sig.getDeviceInfo(0).getJobPhase(0);
            Assert.AreEqual(200, jp.getAmount(), 0);
            Assert.AreEqual(400, jp.getWaste(), 0);
            Assert.IsTrue(jp.hasAttribute(AttributeName.PHASEAMOUNT));
            sig = (JDFResponse)docJMF.getJMFRoot().getMessageElement(EnumFamily.Response, EnumType.Status, 1);
            jp  = sig.getDeviceInfo(0).getJobPhase(0);
            Assert.AreEqual(0.0, jp.getPhaseAmount(), 0.0);
            Assert.AreEqual(EnumWorkType.Alteration, jp.getMISDetails().getWorkType());

            sc.setFirstRefID("dummy");
            sc.addPhase(resID, 0, 100, true);
            sc.setTrackWaste(resID, true);
            sc.setPhase(EnumNodeStatus.InProgress, "i", EnumDeviceStatus.Running, "r");
            docJMF = sc.getDocJMFPhaseTime();
            sig    = (JDFResponse)docJMF.getJMFRoot().getMessageElement(EnumFamily.Response, EnumType.Status, 0);
            jp     = sig.getDeviceInfo(0).getJobPhase(0);
            Assert.IsFalse(jp.hasAttribute(AttributeName.AMOUNT));
            Assert.AreEqual(EnumWorkType.Alteration, jp.getMISDetails().getWorkType());
        }