示例#1
0
        /// <summary>
        /// Assebles subCPN which mirrors _in place in _out place.
        /// That means when token comes into _in place it is copied into _out place. When token is removed from _in place
        /// it will NOT be removed from _out place
        /// </summary>
        /// <param name="_in"></param>
        /// <param name="_out"></param>
        public static void duplicateOnlyNewTokens(Place _in, Place _out)
        {
            //Define where side reaction will be applied
            SideReactionProvider srp = new SideReactionProvider(_out);

            _in.addPutReaction(new Place.Reaction(srp.addToSideEffectPlace));
        }
示例#2
0
        /// <summary>
        /// This method bonds _in and _out place in such way that any token that has been put into _in place
        /// is copied to _out place. Any token removed from _in place will be removed from _out place in case there is one.
        /// This method uses ILLEGAL according to the religion of CPN side effects for removeToken reaction for _in place. Be careful with self-dloop structures.
        /// Also be careful with remaining tokens. BE CAREFUL: It copies all contents of the _in place into _out place upon each
        /// arrival of new token into _in place.
        /// </summary>
        /// <param name="_in">mirror source</param>
        /// <param name="_out">mirror destination</param>
        public static void duplicatePlaceWithRemoval(Place _in, Place _out)
        {
            //define token removing side effects
            SideReactionProvider srp = new SideReactionProvider(_out);

            //Mark all tokens in
            _in.addPutReaction(new Place.Reaction(srp.addIdFieldToToken));
            //Remove tokens with the same mark
            _in.addRemoveReaction(new Place.Reaction(srp.removeFromSideEffectPlace));
            duplicateOnlyNewTokens(_in, _out);
        }