Ejemplo n.º 1
0
        public void CanItemConstructA()
        {
            var chars = new List <char>();

            for (byte i = 32; i < 127; i++)
            {
                chars.Add((char)i);
            }

            chars.AddRange(chars);
            chars.AddRange(chars);

            Assert.IsTrue(chars.Count > byte.MaxValue);

            string targetValue = new string(chars.ToArray());

            Item item = Item.A(targetValue);

            Assert.AreEqual(SecsFormat.ASCII, item.Format, nameof(item.Count));
            Assert.AreEqual(chars.Count, item.Count, nameof(item.Count));

            byte[] rawBytes = item.RawBytes.ToArray();

            Assert.AreEqual(new ItemHeader(SecsFormat.ASCII, chars.Count).RawHeaderDataSize + chars.Count, rawBytes.Length, nameof(rawBytes));
        }
Ejemplo n.º 2
0
        async Task HandleTCS(CreateControlJobRequest tx)
        {
            var s14f10 = await EAP.SendAsync(new SecsMessage(14, 9, "CreaeteControlJob",
                                                             Item.L(
                                                                 Item.A("Equipment"),
                                                                 Item.A("ControlJob"),
                                                                 Item.L(
                                                                     Item.L(
                                                                         Item.A("ObjID"),
                                                                         Item.A(tx.ControlJobID)),
                                                                     Item.L(
                                                                         Item.A("CarrierInputSpec"),
                                                                         Item.L(from carrier in tx.CarrierIDs select
                                                                                Item.A(carrier))),
                                                                     Item.L(
                                                                         Item.A("ProcessingCtrlSpec"),
                                                                         Item.L(from pj in tx.ProcessJobIDs select
                                                                                Item.L(
                                                                                    Item.A(pj),
                                                                                    Item.L(),
                                                                                    Item.A()))),
                                                                     Item.L(
                                                                         Item.A("ProcessOrderMgmt"),
                                                                         Item.U1(0)),
                                                                     Item.L(
                                                                         Item.A("StartMethod"),
                                                                         Item.Boolean(true))))));

            byte returnCode = (byte)s14f10.SecsItem.Items[2].Items[0];

            if (returnCode != 0 && returnCode != 4)
            {
                throw new ScenarioException("CreateControlJob fail. ");
            }
        }
Ejemplo n.º 3
0
        async Task HandleTCS(CreateProcessJobRequest tx)
        {
            var s16f16 = await EAP.SendAsync(new SecsMessage(16, 15, "CreateProcessJob",
                                                             Item.L(
                                                                 Item.U4(0),
                                                                 Item.L(from pj in tx.ProcessJobs select
                                                                        Item.L(
                                                                            Item.A(pj.Id),
                                                                            Item.B(2),
                                                                            Item.L(from carrier in pj.Carriers select
                                                                                   Item.L(
                                                                                       Item.A(carrier.Id),
                                                                                       Item.L(from slot in carrier.SlotMap select
                                                                                              Item.U1(slot.SlotNo)))),
                                                                            Item.L(
                                                                                Item.A("STANDARD"),
                                                                                Item.A(pj.RecipeId),
                                                                                Item.L()),
                                                                            Item.Boolean(true),
                                                                            Item.L())))));

            if (!s16f16.SecsItem.Items[1].Items[0])
            {
                throw new ScenarioException("CreateProcessJob fail. ");
            }

            foreach (var processJob in tx.ProcessJobs)
            {
                this._ProcessingJobs.Add(processJob);
            }
        }
Ejemplo n.º 4
0
        async Task TCS_CreateProcessJob(CreateProcessJobRequest tx)
        {
            var s16f16 = await EAP.SendAsync(new SecsMessage(16, 15, "CreateProcessJob",
                                                             Item.L(
                                                                 Item.U4(0),
                                                                 Item.L(from pj in tx.ProcessJobs select
                                                                        Item.L(
                                                                            Item.A(pj.Id),
                                                                            Item.B(0x0D),
                                                                            Item.L(from carrier in pj.Carriers select
                                                                                   Item.L(
                                                                                       Item.A(carrier.Id),
                                                                                       Item.L(from slotInfo in carrier.SlotMap select
                                                                                              Item.U1(slotInfo.SlotNo)))),
                                                                            Item.L(
                                                                                Item.U1(1),
                                                                                Item.A(pj.RecipeId),
                                                                                Item.L()),
                                                                            Item.Boolean(true),
                                                                            Item.L())))));

            if (!s16f16.SecsItem.Items[1].Items[0])
            {
                throw new ScenarioException("CreateProcessJob fail Return Code:" + s16f16.SecsItem.Items[1].Items[0]);
            }

            foreach (var processJob in tx.ProcessJobs)
            {
                this._ProcessingJobs[processJob.Id] = processJob;
            }
        }
