Example #1
0
        // Handle the Own Boat message
        public void HandleOwnBoatMessage(OwnBoatOriginalMessage message)
        {
            OwnBoatData ownBoat = new OwnBoatData();

            // convert
            ownBoat.timeStamp = convertTime(message.systemTime.time.value);
            ownBoat.timeZone  = message.timeZone.data.value;
            ownBoat.heading   = message.heading.data.value;
            ownBoat.pitch     = message.pitch.data.value;
            ownBoat.roll      = message.roll.data.value;
            ownBoat.heave     = message.heave.data.value;


            sender.SendOwnBoatData(ownBoat);

            //save to db
            db.saveRecord(ownBoat, "OwnBoat");
        }
Example #2
0
        private void InitFromUAGOwnBoatReceiver()
        {
            Channel = Connection.CreateModel();
            Channel.ExchangeDeclare(exchange: "OwnBoatData", type: ExchangeType.Fanout);
            Channel.QueueDeclare("UAGOwnBoatQueue");
            Channel.QueueBind(queue: "UAGOwnBoatQueue",
                              exchange: "OwnBoatData",
                              routingKey: "");
            OwnBoatConsumer           = new EventingBasicConsumer(Channel);
            OwnBoatConsumer.Received += (model, ea) =>
            {
                var body    = ea.Body;
                var message = Encoding.UTF8.GetString(body);

                OwnBoatOriginalMessage ownMessage = JsonConvert.DeserializeObject <OwnBoatOriginalMessage>(message);

                DataHandler.ReceiveOwnBoatData(ownMessage);
            };


            Channel.BasicConsume(queue: "UAGOwnBoatQueue",
                                 autoAck: true,
                                 consumer: OwnBoatConsumer);
        }
Example #3
0
 // Recieves a string in a Json format.
 // Handle the Received OwnBoat message
 public void ReceiveOwnBoatData(OwnBoatOriginalMessage receivedMessage)
 {
     HandleOwnBoatMessage(receivedMessage);
 }