Exemple #1
0
 public void start( AID aid )
 {
     //addAniamtion( new Jump_sub( "1019"));
     //addAniamtion( new Jump_sub( "1020"));
     //addAniamtion( new Jump_sub( "1021"));
     //addAniamtion( new Jump_sub( "1022"));
 }
        public void ProcessData(string message, AID processorAgentId)
        {
            var partOfMessage = message.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
            var result        = Sum(partOfMessage[1], partOfMessage[2]);

            messageForProc[new AID(partOfMessage[0], true)] = result;
        }
Exemple #3
0
 public Jump_sub( AID aid  )
 {
     //_aType = aType;
     ///am[ _aType ].weight   = weight;
     //am[ _aType ].layer    = layer;
     //am[ _aType ].wrapMode = wrapMode;
 }
Exemple #4
0
 public override void Handle(object message, AID sender)
 {
     if (message is FindMyServicesRequest)
     {
         Handle((FindMyServicesRequest)message, sender);
     }
 }
Exemple #5
0
        public override void setup()
        {
            object[] args = this.getArguments();
            if (args != null)
            {
                windowsForm = (FormAgent)args[0];
            }

            windowsForm.Text = this.getName();
            windowsForm.Show();

            providerAID = YellowPages.FindService("AuctionService", this, 10);

            if (providerAID == null)
            {
                windowsForm.AddTextLine("No auction provider found.");
            }
            else
            {
                windowsForm.AddTextLine("Found auction provider: " + providerAID.getLocalName());

                addBehaviour(new BuyerRegister(this));
                addBehaviour(new BuyerReceive(this));
            }
        }
Exemple #6
0
 public void Handle(FoundTransportServicesResponse message, AID sender)
 {
     foreach (var transport in message.Tranports)
     {
         Console.WriteLine($"Found Transport: {transport.Description}, {transport.TransportFromCity}.");
     }
 }
Exemple #7
0
 public void Handle(FoundHotelServicesResponse message, AID sender)
 {
     foreach (var hotel in message.Hotels)
     {
         Console.WriteLine($"Found Hotel: {hotel.Description}, {hotel.NumberOfStars}.");
     }
 }
Exemple #8
0
        public override void action()
        {
            ACLMessage aCLMessage = new ACLMessage(ACLMessage.INFORM);

            AID aID = null;

            if (args != null && args.Length == 1)
            {
                string name = args[0] as string;
                aID = new AID(name, AID.ISLOCALNAME);
            }
            else if (args != null && args.Length == 2)
            {
                string name = args[0] as string;
                string host = args[1] as string;
                aID = new AID(name + "@" + host + ":1099/JADE", AID.ISGUID);
                aID.addAddresses("http://" + host + ":7778/acc");
            }
            else
            {
                aID = new AID("dummyReceiver", AID.ISLOCALNAME);
            }

            aCLMessage.addReceiver(aID);
            aCLMessage.setSender(myAgent.getAID());
            aCLMessage.setContent("Prova contenuto");
            myAgent.send(aCLMessage);
            Console.WriteLine("AID is " + aID.getName());
            Console.WriteLine("Message sent");
            myAgent.doDelete();
        }
        public override void action()
        {
            ACLMessage aCLMessage = new ACLMessage(ACLMessage.INFORM);

            AID aID = null;

            if (args != null && args.Length == 1)
            {
                string name = args[0] as string;
                aID = new AID(name, AID.ISLOCALNAME);
            }
            else if (args != null && args.Length == 2)
            {
                string name = args[0] as string;
                string host = args[1] as string;
                aID = new AID(name+"@"+host+":1099/JADE", AID.ISGUID);
                aID.addAddresses("http://"+host+":7778/acc");
            }
            else
                aID = new AID("dummyReceiver", AID.ISLOCALNAME);

            aCLMessage.addReceiver(aID);
            aCLMessage.setSender(myAgent.getAID());
            aCLMessage.setContent("Prova contenuto");
            myAgent.send(aCLMessage);
            Console.WriteLine("AID is "+aID.getName());
            Console.WriteLine("Message sent");
            myAgent.doDelete();
        }
        public override void Handle(object message, AID sender)
        {
            base.Handle(message, sender);

            if (message is INeedHotelServicesRequest)
            {
                Handle((INeedHotelServicesRequest)message, sender);
            }
        }
        public void Handle(ServicesFoundResponse message, AID sender)
        {
            foreach (var hotelServiceInformation in message.ServicesInformation.Select(DeserializeWith))
            {
                Services.Add(hotelServiceInformation);
            }

            Console.WriteLine($"{ServiceName}: I have {Services.Count} services.");
        }