Ejemplo n.º 5
0
 async Task DeleteProcessJob(IEnumerable <string> processJobIds)
 {
     foreach (string pjID in processJobIds)
     {
         _ProcessingJobs.Remove(pjID);
         try {
             await EAP.SendAsync(new SecsMessage(16, 5, "PJCancel",
                                                 Item.L(
                                                     Item.U4(0),
                                                     Item.A(pjID),
                                                     Item.A("Cancel"),
                                                     Item.L())));
         } catch { }
     }
 }
Ejemplo n.º 6
0
        async Task HandleTCS(ProceedSlotMapRequest tx)
        {
            var s3f18 = await EAP.SendAsync(new SecsMessage(3, 17, "ProceedWithCarrier",
                                                            Item.L(
                                                                Item.U4(2),
                                                                Item.A("ProceedWithCarrier"),
                                                                Item.A(tx.Carrier.Id),
                                                                Item.U1(GetPortNo(tx.Carrier.LoadPortId)),
                                                                Item.L())));

            byte returnCode = (byte)s3f18.SecsItem.Items[0];

            if (returnCode != 0 && returnCode != 4)
            {
                throw new ScenarioException("ProceedWithCarrier failed. ");
            }
        }
Ejemplo n.º 7
0
        async Task TCS_CancelCarrier(CancelCarrierRequest tx)
        {
            bool isUnknown = tx.Carrier.Id == "(Unknown)";
            var  s3f18     = await EAP.SendAsync(new SecsMessage(3, 17, "CancelCarrier",
                                                                 Item.L(
                                                                     Item.U4(0),
                                                                     Item.A(isUnknown ? "CancelCarrierAtPort" : "CancelCarrier"),
                                                                     Item.A(isUnknown ? string.Empty : tx.Carrier.Id),
                                                                     Item.B(GetPortNo(tx.Carrier.LoadPortId)),
                                                                     Item.L())));

            byte returnCode = (byte)s3f18.SecsItem.Items[0];

            if (returnCode != 0 && returnCode != 4)
            {
                throw new ScenarioException("CancelCarrier failed : " + s3f18.SecsItem.Items[1].Items[0].Items[1].GetValue <string>());
            }
        }
Ejemplo n.º 8
0
        async Task HandleTCS(CancelCarrierRequest tx)
        {
            var isUnknown = tx.Carrier.Id == "(Unknown)";
            var s3f18     = await EAP.SendAsync(new SecsMessage(3, 17, "CancelCarrier",
                                                                Item.L(
                                                                    Item.U4(0),
                                                                    Item.A(isUnknown?"CancelCarrierAtPort":"CancelCarrier"),
                                                                    Item.A(isUnknown?string.Empty:tx.Carrier.Id),
                                                                    Item.U1(GetPortNo(tx.Carrier.LoadPortId)),
                                                                    Item.L())));

            var returnCode = (byte)s3f18.SecsItem.Items[0];

            if (returnCode != 0 && returnCode != 4)
            {
                throw new ScenarioException("CancelCarrier failed. ");
            }
        }
Ejemplo n.º 9
0
 async Task RequestOffLine(ToolModeChangeRequest request)
 {
     try {
         foreach (var port in request.LoadPorts)
         {
             await EAP.SendAsync(new SecsMessage(3, 23, "ChangeAccessMode",
                                                 Item.L(
                                                     Item.A(),
                                                     Item.U1(0),
                                                     Item.L(
                                                         Item.U1(GetPortNo(port.Id))))));
         }
     }catch {}
     try{
         await EAP.SendAsync(EAP.SecsMessages[1, 15, "RequestOffLine"]);
     } catch {
     }
 }
Ejemplo n.º 10
0
        async Task ChangeAccessMode(AccessMode changeAccessMode, byte portNo)
        {
            var S3F23 = new SecsMessage(3, 23, "ChangeAccessMode",
                                        Item.L(
                                            Item.A(),
                                            Item.U1((byte)changeAccessMode),
                                            Item.L(
                                                Item.U1(portNo))));

            var S3F24 = await EAP.SendAsync(S3F23);

            var returnCode = (byte)S3F24.SecsItem.Items[0];

            if (returnCode != 0 && returnCode != 4)
            {
                throw new ScenarioException("Change Loadport[" + portNo + "] access mode fial. " + S3F24.SecsItem.Items[1].Items[1].GetString());
            }
        }
