Example #1
0
File: Cheese.cs Project: staxgr/ops
 public override void FillClone(OPSObject cloneO)
 {
     base.FillClone(cloneO);
     Cheese cloneResult = (Cheese)cloneO;
     cloneResult.name = this.name;
     cloneResult.age = this.age;
 }
Example #2
0
 public override void FillClone(OPSObject cloneO)
 {
     base.FillClone(cloneO);
     TestData cloneResult = (TestData)cloneO;
     cloneResult.text = this.text;
     cloneResult.value = this.value;
 }
Example #3
0
 public override void FillClone(OPSObject cloneO)
 {
     base.FillClone(cloneO);
     PizzaData cloneResult = (PizzaData)cloneO;
     cloneResult.cheese = this.cheese;
     cloneResult.tomatoSauce = this.tomatoSauce;
 }
Example #4
0
 /// 
 /// <param name="cloneResult"></param>
 /// Fills the parameter "cloneResult" with all values from this object.
 public virtual void FillClone(OPSObject cloneResult)
 {
     cloneResult.typesString = this.typesString;
     cloneResult.key = this.key;
     cloneResult.spareBytes = new byte[this.spareBytes.Length];
     this.spareBytes.CopyTo(cloneResult.spareBytes, 0);
 }
Example #5
0
 public override void FillClone(OPSObject cloneO)
 {
     base.FillClone(cloneO);
     BaseData cloneResult = (BaseData)cloneO;
     cloneResult.Id = this.Id;
     cloneResult.Name = this.Name;
 }
Example #6
0
 ///
 /// <param name="cloneResult"></param>
 /// Fills the parameter "cloneResult" with all values from this object.
 virtual public void FillClone(OPSObject cloneResult)
 {
     cloneResult.typesString = this.typesString;
     cloneResult.key         = this.key;
     cloneResult.spareBytes  = new byte[this.spareBytes.Length];
     this.spareBytes.CopyTo(cloneResult.spareBytes, 0);
 }
Example #7
0
        void NotifyNewOPSObject(OPSObject o)
        {
            if (ApplyFilterQoSPolicies(o))
            {
                long currentTime = System.DateTime.Now.Ticks;
                if (currentTime - timeLastDataForTimeBase > timeBaseMinSeparationTime || timeBaseMinSeparationTime == 0)
                {
                    lastDeadlineTime        = currentTime;
                    timeLastDataForTimeBase = currentTime;

                    sampleTime2 = sampleTime1;
                    sampleTime1 = currentTime;

                    data = o;

                    if (data != null)
                    {
                        NewDataArrived(data);
                    }

                    lock (newDataEvent)
                    {
                        Monitor.PulseAll(newDataEvent);
                    }
                }
            }
        }
Example #8
0
        /// Returns a new allocated deep copy/clone of this object.
        virtual public object Clone()
        {
            OPSObject cloneResult = new OPSObject();

            FillClone(cloneResult);
            return(cloneResult);
        }
Example #9
0
 public override void FillClone(OPSObject cloneO)
 {
     base.FillClone(cloneO);
     LHCData cloneResult = (LHCData)cloneO;
     cloneResult.bearnaise = this.bearnaise;
     cloneResult.beef = this.beef;
     cloneResult.p = new List<pizza.PizzaData>(this.p.Count);
     this.p.ForEach((item) => { cloneResult.p.Add((pizza.PizzaData)item.Clone()); });
 }
Example #10
0
        protected void Write(OPSObject opsObject)
        {
            if (opsObject == null)
            {
                throw new CommException("Trying to send OPSObject that is null!");
            }

            if (sendDataHandler == null)
            {
                Init();
            }

            if (sendDataHandler == null)
            {
                return;
            }

            this.sampleTime2 = this.sampleTime1;
            this.sampleTime1 = System.DateTime.Now.Ticks;

            OPSMessage message = new OPSMessage();

            opsObject.SetKey(this.key);
            message.SetData(opsObject);
            message.SetPublicationID(this.currentPublicationID);
            message.SetTopicName(this.topic.GetName());
            message.SetPublisherName(this.name);

            //inProcessTransport.copyAndPutMessage(message);
            WriteByteBuffer buf = new WriteByteBuffer(this.bytes, Globals.MAX_SEGMENT_SIZE);

            try
            {
                OPSArchiverOut archiverOut = new OPSArchiverOut(buf, topic.GetOptNonVirt());

                archiverOut.Inout("message", message);

                // If o has spare bytes, write them to the end of the buf
                if (opsObject.spareBytes.Length > 0)
                {
                    buf.Write(opsObject.spareBytes, 0, opsObject.spareBytes.Length);
                }
                // Finish will fill in nrOf segments in all segments.
                buf.Finish();
                int sizeToSend = buf.Position();

                sendDataHandler.SendData(this.bytes, sizeToSend, this.topic);
            }
            catch (System.IO.IOException ex)
            {
                Logger.ExceptionLogger.LogException(ex);
            }
            IncCurrentPublicationID();
        }