Exemple #12
0
        public override void Handle(object message, AID sender)
        {
            base.Handle(message, sender);

            if (message is INeedTouristAttractionServicesRequest)
            {
                Handle((INeedTouristAttractionServicesRequest)message, sender);
            }
        }
Exemple #13
0
        public void SendMessage(AID to, object info, int type = ACLMessage.REQUEST)
        {
            var reply       = new ACLMessage(type);
            var receiverAid = new AID(to.getLocalName(), AID.ISLOCALNAME);

            reply.addReceiver(receiverAid);

            reply.setContent(JsonConvert.SerializeObject(info));
            send(reply);
        }
        public void Handle(INeedHotelServicesRequest message, AID sender)
        {
            List <HotelServiceInformation> hotelServiceInformations = Services.GetFor(message).ToList();

            SendMessage(
                sender,
                new FoundHotelServicesResponse
            {
                CorrelationId = message.CorrelationId,
                Hotels        = hotelServiceInformations
            });
        }
        public override void Handle(object message, AID sender)
        {
            if (message is ServicesFoundResponse)
            {
                Handle((ServicesFoundResponse)message, sender);
            }

            if (message is NewServicesFound)
            {
                Handle((NewServicesFound)message, sender);
            }
        }
 //播放动作
 public void play( AID aid )
 {
     IBaseAnimation am = getAnimation( aid );
     if ( am != null &&  _animation != null)
     {
         am.play( _animation, null );
     }
     else
     {
         Debug.Log( "Function: play --  the player '" + _playerName + "' didn't have animation " + aid.id );
     }
 }
 public float animationClipNormalize( AID aid )
 {
     IBaseAnimation am = getAnimation( aid );
     if ( am != null ){
         return am.animationTimeNormalize( _animation );
     }
     else
     {
         Debug.Log( "Function: animationClipNormalize --  the player '" + _playerName + "' didn't have animation " + aid.id );
         return 0.0f;
     }
 }
        public void Handle(INeedTransportServicesRequest message, AID sender)
        {
            List <TransportServiceInformation> transportServiceInformations = Services.GetFor(message).ToList();

            SendMessage(
                sender,
                new FoundTransportServicesResponse
            {
                CorrelationId = message.CorrelationId,
                Tranports     = transportServiceInformations
            });
        }
 public void Handle(FoundTouristAttractionServicesResponse message, AID sender)
 {
     foreach (var activity in message.Activities)
     {
         PrintInfomation($"Found Activity:" +
                         $"\r\n\tName: {activity.Name}, " +
                         $"\r\n\tDescription: {activity.Description}, " +
                         $"\r\n\tActivity Type: {activity.ActivityType}," +
                         $"\r\n\tEvent Date: {activity.DateStart} - {activity.DateEnd}," +
                         $"\r\n\tPrice: {activity.Price}, ");
     }
 }
Exemple #20
0
        public override void Handle(object message, AID sender)
        {
            if (message is FoundHotelServicesResponse)
            {
                Handle((FoundHotelServicesResponse)message, sender);
            }

            if (message is FoundTransportServicesResponse)
            {
                Handle((FoundTransportServicesResponse)message, sender);
            }
        }
Exemple #21
0
        public void Handle(INeedTouristAttractionServicesRequest message, AID sender)
        {
            List <TouristAttractionServiceInformation> touristAttractionServiceInformations =
                Services.GetFor(message).ToList();

            SendMessage(
                sender,
                new FoundTouristAttractionServicesResponse
            {
                CorrelationId = message.CorrelationId,
                Activities    = touristAttractionServiceInformations
            });
        }