Ejemplo n.º 11
0
        async Task ChangeAccessMode(AccessMode changeAccessMode, int portNo)
        {
            var s3f24 = await EAP.SendAsync(new SecsMessage(3, 23, "ChangeAccessMode",
                                                            Item.L(
                                                                Item.A("ChangeAccess"),
                                                                Item.A(portNo.ToString()),
                                                                Item.L(
                                                                    Item.L(
                                                                        Item.A("AccessMode"),
                                                                        Item.B((byte)changeAccessMode))))));

            byte returnCode = (byte)s3f24.SecsItem.Items[0];

            if (returnCode != 0 && returnCode != 4)
            {
                throw new ScenarioException("Change Loadport[" + portNo + "] access mode fial: " + s3f24.SecsItem.Items[1].Items[0].Items[1].GetValue <string>());
            }
        }
Ejemplo n.º 12
0
 async Task RequestOffline(ToolModeChangeRequest request)
 {
     try {
         foreach (var port in request.LoadPorts)
         {
             await EAP.SendAsync(new SecsMessage(3, 23, "ChangeAccessMode",
                                                 Item.L(
                                                     Item.A("ChangeAccess"),
                                                     Item.A(GetPortNo(port.Id).ToString()),
                                                     Item.L(
                                                         Item.L(
                                                             Item.A("AccessMode"),
                                                             Item.B(0))))));
         }
     }catch {}
     try{
         await EAP.SendAsync(EAP.SecsMessages[1, 19, "RequestOffline"]);
     } catch { }
 }
Ejemplo n.º 13
0
        public void CanSecsGemSendMessageToSecsGem()
        {
            const ushort port = 60000;

            Item        mdlnAndSoftRev  = Item.L(Item.A($"{nameof(SecsGemTests)}Host"), Item.A(SecsGemTests.GetSoftRevValue()));
            Item        commackAccepted = Item.B(0);
            SecsMessage establishCommunicationsRequest            = new SecsMessage(1, 13, "Establish Communications Request (CR)", mdlnAndSoftRev, true);
            SecsMessage establishCommunicationsRequestAcknowledge = new SecsMessage(1, 14, "Establish Communications Request Acknowledge (CRA)", Item.L(commackAccepted, mdlnAndSoftRev), false);

            using (SecsGemLocalLoop loop = new SecsGemLocalLoop(port))
            {
                SecsMessage message = null;

                loop.Host.ConnectionChanged += async(sender, e) =>
                {
                    if (e == ConnectionState.Selected)
                    {
                        message = await loop.Host.SendAsync(establishCommunicationsRequest).ConfigureAwait(false);
                    }
                };

                loop.Equipment.PrimaryMessageReceived += async(sender, e) =>
                {
                    if (e.Message.S == 1 && e.Message.F == 13)
                    {
                        await e.ReplyAsync(establishCommunicationsRequestAcknowledge).ConfigureAwait(false);
                    }
                };

                loop.Start();

                while (message == null)
                {
                    Thread.Sleep(1000);
                }

                Assert.IsTrue(message.S == 1 && message.F == 14);
            }
        }
Ejemplo n.º 14
0
        async Task TCS_CreateControlJob(CreateControlJobRequest tx)
        {
            var s14f10 = await EAP.SendAsync(new SecsMessage(14, 9, "CreateControlJob",
                                                             Item.L(
                                                                 Item.A("Equipment"),
                                                                 Item.A("ControlJob"),
                                                                 Item.L(
                                                                     Item.L(
                                                                         Item.A("ObjID"),
                                                                         Item.A(tx.ControlJobID)),
                                                                     Item.L(
                                                                         Item.A("ProcessingCtrlSpec"),
                                                                         Item.L(from pjid in tx.ProcessJobIDs select
                                                                                Item.A(pjid))),
                                                                     Item.L(
                                                                         Item.A("CarrierInputSpec"),
                                                                         Item.L(from carrier in tx.CarrierIDs select
                                                                                Item.A(carrier))),
                                                                     Item.L(
                                                                         Item.A("MtrlOutSpec"),
                                                                         Item.A()),
                                                                     Item.L(
                                                                         Item.A("ProcessOrderMgmt"),
                                                                         Item.A("LIST")),
                                                                     Item.L(
                                                                         Item.A("StartMethod"),
                                                                         Item.Boolean(true))))));

            byte returnCode = (byte)s14f10.SecsItem.Items[2].Items[0];

            if (returnCode != 0 && returnCode != 4)
            {
                await DeleteProcessJob(tx.ProcessJobIDs);

                throw new ScenarioException("S14F10_CreateControlJob_Handler Return Code:" + returnCode);
            }
        }
