Beispiel #1
0
 /// <summary>
 /// Hardwarenode sends the package to specified destination.
 /// </summary>
 /// <param name="Destination">The destination.</param>
 /// <param name="Tags">Optional tags.</param>
 /// <param name="ValInfo"></param>
 /// <returns>
 /// The Hardwarenode which received the package or null if an error occured
 /// </returns>
 public override List <Hardwarenode> Send(Hardwarenode Destination, Dictionary <string, object> Tags, ValidationInfo ValInfo)
 {
     ValInfo.NextNodes = new List <Hardwarenode>();
     ValInfo.Iface     = null;
     for (int i = Layerstack.GetSize() - 1; i >= 0; i--)
     {
         int customLayerCount = 0;
         //Calculate the custom layer count before this layer
         for (int j = 0; j < i; j++)
         {
             if (Layerstack.GetLayer(j) is CustomLayer)
             {
                 customLayerCount++;
             }
         }
         if (ValInfo.NextNodes == null)
         {
             continue;
         }
         Workstation dest = Destination as Workstation;
         if (dest != null)
         {
             Layerstack.GetLayer(i).ValidateSend(dest, this, ValInfo, Tags, i - customLayerCount);
         }
         else
         {
             throw new ArgumentException("Destination is no Workstation.");
         }
     }
     return(ValInfo.NextNodes);
 }
Beispiel #2
0
        /// <summary>
        /// Hardwarenode receives the package.
        /// </summary>
        /// <param name="Tags">Optional tags.</param>
        /// <param name="ValInfo">The validation Info</param>
        /// <param name="Destination">The destination</param>
        /// <returns>
        /// bool that indicates if the Hardwarenode received the package
        /// </returns>
        public override bool Receive(Dictionary <string, object> Tags, ValidationInfo ValInfo, Hardwarenode Destination)
        {
            bool res = true;
            int  customLayerCount = 0;

            for (int i = 0; i < Layerstack.GetSize(); i++)
            {
                if (!res)
                {
                    continue;
                }
                res = Layerstack.GetLayer(i).ValidateReceive(this, ValInfo, Tags, Destination, i - customLayerCount);
                if (Layerstack.GetLayer(i) is CustomLayer)
                {
                    customLayerCount++;
                }
            }
            return(res);
        }