Exemple #22
0
 public void Handle(FindMyServicesRequest message, AID sender)
 {
     SendMessage(
         sender,
         new ServicesFoundResponse
     {
         CorrelationId       = message.CorrelationId,
         ServicesInformation =
             services.Where(service => service.ServiceType == message.ServiceType)
             .Select(service => service.ServiceInformation)
             .ToList()
     });
 }
    //设置动作时间
    public void animationClipEvent( AID aid, AnimationEvent ae )
    {
        IBaseAnimation am = getAnimation( aid );

        if ( am != null )
        {
            am.setAnimationEvent( _animation, ae );
        }
        else
        {
            Debug.Log( "Function: animationClipEvent --  the player '" + _playerName + "' didn't have animation " + aid.id );
        }
    }
 public void Handle(FoundTransportServicesResponse message, AID sender)
 {
     foreach (var transport in message.Tranports)
     {
         PrintInfomation($"Found Transport:" +
                         $"\r\n\tName: {transport.Name}, " +
                         $"\r\n\tDescription: {transport.Description}, " +
                         $"\r\n\tFrom (Country): {transport.TransportFromCountry}, " +
                         $"\r\n\tFrom (City): {transport.TransportFromCity}, " +
                         $"\r\n\tTransport Type: {transport.TransportType}," +
                         $"\r\n\tPrice: {transport.Price}, ");
     }
 }
Exemple #25
0
        public override void action()
        {
            //inform managerAgent that I want to register for the auction

            ACLMessage m = new ACLMessage(ACLMessage.INFORM);

            AID receiverAID = new AID("managerAgent", AID.ISLOCALNAME);
            m.addReceiver(receiverAID);
            m.setContent("registering");
            myAgent.send(m);

            myAgent.windowsForm.AddTextLine("Registering for auction ...");
        }
 public void Handle(FoundHotelServicesResponse message, AID sender)
 {
     foreach (var hotel in message.Hotels)
     {
         PrintInfomation($"Found Hotel: " +
                         $"\r\n\tName: {hotel.Name}, " +
                         $"\r\n\tDescription: {hotel.Description}, " +
                         $"\r\n\tCountry: {hotel.Country}, " +
                         $"\r\n\tCity: {hotel.City}, " +
                         $"\r\n\tNumber of rooms: {hotel.NumberOfRooms}, " +
                         $"\r\n\tNumber of people per room: {hotel.NumberOfPeoplePerRoom}, " +
                         $"\r\n\tNumberOfStars: {hotel.NumberOfStars}," +
                         $"\r\n\tPrice: {hotel.Price}, ");
     }
 }
        public void ProcessData(string message, AID processorAgentId)
        {
            var arrays = message.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
            var array1 = arrays[0].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            var array2 = arrays[1].Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

            var necessaryNrOfHelpers = array1.Count() / Constants.HelperCapacity;

            necessaryNrOfHelpers = (array1.Count() % Constants.HelperCapacity != 0) ? necessaryNrOfHelpers + 1 : necessaryNrOfHelpers;
            Constants.helpersNeeded[processorAgentId.getName()] = necessaryNrOfHelpers;

            GenerateHelperAgents(processorAgentId, necessaryNrOfHelpers);

            GenerateDataForHelperAgents(array1.ToList(), array2.ToList(), necessaryNrOfHelpers, processorAgentId);
        }
        public void GenerateHelperAgents(AID processorAgentId, int number)
        {
            String index;

            for (int i = 0; i < number; i++)
            {
                index = (i < 9) ? "0" + i : i.ToString();
                helperContainers.Add(JadeHelper.CreateContainer("container" + i, false, "localhost", null, "14" + index));
                helperAgents.Add(JadeHelper.CreateAgent(helperContainers[i], "HelperAgent" + i + processorAgentId.getLocalName(), "Project_MASMA.HelperAgent", null));
            }
            for (int i = 0; i < number; i++)
            {
                helperContainers[i].start();
                helperAgents[i].start();
            }
        }