Ejemplo n.º 15
0
        void HandleTCS(PPBodyQueryRequest tx)
        {
            if (tx.Type != "Body")
            {
                return;
            }

            var s7f6 = EAP.Send(new SecsMessage(7, 5, "PPBodyQuery", Item.A(tx.PPID)));

            if (s7f6.SecsItem.Items[0].ToString() != tx.PPID)
            {
                throw new ScenarioException("PPID unmatch!!");
            }

            if (s7f6.SecsItem.Items.Count == 0)
            {
                throw new ScenarioException("PPBody is null");
            }

            string body = s7f6.SecsItem.Items[1].ToString();

            if (EAP.ToolId.StartsWith("PEU"))
            {
                tx.Add(new PPBodyItem {
                    ID1   = "IrrMethod_Ref",
                    Value = body.Substring(0x48, 3).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "Exposure_Time",
                    Value = body.Substring(0x4d, 3).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "Exposure_Intensity",
                    Value = body.Substring(0x51, 1).Trim()
                });
            }
            else if (EAP.ToolId.StartsWith("PGU"))
            {
                tx.Add(new PPBodyItem {
                    ID1   = "RecipeName",
                    Value = body.Substring(0, 48).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "RecipeEditDate",
                    Value = body.Substring(49, 10).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "RecipeEditTime",
                    Value = body.Substring(59, 9).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "RecipeValidity",
                    Value = body.Substring(68, 2).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "IrradiationTimeIntensity_u1",
                    Value = body.Substring(70, 5).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "IrradiationTimeIntensity_u2",
                    Value = body.Substring(75, 5).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "IrradiationTimeIntensity_u3",
                    Value = body.Substring(80, 5).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "IrradiationTimeIntensity_u4",
                    Value = body.Substring(85, 5).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "IrradiationTimeIntensity_u5",
                    Value = body.Substring(90, 5).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "IrradiationIntensity_i1",
                    Value = body.Substring(95, 2).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "IrradiationIntensity_i2",
                    Value = body.Substring(97, 2).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "IrradiationIntensity_i3",
                    Value = body.Substring(99, 2).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "IrradiationIntensity_i4",
                    Value = body.Substring(101, 2).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "IrradiationIntensity_i5",
                    Value = body.Substring(103, 2).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "HotPlateTimeInterval_t1",
                    Value = body.Substring(105, 5).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "HotPlateTimeInterval_t2",
                    Value = body.Substring(110, 5).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "HotPlateTimeInterval_t3",
                    Value = body.Substring(115, 5).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "HotPlateTimeInterval_t4",
                    Value = body.Substring(120, 5).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "HotPlateTimeInterval_t5",
                    Value = body.Substring(125, 5).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "HotPlateTemperature_T1",
                    Value = body.Substring(130, 4).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "HotPlateTemperature_T2",
                    Value = body.Substring(134, 4).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "HotPlateTemperature_T3",
                    Value = body.Substring(138, 4).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "HotPlateTemperature_T4",
                    Value = body.Substring(142, 4).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "HotPlateTemperature_T5",
                    Value = body.Substring(146, 4).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "CoolingStageUsage",
                    Value = body.Substring(150, 2).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "CoolingTimeAtTheCoolingStage",
                    Value = body.Substring(152, 5).Trim()
                });

                tx.Add(new PPBodyItem {
                    ID1   = "PurgeDuringProcess",
                    Value = body.Substring(157, 2).Trim()
                });
            }
        }
Ejemplo n.º 16
0
        public override void Cast(IAvatar caster, IActor target, CastResults results)
        {
            Item item = target as Item;

            if (item != null)
            {
                item.Properties.SetValue(this.EnchantPropertyName, this.Power);
                caster.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Cast,
                                                        String.Format(Resources.SpellEnchanted, item.A())));
            }
            else
            {
                this.NoAffect(caster);
            }
        }
