Exemplo n.º 1
0
 public Poisson(double tV, int nV, double l1, double l2)
 {
     t       = tV;
     N       = nV;
     ALambda = l1 + l2;
     AStream = new AggregatedStream(l1, l2);
 }
Exemplo n.º 2
0
        public Simulator(double time, int n, double lambda1, double lambda2)
        {
            Time    = time;
            N       = n;
            ALambda = lambda1 + lambda2;

            AStream = new AggregatedStream(lambda1, lambda2);
        }
Exemplo n.º 3
0
 public void SetData(AggregatedStream memoryStream)
 {
     if (_IsTimingOut)
     {
         StopTimeOut();
     }
     _WasUpdated   = true;
     _MemoryStream = memoryStream;
 }
Exemplo n.º 4
0
        public void Evaluate(int spreadMax)
        {
            FOutput.SliceCount = FInputs.SliceCount;
            var intersperseElement = FIntersperseSequence[0];

            for (int i = 0; i < FOutput.SliceCount; i++)
            {
                IEnumerable <Stream> streams = FInputs[i];
                if (intersperseElement.Length > 0)
                {
                    streams = streams.Intersperse(intersperseElement);
                }
                FOutput[i] = new AggregatedStream(streams);
            }
        }
Exemplo n.º 5
0
 public BufferContainer(string id, AggregatedStream memoryStream)
 {
     SetIdentifier(id);
     SetData(memoryStream);
 }
Exemplo n.º 6
0
        //called when data for any output pin is requested
        public void Evaluate(int spreadMax)
        {
            // reset update status - needed later to identify buffers that got no update and time out
            foreach (BufferContainer bc in Store.Values)
            {
                bc.ResetUpdateStatus();
            }

            if (FInput.SliceCount > 0)
            {
                int IdentifierSlice = 0;
                for (int i = 0; i < FBinSize.SliceCount; i++) // go through all bins (1 bin = 1 client)
                {
                    // Get the first slice of the frame. It holds the identifier string
                    string IdentifierString = "";
                    using (var reader = new StreamReader(FInput[IdentifierSlice], Encoding.Default))
                    {
                        IdentifierString = reader.ReadToEnd();
                    }

                    // The rest of the frame is the raw data we want to store in the buffer
                    List <Stream> streams = new List <Stream>();
                    for (int streamId = 1; streamId < FBinSize[i]; streamId++) // iterate from identifier slice to the end of this frame
                    {
                        streams.Add(FInput[IdentifierSlice + streamId]);
                    }
                    AggregatedStream data = new AggregatedStream(streams); // aggregate the data

                    // Store the data - this also updates the timeout flag
                    if (Store.ContainsKey(IdentifierString))
                    {
                        Store[IdentifierString].SetData(data);
                    }
                    else
                    {
                        Store.Add(IdentifierString, new BufferContainer(IdentifierString, data));
                    }

                    IdentifierSlice += FBinSize[i];
                }
            }

            // start timeout for all buffer entries that had no update
            foreach (BufferContainer bc in Store.Values)
            {
                if (bc.GetUpdateStatus() == false && !bc.IsTimingOut())
                {
                    bc.StartTimeOut(FTimeOut[0]);
                }
            }

            // remove all buffers where timeout elapsed
            var buffersToRemove = Store.Where(kvp => kvp.Value.IsReleased() == true).Select(kvp => kvp.Key).ToArray();

            foreach (string bufferKeys in buffersToRemove)
            {
                Store.Remove(bufferKeys);
            }

            // output stored buffers
            FOutput.SliceCount = FOutString.SliceCount = Store.Count;
            int slice = 0;

            foreach (BufferContainer bc in Store.Values)
            {
                FOutput[slice]    = bc.GetData();
                FOutString[slice] = bc.GetIdentifier();
                slice++;
            }
        }