Exemple #29
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (entityId_ != null)
            {
                hash ^= EntityId.GetHashCode();
            }
            if (authorizationAmount_ != null)
            {
                hash ^= AuthorizationAmount.GetHashCode();
            }
            if (Result != 0)
            {
                hash ^= Result.GetHashCode();
            }
            if (EntryMethod != 0)
            {
                hash ^= EntryMethod.GetHashCode();
            }
            if (HostReferenceNumber.Length != 0)
            {
                hash ^= HostReferenceNumber.GetHashCode();
            }
            if (ApprovalCode.Length != 0)
            {
                hash ^= ApprovalCode.GetHashCode();
            }
            if (ApplicationLabel.Length != 0)
            {
                hash ^= ApplicationLabel.GetHashCode();
            }
            if (ApplicationCrypto.Length != 0)
            {
                hash ^= ApplicationCrypto.GetHashCode();
            }
            if (AID.Length != 0)
            {
                hash ^= AID.GetHashCode();
            }
            if (postedAt_ != null)
            {
                hash ^= PostedAt.GetHashCode();
            }
            return(hash);
        }
Exemple #30
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter = @"AID File (*.aid)|*.aid"
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                _path   = openFileDialog.FileName.TrimEnd(Path.DirectorySeparatorChar);
                _mapInx = _path.Substring(_path.LastIndexOf(Path.DirectorySeparatorChar) + 1);

                AID = AID.Load(openFileDialog.FileName);

                AIDListBox.DataSource = AID.Data;
                AIDPropertyGrid.ExpandAllGridItems();
                UpdateButtons(true);
            }
        }
        void Send(int startIndex, int lastIndex, AID agentId)
        {
            ACLMessage toSendFirstArray  = new ACLMessage(ACLMessage.REQUEST);
            ACLMessage toSendSecondArray = new ACLMessage(ACLMessage.REQUEST);

            String content1 = "FirstSubset ";
            String content2 = "SecondSubset ";

            for (int index = startIndex; index < lastIndex; index++)
            {
                content1 += matrix1[(index / Constants.MatrixSize), index % Constants.MatrixSize] + " ";
                content2 += matrix2[(index / Constants.MatrixSize), index % Constants.MatrixSize] + " ";
            }

            toSendFirstArray.setContent(content1);
            toSendFirstArray.addReceiver(agentId);
            this.send(toSendFirstArray);

            toSendSecondArray.setContent(content2);
            toSendSecondArray.addReceiver(agentId);
            this.send(toSendSecondArray);
        }
Exemple #32
0
        private void button2_Click(object sender, EventArgs e)
        {
            int  AD;
            bool res = int.TryParse(AID.Text, out AD);

            if (res == true)
            {
                DataTable checkValidID = controllerObj.AIDExist(Int32.Parse(AID.Text));
                if (checkValidID != null)
                {
                    controllerObj.InsertAniShow(Int32.Parse(AID.Text), comboBox2.Text);
                    AID.Clear();
                }

                else
                {
                    MessageBox.Show(" AID Animal ID, please insert another ID. ");
                }
            }
            else
            {
                MessageBox.Show(" AID Animal ID, please insert another ID. ");
            }
        }
        public void GenerateDataForHelperAgents(List <string> array1, List <string> array2, int nrNeccessaryNrOfHelp, AID processorAgentId)
        {
            string result = String.Empty;

            for (int i = 0; i < nrNeccessaryNrOfHelp; i++)
            {
                result = String.Empty;
                if (i < nrNeccessaryNrOfHelp - 1)
                {
                    var firstMatrix  = array1.GetRange(i * Constants.HelperCapacity, Constants.HelperCapacity);
                    var secondMatrix = array2.GetRange(i * Constants.HelperCapacity, Constants.HelperCapacity);
                    messagesToSend[new AID(helperAgents[i].getName(), true)] = processorAgentId.getName() + "|" + GetMessage(firstMatrix, secondMatrix);
                }
                else
                {
                    var firstMatrix  = array1.GetRange(i * Constants.HelperCapacity, array1.Count - i * Constants.HelperCapacity);
                    var secondMatrix = array2.GetRange(i * Constants.HelperCapacity, array2.Count - i * Constants.HelperCapacity);
                    messagesToSend[new AID(helperAgents[i].getName(), true)] = processorAgentId.getName() + "|" + GetMessage(firstMatrix, secondMatrix);
                }
            }
        }
    //加载动作
    private IBaseAnimation loadAM( AID aid )
    {
        Type animationType = null;
        if ( aid != null )
        {
            animationType = AnimationKeyValue.getSingleton().getAnimation( aid );
            if ( animationType != null && animationType == IBaseAnimation )
            {
                if ( animationType.BaseType == AniamtionContainer )
                {
                    animationType am = new animationType();
                    ( am as AniamtionContainer ).start( aid );
                    _hashtable.Add( aid.id,  am );
                }
                else
                {
                    _hashtable.Add( aid.id,  animationType );
                }

            }
            else
            {
                Debug.Log( " the animation '" + aid.id + "' do not registered" );
                return null;
            }
        }
        return animation;
    }
 public Shareable getShareableInterfaceObject(AID id, byte param)
 {
     return (test)this;
 }
 public Shareable getShareableInterfaceObject(AID id, byte param)
 {
     return((test)this);
 }
 public void setLoadFile(AID aid)
 {
     this.loadfile = aid;
 }
 public virtual void start( AID aid );