Ejemplo n.º 17
0
        public void CanSecsGemSendLargeMessageToSecsGem()
        {
            const ushort port = 60001;

            Item        mdlnAndSoftRev  = Item.L(Item.A($"{nameof(SecsGemTests)}Host"), Item.A(SecsGemTests.GetSoftRevValue()));
            Item        commackAccepted = Item.B(0);
            SecsMessage establishCommunicationsRequest            = new SecsMessage(1, 13, "Establish Communications Request (CR)", mdlnAndSoftRev, true);
            SecsMessage establishCommunicationsRequestAcknowledge = new SecsMessage(1, 14, "Establish Communications Request Acknowledge (CRA)", Item.L(commackAccepted, mdlnAndSoftRev), false);

            SecsMessage selectedEquipmentStatusRequest = new SecsMessage(1, 3, "Selected Equipment Status Request (SSR)", Item.L(), true);

            const int statusValuesLength = ushort.MaxValue + 1;
            const int maxValueCount      = byte.MaxValue + 1;

            List <uint> values = new List <uint>(maxValueCount);

            Item[] statusValues = new Item[statusValuesLength];
            for (uint i = 0; i < statusValues.Length; i++)
            {
                values.Add(i);
                statusValues[i] = Item.U4(values);

                if (values.Count >= maxValueCount)
                {
                    values.Clear();
                }
            }
            Item listItemStatusValues = Item.L(statusValues);

            SecsMessage selectedEquipmentStatusData = new SecsMessage(1, 4, "Selected Equipment Status Data (SSD)", listItemStatusValues, true);

            int expectedTotalRawBytesCount = selectedEquipmentStatusData.RawBytes.SelectMany(x => x).Count();

            Trace.WriteLine($"{nameof(selectedEquipmentStatusData)}.{nameof(selectedEquipmentStatusData.RawBytes)} Count: {expectedTotalRawBytesCount}");

            using (SecsGemLocalLoop loop = new SecsGemLocalLoop(port))
            {
                SecsMessage message = null;

                loop.Host.ConnectionChanged += async(sender, e) =>
                {
                    if (e == ConnectionState.Selected)
                    {
                        await loop.Host.SendAsync(establishCommunicationsRequest).ConfigureAwait(false);

                        message = await loop.Host.SendAsync(selectedEquipmentStatusRequest).ConfigureAwait(false);
                    }
                };

                loop.Equipment.PrimaryMessageReceived += async(sender, e) =>
                {
                    if (e.Message.S == 1)
                    {
                        switch (e.Message.F)
                        {
                        case 3:
                            await e.ReplyAsync(selectedEquipmentStatusData).ConfigureAwait(false);

                            break;

                        case 13:
                            await e.ReplyAsync(establishCommunicationsRequestAcknowledge).ConfigureAwait(false);

                            break;
                        }
                    }
                };

                loop.Start();

                while (message == null)
                {
                    Thread.Sleep(1000);
                }

                Assert.IsTrue(message.S == 1 && message.F == 4);
                Assert.IsTrue(message.SecsItem.Count == statusValuesLength);
                Assert.AreEqual(expectedTotalRawBytesCount, message.RawBytes.SelectMany(x => x).Count(), nameof(expectedTotalRawBytesCount));
            }
        }
