public void SendData(Data data) { foreach (Connector nextConnector in Branches) { if (nextConnector == null) { data.Stop(); return; } bool isReceiving = nextConnector.IsReceiving(); if (isReceiving == false) { continue; } nextConnector.ReceiveData(data); return; } }
//protected override void UpdateData(float timeElapsed) //{ // if (outputDelayRemaining > 0) // { // outputDelayRemaining -= timeElapsed; // } // if (inputDelayRemaining > 0) // { // inputDelayRemaining -= timeElapsed; // } // InsufficientData(); // if (outputDelayRemaining > 0) // { // return; // } // EmptySink(); // if (SinkBits == 0) // { // if (StoredBits == 0) // { // allData.Clear(); // return; // } // } // // Reset timer // outputDelayRemaining = OutputDelay; // // Buffer must be full // //if (StoredBits < MaxBits) // //{ // // return; // //} // if (StoredBits < OutputValue) // { // return; // } // Content data = allData.ElementAt(0); // float cruiseVelocity = data.CruiseVelocity; // float maxVelocity = data.MaxVelocity; // switch (OutputValue) // { // case 64: // data = new DataHex(Center, cruiseVelocity, maxVelocity); // break; // case 8: // data = new DataByte(Center, cruiseVelocity, maxVelocity); // break; // case 1: // default: // data = new DataBit(Center, cruiseVelocity, maxVelocity); // break; // } // StoredBits -= OutputValue; // TransferData(data); //} public override void ReceiveData(Data data) { data.Stop(); int bitsToAdd = data.Value; if (HasReachedCapacity == true) { SinkBits += bitsToAdd; return; } inputDelayRemaining = InputDelay; int totalBits = StoredBits + bitsToAdd; if (totalBits > MaxBits) { int excessBits = totalBits - MaxBits; SinkBits += excessBits; bitsToAdd = bitsToAdd - excessBits; if (bitsToAdd == 0) { return; } } StoredBits += bitsToAdd; if (StoredBits == MaxBits) { HasReachedCapacity = true; } IsFull = StoredBits == MaxBits; allData.Clear(); allData.AddLast(data); }