Example #11
0
 private bool ApplyFilterQoSPolicies(OPSObject o)
 {
     foreach (IFilterQoSPolicy filter in filterQoSPolicies)
     {
         if (!filter.ApplyFilter(o))
         {
             //Indicates that this data sample NOT should be delivered to the application.
             return(false);
         }
     }
     return(true);
 }
Example #12
0
 public bool ApplyFilter(OPSObject o)
 {
     lock (lockThis)
     {
         foreach (string key in keys)
         {
             if (o.GetKey().Equals(key))
             {
                 return(true);
             }
         }
         return(false);
     }
 }
Example #13
0
 public bool ApplyFilter(OPSObject o)
 {
     lock(lockThis)
     {
         foreach (string key in keys)
         {
             if (o.GetKey().Equals(key))
             {
                 return true;
             }
         }
         return false;
     }
 }
Example #14
0
        public void SubscriberNewData(Subscriber sender, OPSObject data)
        {
            if (!(data is ParticipantInfoData)) return;

            ParticipantInfoData partInfo = (ParticipantInfoData)data;

            // Is it on our domain?
            if (partInfo.domain.Equals(participant.domainID)) {

                foreach (TopicInfoData tid in partInfo.subscribeTopics)
                {
                    // We are only interrested in topics with UDP as transport
                    if ( (tid.transport.Equals(Topic.TRANSPORT_UDP)) && (participant.HasPublisherOn(tid.name)) )
                    {
                        udpSendDataHandler.AddSink(tid.name, partInfo.ip, partInfo.mc_udp_port);
                    }
                }
            }
        }
        public void SubscriberNewData(Subscriber sender, OPSObject data)
        {
            if (!(data is ParticipantInfoData))
            {
                return;
            }

            ParticipantInfoData partInfo = (ParticipantInfoData)data;

            // Is it on our domain?
            if (partInfo.domain.Equals(participant.domainID))
            {
                foreach (TopicInfoData tid in partInfo.subscribeTopics)
                {
                    // We are only interrested in topics with UDP as transport
                    if ((tid.transport.Equals(Topic.TRANSPORT_UDP)) && (participant.HasPublisherOn(tid.name)))
                    {
                        udpSendDataHandler.AddSink(tid.name, partInfo.ip, partInfo.mc_udp_port);
                    }
                }
            }
        }
Example #16
0
 public override void FillClone(OPSObject cloneO)
 {
     base.FillClone(cloneO);
     ExtraAllt cloneResult = (ExtraAllt)cloneO;
     cloneResult.extraCheese = this.extraCheese;
     cloneResult.nrOfMushRooms = this.nrOfMushRooms;
     cloneResult.meetQuality = this.meetQuality;
     cloneResult.timestamp = this.timestamp;
     cloneResult.timeBakedHours = this.timeBakedHours;
     cloneResult.timeBakedSeconds = this.timeBakedSeconds;
     cloneResult.description = this.description;
     cloneResult.cheese_ = (pizza.special.Cheese)this.cheese_.Clone();
     cloneResult.bools = new List<bool>(this.bools);
     cloneResult.bytes = new List<byte>(this.bytes);
     cloneResult.ints = new List<int>(this.ints);
     cloneResult.longs = new List<long>(this.longs);
     cloneResult.floats = new List<float>(this.floats);
     cloneResult.doubles = new List<double>(this.doubles);
     cloneResult.strings = new List<string>(this.strings);
     cloneResult.cheeses = new List<pizza.special.Cheese>(this.cheeses.Count);
     this.cheeses.ForEach((item) => { cloneResult.cheeses.Add((pizza.special.Cheese)item.Clone()); });
 }
Example #17
0
 public void WriteAsOPSObject(OPSObject opsObject)
 {
     Write(opsObject);
 }