Ejemplo n.º 18
0
        public static bool Drop(this Item item, IActor giverActor, IActor takerActor, int quantity)
        {
            IAvatar taker     = takerActor as IAvatar;
            IAvatar giver     = giverActor as IAvatar;
            IActor  container = null;

            // Ensure a container exists to recevie the item.
            if (taker != null && taker is Character)
            {
                container = (taker as Character).GetFirstAvailableContainer(item);
            }
            else
            {
                container = takerActor;
            }

            if (container == null)
            {
                if (taker != null)
                {
                    taker.Context.Add(new RdlErrorMessage(Resources.InventoryFull));
                }
                else if (giver != null)
                {
                    giver.Context.Add(new RdlErrorMessage(Resources.CanNotDrop));
                }
                return(false);
            }

            // Adjust quantity.
            if (quantity > item.Quantity())
            {
                quantity = item.Quantity();
            }

            // If the specified item has an IsInventoryItem property value of false then immediately
            // USE this item and do not add it to the taker's inventory.
            if (item.IsInventoryItem)
            {
                List <Item> items = new List <Item>();
                if (item.IsStackable && item.Quantity() > 1 && item.Owner != null)
                {
                    if (item.Owner is Npc)
                    {
                        for (int i = 0; i < quantity; i++)
                        {
                            items.Add(item.Clone() as Item);
                        }
                    }
                    else
                    {
                        items = item.Owner.Children.Where(c => c is Item &&
                                                          c.GetType() == item.GetType() &&
                                                          c.Name.Equals(item.Name)).Select(c => c as Item).Take(quantity).ToList();
                    }
                }
                else
                {
                    items.Add(item);
                }

                // If the container is an actual Container instance then the container must be able to hold
                // all of the available items.
                if (taker is Character)
                {
                    for (int i = 0; i < items.Count; i++)
                    {
                        container = (taker as Character).GetFirstAvailableContainer(items[i]);
                        if (container == null)                        // || !((container as Container).GetRemainingSlots(items[i]) >= quantity))
                        {
                            if (taker != null)
                            {
                                taker.Context.Add(new RdlErrorMessage(Resources.InventoryNotEnoughSpace));
                            }
                            else if (giver != null)
                            {
                                giver.Context.Add(new RdlErrorMessage(Resources.CanNotDrop));
                                // Send the item back down to the client.
                                giver.Context.AddRange(item.ToRdl());
                            }
                            return(false);
                        }
                    }
                }

                // Add the items to the container.
                for (int i = 0; i < items.Count; i++)
                {
                    Item newItem = items[i];
                    // If giver is NPC Merchant then clone the templates rather than drop them.
                    if (giver is IMerchant)
                    {
                        newItem = items[i].Clone() as Item;
                    }

                    // Clear the owner and save the object.
                    if (newItem.ID == 0)
                    {
                        newItem.Owner = null;
                        newItem.Save();
                    }

                    // If taker is a Character then different rules apply to where stuff is dropped.
                    if (taker is Character)
                    {
                        Character character = taker as Character;
                        if (newItem is ISpell)
                        {
                            // Spells.Add will add the item to the child collection.
                            character.Spells.Add((ISpell)newItem);
                            character.Context.AddRange(character.GetRdlProperties(String.Concat(character.Spells.Prefix, character.Spells.Count - 1)));
                        }
                        else if (newItem is Container && character.Bags.Count < 5)
                        {
                            character.Bags.Add((Container)newItem);
                            character.Context.AddRange(character.GetRdlProperties(String.Concat(character.Bags.Prefix, character.Bags.Count - 1)));
                        }
                        else
                        {
                            container = (taker as Character).GetFirstAvailableContainer(newItem);
                            if (container != null)
                            {
                                newItem.Drop(container);
                            }
                            else
                            {
                                taker.Context.Add(new RdlErrorMessage(Resources.InventoryNotEnoughSpace));
                            }
                        }
                    }
                    else
                    {
                        newItem.Drop(container);
                    }

                    if (taker != null)
                    {
                        taker.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Positive,
                                                               String.Format(Resources.ItemAdded, newItem.AUpper())));
                    }

                    if (takerActor is Place)
                    {
                        if (giver != null)
                        {
                            giver.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.None,
                                                                   String.Format(Resources.ItemDropped, newItem.A())));
                        }
                    }

                    // Send the taker the item and a remove command so the item will be removed from the giver.
                    if (taker != null && giver != null)
                    {
                        taker.Context.Add(newItem.GetRemoveCommand(giver.ID));
                    }
                    if (taker != null)
                    {
                        taker.Context.AddRange(newItem.ToRdl());
                    }

                    // Send the giver the item with the new owner and a remove command so the item will be removed.
                    if (giver != null)
                    {
                        giver.Context.Add(newItem.GetRemoveCommand(giver.ID));
                    }
                    if (giver != null)
                    {
                        giver.Context.AddRange(newItem.ToRdl());
                    }
                }
            }
            else
            {
                for (int i = 0; i < quantity; i++)
                {
                    // USE the item.
                    giver.SetTarget(taker);
                    if (item is Spell)
                    {
                        // Spells need to be cast by the giver onto the taker.
                        if (taker != null)
                        {
                            item.Use(giver, taker.Context);
                        }
                    }
                    else
                    {
                        // All other items ned to be used by the taker.
                        if (taker != null)
                        {
                            item.Use(taker, taker.Context);
                        }
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Validates the requirements for this quest and if valid, completes the quest and issues the rewards to the owner.
        /// </summary>
        public void Complete()
        {
            if (this.Validate(true))
            {
                Character owner = this.Owner as Character;
                if (owner != null)
                {
                    if (!this.IsComplete)
                    {
                        // Complete the quest.
                        this.IsComplete = true;

                        // Raise the onComplete event.
                        this.OnComplete();

                        owner.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Positive,
                                                               String.Format(Resources.QuestCompleteLogUpdated, this.Name)));
                        owner.Context.AddRange(this.ToRdl());

                        // Emblem
                        if (this.RewardEmblem > 0)
                        {
                            User user = SecurityManager.GetUser(owner.UserName);
                            if (user != null)
                            {
                                user.Tokens += this.RewardEmblem;
                                owner.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Positive,
                                                                       String.Format(Resources.EmblemGained,
                                                                                     this.RewardEmblem, this.Name)));
                                owner.Context.Add(new RdlProperty(owner.ID, "Emblem", user.Tokens));
                            }
                        }

                        // Currency
                        if (this.RewardCurrency.Value > 0)
                        {
                            owner.Currency.Value += this.RewardCurrency.Value;
                            owner.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Positive,
                                                                   String.Format(Resources.CurrencyGained, this.RewardCurrency.ToString())));
                            owner.Context.AddRange(owner.GetRdlProperties(Character.CurrencyProperty));
                        }

                        // Items
                        bool processLoop = true;
                        foreach (var reward in this.RewardItems)
                        {
                            if (processLoop)
                            {
                                for (int i = 0; i < reward.Quantity; i++)
                                {
                                    Item item = this.World.CreateFromTemplate <Item>(reward.Name);
                                    if (item != null)
                                    {
                                        Container container = owner.GetFirstAvailableContainer();
                                        if (container != null)
                                        {
                                            item.Drop(container);
                                            item.Save();
                                            owner.Context.AddRange(item.ToRdl());
                                            owner.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Positive,
                                                                                   String.Format(Resources.ItemGained, item.A())));
                                        }
                                        else
                                        {
                                            owner.Context.Add(new RdlErrorMessage(Resources.InventoryFull));
                                            processLoop = false;
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                break;
                            }
                        }

                        // Experience
                        if (this.RewardExperience > 0)
                        {
                            owner.Experience      += this.RewardExperience;
                            owner.TotalExperience += this.RewardExperience;
                            owner.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Positive,
                                                                   String.Format(Resources.ExperienceGained, this.RewardExperience)));

                            // Cause the player to advance if the required experience requirements are met.
                            LevelManager.AdvanceIfAble(owner);

                            owner.Context.AddRange(owner.GetRdlProperties(
                                                       Character.ExperienceProperty,
                                                       Character.ExperienceMaxProperty));
                        }

                        // Skill
                        if (this.RewardSkillValue > 0)
                        {
                            owner.Skills[this.RequiredSkill] += this.RewardSkillValue;

                            owner.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Positive,
                                                                   String.Format(Resources.SkillGained, this.RewardSkillValue)));

                            owner.Context.AddRange(owner.GetRdlProperties(String.Concat(owner.Skills.Prefix, this.RequiredSkill)));
                        }

                        // Save the owner instance.
                        owner.Save();
                        // Save the quest instance.
                        this.Save();

                        // Send down the completed quest details to the owner.
                        owner.Context.AddRange(this.ToRdl());

                        // TODO: If a quest auto starts another quest then the UI should display the new quest right away
                        // instead of auot adding it.
                        //// Some quests may auto start other quests without being given from an Actor instance.
                        //if (!String.IsNullOrEmpty(this.OnCompleteAutoStartQuestName))
                        //{
                        //    Quest quest = this.World.GetTemplate<Quest>(this.OnCompleteAutoStartQuestName);
                        //    if (quest != null)
                        //    {
                        //        quest.Start(owner);
                        //    }
                        //}
                    }
                    else
                    {
                        owner.Context.Add(new RdlErrorMessage(Resources.QuestAlreadyComplete));
                    }
                }
            }
        }
