Example #1
0
 public void Disconnect()
 {
     FromAToB.Stop();
     FromBToA.Stop();
     ChannelB.ImmitateDisconnect();
     CahnnelA.ImmitateDisconnect();
     IsConnected = false;
 }
Example #2
0
 public void Connect()
 {
     CahnnelA.ImmitateConnect();
     ChannelB.ImmitateConnect();
     FromAToB.Start();
     FromBToA.Start();
     IsConnected = true;
 }
Example #3
0
        public override void CalculateValues(ChannelCompartment compartment)
        {
            double[] arrayVals = new double[ChannelA.GetValues(compartment).Count];
            if (channelType == ChannelType.DURATION_VALUE)
            {
                durations[(int)compartment] = ChannelA.GetDurations(compartment);
            }
            List <double> A = ChannelA.GetValues(compartment);
            List <double> B = ChannelB.GetValues(compartment);

            timeStamps[(int)compartment] = ChannelA.GetTimeStamps(compartment);

            switch (Operation)
            {
            case OperationType.Sum:
                for (int i = 0; i < A.Count; i++)
                {
                    arrayVals[i] = A[i] + B[i];
                }
                break;

            case OperationType.Difference:
                for (int i = 0; i < A.Count; i++)
                {
                    arrayVals[i] = A[i] - B[i];
                }
                break;

            case OperationType.Product:
                for (int i = 0; i < A.Count; i++)
                {
                    arrayVals[i] = A[i] * B[i];
                }
                break;

            case OperationType.Ratio:
                for (int i = 0; i < A.Count; i++)
                {
                    if (B[i] == 0)
                    {
                        arrayVals[i] = 0;
                    }
                    else
                    {
                        arrayVals[i] = A[i] / B[i];
                    }
                }
                break;
            }
            values[(int)compartment] = arrayVals.ToList();
        }
 /// <summary>
 /// Sets this StatusObject from another StatusObject
 /// </summary>
 /// <param name="status">StatusObject to copy</param>
 public void SetFrom(StatusObject status)
 {
     ChannelA.SetFrom(status.ChannelA);
     ChannelB.SetFrom(status.ChannelB);
     Common.SetFrom(status.Common);
 }
 /// <summary>
 /// Checks for equality against another StatusObject
 /// </summary>
 /// <param name="status">StatusObject to compare against</param>
 /// <returns>True if equal</returns>
 public bool Equals(StatusObject status)
 {
     return(ChannelA.Equals(status.ChannelA) &&
            ChannelB.Equals(status.ChannelB) &&
            Common.Equals(status.Common));
 }