package AvatarInstance {
    private import AvatarGeneral::*;
    private import AvatarBlockTypes::*;
    private import AvatarCommunication::*;
    private import AvatarTransitionServer::*;
	part '@model': '#AvatarModel' {
		localClock : Clock redefines Occurrence::localClock = '#discreteClock';

	    // DATATYPES $$$$$$$$$$$$$$$$$$$$$$$$

	    item def '@dt:Point' :> '#AvatarDataType' {
	        #field attribute 'x' : Integer default := 0;
	        #field attribute 'y' : Integer default := 0;
	    }

	    // COMMUNICATIONS $$$$$$$$$$$$$$$$$$$$$$$$

	    // Relation '@SYN0:B0-B1'=============
	    part '@SYN0:B0-B1': '#Sync_Rel' = new '#Sync_Rel'('@block1' = '@blk:B0', '@block2' = '@blk:B1', '@private'=true);

	    // Channel '@syn:B0.in0<B1.out1'-------------
	    part '@syn:B0.in0<B1.out1' : '#Sync' = new '#Sync'('@relation' = '@SYN0:B0-B1');
	    binding : '#InSignalBinding' bind '@blk:B0'.'@sig:in0' = '@syn:B0.in0<B1.out1';
	    binding : '#OutSignalBinding' bind '@blk:B1'.'@sig:out1' = '@syn:B0.in0<B1.out1';

	    // Message of signal '@blk:B0'.'@sig:in0'............
	    part def '@MSG:B0.in0' :> '#InMessage' {
	        part '@channel' redefines '@channel' = '@model'.'@syn:B0.in0<B1.out1';
	        #field attribute 'x' : Integer;
	        #field item 'p' : '@dt:Point';
	        #field attribute 'b' : Boolean;
	    }

	    // Message of signal '@blk:B1'.'@sig:out1'............
	    part def '@MSG:B1.out1' :> '#OutMessage', '@MSG:B0.in0' {
	        #field attribute 'x' redefines 'x';
	        #field item 'p' redefines 'p';
	        #field attribute 'b' redefines 'b';
	    }

	    // Channel '@syn:B0.out0>B1.in1'-------------
	    part '@syn:B0.out0>B1.in1' : '#Sync' = new '#Sync'('@relation' = '@SYN0:B0-B1');
	    binding : '#OutSignalBinding' bind '@blk:B0'.'@sig:out0' = '@syn:B0.out0>B1.in1';
	    binding : '#InSignalBinding' bind '@blk:B1'.'@sig:in1' = '@syn:B0.out0>B1.in1';

	    // Message of signal '@blk:B1'.'@sig:in1'............
	    part def '@MSG:B1.in1' :> '#InMessage' {
	        part '@channel' redefines '@channel' = '@model'.'@syn:B0.out0>B1.in1';
	        #field attribute 'x' : Integer;
	        #field item 'p' : '@dt:Point';
	        #field attribute 'b' : Boolean;
	    }

	    // Message of signal '@blk:B0'.'@sig:out0'............
	    part def '@MSG:B0.out0' :> '#OutMessage', '@MSG:B1.in1' {
	        #field attribute 'x' redefines 'x';
	        #field item 'p' redefines 'p';
	        #field attribute 'b' redefines 'b';
	    }

	    // BLOCKS $$$$$$$$$$$$$$$$$$$$$$$$


	    // Block '@blk:B1'=============
	    part '@blk:B1' : '#AvatarBlock' {

	        // Attributes ---------------------
	        #field attribute '$x' : Integer := 0;
	        #field attribute '$b' : Boolean := false;
	        #field item '$p' : '@dt:Point';

	        // Signals ---------------------
	        part '@sig:in1' : '#Channel';
	        part '@sig:out1' : '#Channel';

	        // state-machine -------------------
	        exhibit state '@statemachine' : '#AvatarStateMachine' {

	            state '@st:send.out1.0' : '#AvatarSendState';

	            transition : '#AvatarTransition' first '@st:send.out1.0'
	                then '@st:stop';

	            state '@st:receive.in1.0' : '#AvatarReceiveState' {
	                in calc '@request' redefines '@request' = {
	                    new '#SendRequest'(
	                        '@channel' = '@sig:out1',
	                        '@payload' = new '@MSG:B1.out1'(
	                            '$x',
	                            '$p',
	                            '$b' )
	                    )
	                };
	            }

	            transition : '#AvatarTransition' first '@st:receive.in1.0'
	                then '@st:send.out1.0';

	            exit action '@st:stop' :'#AvatarStopState';

	            entry action '@st:start' :'#AvatarStartState' {
	                in calc '@request' redefines '@request' = {
	                    new '#ReceiveRequest'(
	                        '@channel' = '@sig:in1'
	                    )
	                };
	            }

	            transition : '#AvatarTransition' first '@st:start'
	                do action : '#ReceiveAction' {
	                    item '@msg' : '@MSG:B1.in1' = '@payload' as '@MSG:B1.in1';
	                    first start;
	                    then assign '$x' := '@msg'.'x';
	                    then assign '$p' := '@msg'.'p';
	                    then assign '$b' := '@msg'.'b';
	                    then done;
	                } then '@st:receive.in1.0';
	        }
	    }
	    // Block Shortcut Links $$$$$$$$$$$$
	}
}