Ejemplo n.º 20
0
 private void DefineAllReportsForSpecificEquipmentButton_Click(object sender, EventArgs e)
 {
     //DefineAllReportsForSpecificEquipment
     _secsGem.SendAsync(new SecsMessage(2, 33, "DeleteAllReports", Item.L(
                                            Item.U4(1),
                                            Item.L(
                                                Item.L(
                                                    Item.U4(14),
                                                    Item.L(
                                                        Item.A("210003")
                                                        )
                                                    ), Item.L(
                                                    Item.U4(4),
                                                    Item.L(
                                                        Item.A("210001"),
                                                        Item.A("210003"),
                                                        Item.A("210017"),
                                                        Item.A("210008")
                                                        )
                                                    ),
                                                Item.L(//Report:"BasePlateDotCodesReadReport"
                                                    Item.U4(2),
                                                    Item.L(
                                                        Item.L(
                                                            Item.A("210000"),
                                                            Item.A("210001"),
                                                            Item.A("210017")
                                                            ),
                                                        Item.A("210001"),
                                                        Item.A("210017")
                                                        )
                                                    ),
                                                Item.L(//Report:"FramePickedReport"
                                                    Item.U4(3),
                                                    Item.L(
                                                        Item.A("210001"),
                                                        Item.A("210004"),
                                                        Item.A("210017")
                                                        )
                                                    ),
                                                Item.L(//Report:"WT2CarrierPickedReport"
                                                    Item.U4(16),
                                                    Item.L(
                                                        Item.A("210019"),
                                                        Item.A("210017")
                                                        )
                                                    ),
                                                Item.L(//Report:"CarrierFinishedReport"
                                                    Item.U4(5),
                                                    Item.L(
                                                        Item.A("210019"),
                                                        Item.L(
                                                            Item.U1(Byte.Parse("210010")),
                                                            Item.A("210001"),
                                                            Item.A("210004")
                                                            )
                                                        )
                                                    ),
                                                Item.L(//Report:"BasePlateScrappedReport"
                                                    Item.U4(3),
                                                    Item.L(
                                                        Item.A("210001"),
                                                        Item.A("210004")
                                                        )
                                                    ),
                                                Item.L(//Report:"FrameScrappedReport"
                                                    Item.U4(3),
                                                    Item.L(
                                                        Item.A("210017"),
                                                        Item.A("210004")
                                                        )
                                                    ),
                                                Item.L(//Report:"FrameScrappedReport"
                                                    Item.U4(8),
                                                    Item.L(
                                                        Item.A("200001"),
                                                        Item.A("200002")
                                                        )
                                                    )
                                                ))));
 }