Exemple #39
0
 /// <summary>
 /// Fills the envelope's message.
 /// Use in case of reply-to is not equals to sender's AID.
 /// </summary>
 /// <param name="senderAID">Sender's AID</param>
 /// <param name="receiverAID">Receiver's AID</param>
 /// <param name="replyToAID">Reply to's AID</param>
 public void AddEnvelope(AID senderAID, AID receiverAID, AID replyToAID)
 {
     this._sender   = senderAID;
     this._receiver = receiverAID;
     this._replyTo  = replyToAID;
 }
    //获取动作
    private IBaseAnimation getAnimation( AID aid )
    {
        IBaseAnimation am = _hashtable[ aid.id ] as IBaseAnimation;
        if ( am == null )
        {
            am = loadAM( aid );
        }

        return am;
    }
 Disp(AID sender, string message)
 {
     this.sender  = sender;
     this.message = message;
 }
Exemple #42
0
 public abstract void Handle(object message, AID sender);
        private void response(APDU apdu)
        {
        //     static void reply(APDU apdu, sbyte a0, sbyte a1, sbyte a2, sbyte a3)
        //{
        //    var buffer = apdu.getBuffer();
        //    buffer[0] = a0;
        //    buffer[1] = a1;
        //    buffer[2] = a2;
        //    buffer[3] = a3;
        //    apdu.setOutgoingAndSend(0, 4);
        //}


            //upload "E:\jsc.svn\examples\java\javacard\JavacardAppletExample\JavacardAppletExample\bin\Release\web\release\JavacardAppletExample\javacard\JavacardAppletExample.cap"
            //upload "E:\jsc.svn\examples\java\javacard\TestjavaAppletCommunication\TestjavaAppletCommunication\bin\Release\web\release\JavacardAppletExample\javacard\JavacardAppletExample.cap"
            //install A0A1A2A3A40002 A0A1A2A3A4000202
            //install A0A1A2A3A40003 A0A1A2A3A4000301

            if (APDU.getProtocol() != APDU.PROTOCOL_MEDIA_USB)
            {

                var buffer = apdu.getBuffer();

                var CLA = buffer[ISO7816Constants.OFFSET_CLA];
                var INS = buffer[ISO7816Constants.OFFSET_INS];
                var P1 = buffer[ISO7816Constants.OFFSET_P1];
                var P2 = buffer[ISO7816Constants.OFFSET_P2];
                var LC = buffer[ISO7816Constants.OFFSET_LC];

                //var rets = new sbyte[5];
                //rets[0] = CLA;
                //rets[1] = INS;
                //rets[2] = P1;
                //rets[3] = P2;
                //rets[4] = LC;

                //buffer = rets;
                //apdu.setOutgoingAndSend(0, (short)rets.Length);


                //reply(apdu, INS, P1, P2, LC);
                List<sbyte[]> whiteList = new List<sbyte[]>();

                byte[] masterFile = new byte[] { 0x00, 0xA4, 0x00, 0x0C };
                byte[] EEEEcatalogue = new byte[] { 0x00, 0xA4, 0x01, 0x0C, 0x02, 0xEE, 0xEE };
                byte[] setSecEnv1 = new byte[] { 0x00, 0x22, 0xF3, 0x01 };
                byte[] signatureHash = new byte[] { 0x00, 0x2a, 0x9E, 0x9A }; // Partly. Additional length and hash is provided
                byte[] pin1VerifyPartly = new byte[] { 0x00, 0x20, 0x00, 0x01};
                byte[] pukVerifyPartly = new byte[] { 0x00, 0x20, 0x00, 0x00 };
                byte[] pin2VerifyPartly = new byte[] { 0x00, 0x20, 0x00, 0x02 }; //additional Pin2 len and Pin2 as ASCII
                byte[] selectFile5044 = new byte[] { 0x00, 0xa4, 0x02, 0x04};
                byte[] selectFromPersoFile = new byte[] {0x00, 0xB2, 0x01, 0x04, 0x00 };
                byte[] readPersoResponse = new byte[] { 0x00, 0xC0, 0x00, 0x00 };


                whiteList.Add((sbyte[])(object)masterFile);
                whiteList.Add((sbyte[])(object)EEEEcatalogue);
                whiteList.Add((sbyte[])(object)setSecEnv1);
                whiteList.Add((sbyte[])(object)signatureHash);
                whiteList.Add((sbyte[])(object)pin1VerifyPartly);
                whiteList.Add((sbyte[])(object)pukVerifyPartly);
                whiteList.Add((sbyte[])(object)pin2VerifyPartly);
                whiteList.Add((sbyte[])(object)selectFile5044);
                //whiteList.Add((sbyte[])(object)selectFromPersoFile);
                whiteList.Add((sbyte[])(object)readPersoResponse);

                var isValid = false;

                foreach (var arr in whiteList)
                {
                    if (arr[0] == CLA && arr[1] == INS && arr[2] == P1 && arr[3] == P2)
                    {
                        isValid = true;
                    }

                    if(CLA == selectFromPersoFile[0] && INS == selectFromPersoFile[1] && selectFromPersoFile[2] > 0x00 && selectFromPersoFile[2] > 0x10 && P2 == selectFromPersoFile[3])
                    {
                        isValid = true;
                    }
                }
                         


                byte[] AID = { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0x00, 0x02, 0x02 };
                var casted = (sbyte[])(object)AID;
                var s = new AID(casted, 0, (sbyte)casted.Length);


                if (casted == null)
                {
                    reply(apdu, 6, 6, 6, 6);
                    return;
                }

                if (s == null)
                {
                    reply(apdu, 5, 5, 5, 5);
                    return;
                }

                if (!isValid)
                {
                    reply(apdu, 2, 2, 2, 2);
                    return;
                }

                var temp = JCSystem.getAppletShareableInterfaceObject(s, 0);

                if (temp == null)
                {
                    reply(apdu, 1, 1, 1, 1);
                }
                else
                {
                    //reply(apdu, 3, 3, 3, 3);
                    
                    test sio = (test)temp;
                    var ret = sio.GetAnswerFromOtherApplet(apdu);
                    if (sio == null)
                    {
                        reply(apdu, 9, 9, 9, 9);
                    }
                    else
                    {
                        if (ret != 0)
                        {
                            apdu.setOutgoingAndSend(0, ret);
                            
                                //reply(apdu, 2, 2, 2, 2);
                                //var b = apdu.getBuffer();
                                //b = ret;
                                //apdu.setOutgoingAndSend(0, (short)ret.Length);
                            //}
                        }
                        else
                        {
                            reply(apdu, 8, 8, 8, 8);
                        }
                    }
                }
            }
            else
            {
                reply(apdu, 5, 5, 5, 5);
            }
        }