Example #18
0
 // This is the default implementation for when new data has arrived.
 // The method can be overriden to implament a type safe callback event.
 protected virtual void NewDataArrived(OPSObject o)
 {
     // Use a delegate to send data to interested receivers.
     newDataDefault(this, o);
 }
Example #19
0
        void NotifyNewOPSObject(OPSObject o)
        {
            if (ApplyFilterQoSPolicies(o))
            {
                long currentTime = System.DateTime.Now.Ticks;
                if (currentTime - timeLastDataForTimeBase > timeBaseMinSeparationTime || timeBaseMinSeparationTime == 0)
                {
                    lastDeadlineTime = currentTime;
                    timeLastDataForTimeBase = currentTime;

                    sampleTime2 = sampleTime1;
                    sampleTime1 = currentTime;

                    data = o;

                    if (data != null)
                        NewDataArrived(data);

                    lock (newDataEvent)
                    {
                        Monitor.PulseAll(newDataEvent);
                    }
                }
            }
        }
Example #20
0
        private bool ApplyFilterQoSPolicies(OPSObject o)
        {
            foreach (IFilterQoSPolicy filter in filterQoSPolicies)
            {
                if (!filter.ApplyFilter(o))
                {
                    //Indicates that this data sample NOT should be delivered to the application.
                    return false;
                }

            }
            return true;
        }
Example #21
0
 // This is the default implementation for when new data has arrived.
 // The method can be overriden to implament a type safe callback event.
 protected virtual void NewDataArrived(OPSObject o)
 {
     // Use a delegate to send data to interested receivers.
     newDataDefault(this, o);
 }
 public bool ApplyFilter(OPSObject o)
 {
     newUpdate = true;
     return(true);
 }
Example #23
0
 public void WriteAsOPSObject(OPSObject opsObject)
 {
     Write(opsObject);
 }
Example #24
0
        protected void Write(OPSObject opsObject)
        {
            if (opsObject == null)
            {
                throw new CommException("Trying to send OPSObject that is null!");
            }

            if (sendDataHandler == null)
            {
                Init();
            }

            if (sendDataHandler == null)
            {
                return;
            }

            this.sampleTime2 = this.sampleTime1;
            this.sampleTime1 = System.DateTime.Now.Ticks;

            OPSMessage message = new OPSMessage();
            opsObject.SetKey(this.key);
            message.SetData(opsObject);
            message.SetPublicationID(this.currentPublicationID);
            message.SetTopicName(this.topic.GetName());
            message.SetPublisherName(this.name);

            //inProcessTransport.copyAndPutMessage(message);
            WriteByteBuffer buf = new WriteByteBuffer(this.bytes, Globals.MAX_SEGMENT_SIZE);
            try
            {
                OPSArchiverOut archiverOut = new OPSArchiverOut(buf);

                archiverOut.Inout("message", message);

                // If o has spare bytes, write them to the end of the buf
                if (opsObject.spareBytes.Length > 0)
                {
                    buf.Write(opsObject.spareBytes, 0, opsObject.spareBytes.Length);
                }
                // Finish will fill in nrOf segments in all segments.
                buf.Finish();
                int sizeToSend = buf.Position();

                sendDataHandler.SendData(this.bytes, sizeToSend, this.topic);
            }
            catch (System.IO.IOException ex)
            {
                Logger.ExceptionLogger.LogException(ex);
            }
            IncCurrentPublicationID();
        }
Example #25
0
 protected override void NewDataArrived(OPSObject o)
 {
     if (newData != null) newData(this, (TestData)o);
 }
Example #26
0
 public override void FillClone(OPSObject cloneO)
 {
     base.FillClone(cloneO);
     BaseData cloneResult = (BaseData)cloneO;
     cloneResult.baseText = this.baseText;
 }
 public bool ApplyFilter(OPSObject o)
 {
     newUpdate = true;
     return true;
 }
Example #28
0
 public override void FillClone(OPSObject cloneO)
 {
     base.FillClone(cloneO);
     CapricosaData cloneResult = (CapricosaData)cloneO;
     cloneResult.mushrooms = this.mushrooms;
 }
Example #29
0
 protected override void NewDataArrived(OPSObject o)
 {
     if (newData != null) newData(this, (ExtraAllt)o);
 }
Example #30
0
 /// Returns a new allocated deep copy/clone of this object.
 public virtual object Clone()
 {
     OPSObject cloneResult = new OPSObject();
     FillClone(cloneResult);
     return cloneResult;
 }