Ejemplo n.º 21
0
        void HandleTCS(PPBodyQueryRequest tx)
        {
            if (tx.Type != "Sequence")
            {
                return;
            }

            var s7f26 = EAP.Send(new SecsMessage(7, 25, "PPBodyQuery", Item.A(tx.PPID)));

            if (s7f26.SecsItem.Items[0].ToString() != tx.PPID)
            {
                throw new ScenarioException("PPID unmatch!!!");
            }

            if (s7f26.SecsItem.Items[3].Count < 5)
            {
                throw new ScenarioException("PPBody is empty");
            }

            var bodyList = s7f26.SecsItem.Items[3].Items;

            for (int i = 0; i < bodyList.Count; i++)
            {
                Item   item        = bodyList[i];
                string chamberItem = item.Items[1].Items[0].ToString();

                switch (chamberItem)
                {
                case "LL-H":     //Step1 LL-H RecipeName
                    tx.Add(new PPBodyItem {
                        ID1   = "1",
                        ID2   = chamberItem,
                        Value = item.Items[1].Items[1].ToString()
                    });
                    break;

                case "B":     //Step2 B RecipeName
                case "C":     //Step2 C RecipeName
                case "D":     //Step2 D RecipeName
                    string chamberRecipe = item.Items[1].Items[1].ToString();
                    if (chamberRecipe.Contains("Shutter"))
                    {
                        continue;
                    }

                    tx.Add(new PPBodyItem {
                        ID1   = "2",
                        ID2   = chamberItem,
                        Value = chamberRecipe
                    });

                    int stepCount = int.Parse(item.Items[1].Items[2].ToString());
                    int paramNum  = int.Parse(item.Items[1].Items[3].ToString());
                    for (int j = i + 1; j < i + paramNum + 1; j++)
                    {
                        item = bodyList[j];
                        string itemName;
                        if (_nameMap.TryGetValue(item.Items[0].FirstValue <ushort>(), out itemName))
                        {
                            for (int step = 0; step < stepCount; step++)
                            {
                                tx.Add(new PPBodyItem {
                                    ID1   = "2",
                                    ID2   = chamberItem,
                                    ID3   = "Step" + (step + 1),
                                    ID4   = itemName,
                                    Value = item.Items[1].Items[1 + 4 * step].ToString()
                                });
                            }
                        }
                    }
                    i += paramNum;
                    break;
                }
            }
        }
Ejemplo n.º 22
0
        public override void Cast(IAvatar caster, IActor target, CastResults results)
        {
            if (!String.IsNullOrEmpty(this.ItemTypeName))
            {
                Item item = this.World.CreateActor(Type.GetType(this.ItemTypeName), this.ItemName) as Item;
                if (item != null)
                {
                    if (caster is Character)
                    {
                        Container container = (caster as Character).GetFirstAvailableContainer(item);
                        if (container != null)
                        {
                            item.Drop(container);
                            item.Save();

                            caster.Context.Add(new RdlSystemMessage(RdlSystemMessage.PriorityType.Cast,
                                                                    String.Format(Resources.ItemCreated, item.A())));
                        }
                        else
                        {
                            caster.Context.Add(new RdlErrorMessage(Resources.InventoryFull));
                        }
                    }
                    else
                    {
                        item.Drop(caster);
                    }
                }
                else
                {
                    caster.Context.Add(new RdlErrorMessage(Resources.CastFailed));
                }
            }
        }
Ejemplo n.º 23
0
        private void btnEnable_Click(object sender, EventArgs e)
        {
            _secsGem?.Dispose();
            _secsGem = new SecsGem(
                radioActiveMode.Checked,
                radioActiveMode.Checked?IPAddress.Parse(txtAddress.Text):IPAddress.Any,
                (int)numPort.Value,
                (int)numBufferSize.Value)
            {
                Logger = _logger, DeviceId = (ushort)numDeviceId.Value
            };
            _secsGem.LinkTestEnable     = true;
            _secsGem.LinkTestInterval   = 60000;
            _secsGem.ConnectionChanged += delegate
            {
                this.Invoke((MethodInvoker) delegate
                {
                    lbStatus.Text = _secsGem.State.ToString();
                    if (_secsGem.State == ConnectionState.Selected && _secsGem.IsActive)
                    {
                        _secsGem.SendAsync(new SecsMessage(1, 13, "Online Request", Item.L(Item.A(), Item.A())));
                    }
                });
            };

            Settings1.Default.ActiveMode = radioActiveMode.Checked;
            Settings1.Default.Save();

            _secsGem.PrimaryMessageReceived += PrimaryMessageReceived;

            btnEnable.Enabled = false;
            _secsGem.Start();
            btnDisable.Enabled = true;
        }