-- Real-Time System Model

Model (
   Model_Name  => Linear_Transactions_Only,
   Model_Date  => 2000-01-01);

-- Resources

Processing_Resource (
        Type                    => Fixed_Priority_Processor,
	Name 	                => CPU_1,
        Max_Priority            => 511,
        Min_Priority            => 1,
        Max_Interrupt_Priority  => 512,
        Min_Interrupt_Priority  => 512,
	Worst_Context_Switch 	=> 150,
	Avg_Context_Switch 	=> 100,
	Best_Context_Switch 	=>  50,
        System_Timer            =>  
	    (Type               => Ticker,
             Worst_Overhead 	=> 200,
	     Period 	        => 2000));

Processing_Resource (
        Type                    => Fixed_Priority_Processor,
	Name 	                => CPU_2,
        Max_Priority            => 511,
        Min_Priority            => 1,
        Max_Interrupt_Priority  => 512,
        Min_Interrupt_Priority  => 512,
	Worst_Context_Switch 	=> 150,
	Avg_Context_Switch 	=> 100,
	Best_Context_Switch 	=>  50,
        System_Timer            =>  
	    (Type               => Ticker,
             Worst_Overhead 	=> 200,
	     Period 	        => 2000));

Processing_Resource (
	Type 	=> Fixed_Priority_Network,
	Name 	=> RED_1,
        Max_Priority            => 512,
        Min_Priority            => 1,
	Packet_Worst_Overhead 	=> 20,
	Packet_Avg_Overhead 	=> 15,
	Packet_Best_Overhead 	=> 10,
	Max_Packet_Transmission_Time 	=> 200,
	Min_Packet_Transmission_Time 	=> 200);

-- Operations

Operation (
	Type	=> Simple,
	Name	=> Proc_11,
	Worst_Case_Execution_Time	=> 250,
	Avg_Case_Execution_Time 	=> 100,
	Best_Case_Execution_Time	=> 10);

Operation (
	Type	=> Simple,
	Name	=> Comunic_11,
	Worst_Case_Execution_Time	=> 700,
	Avg_Case_Execution_Time 	=> 170,
	Best_Case_Execution_Time	=> 10);

Operation (
	Type 	=> Simple,
	Name 	=> Proc_12,
	Worst_Case_Execution_Time 	=> 500,
	Avg_Case_Execution_Time 	=> 300,
	Best_Case_Execution_Time 	=> 0); 


Operation (
	Type	=> Simple,
	Name	=> Proc_21,
	Worst_Case_Execution_Time	=> 250,
	Avg_Case_Execution_Time 	=> 100,
	Best_Case_Execution_Time	=> 10);

Operation (
	Type	=> Simple,
	Name	=> Comunic_21,
	Worst_Case_Execution_Time	=> 750,
	Avg_Case_Execution_Time 	=> 150,
	Best_Case_Execution_Time	=> 10);

Operation (
	Type 	=> Simple,
	Name 	=> Proc_22,
	Worst_Case_Execution_Time 	=> 500,
	Avg_Case_Execution_Time 	=> 300,
	Best_Case_Execution_Time 	=> 100); 

Operation (
	Type	=> Simple,
	Name	=> Comunic_22,
	Worst_Case_Execution_Time	=> 250,
	Avg_Case_Execution_Time 	=> 100,
	Best_Case_Execution_Time	=> 10);

Operation (
	Type 	=> Simple,
	Name 	=> Proc_23,
	Worst_Case_Execution_Time 	=> 50,
	Avg_Case_Execution_Time 	=> 10,
	Best_Case_Execution_Time 	=> 5); 

-- Scheduling Servers

Scheduling_Server (
        Type                       => Fixed_Priority,
	Name 	=> Tarea_11,
	Server_Sched_Parameters 	=> (
        	Type 	           => Fixed_Priority_policy,
        	The_Priority 	        => 6,
                Preassigned             => No),
	Server_Processing_Resource	=> CPU_1);

Scheduling_Server (
        Type                       => Fixed_Priority,
	Name 	=> Mensaje_11,
	Server_Sched_Parameters 	=> (
                Type               => Non_Preemptible_FP_policy,
	        The_Priority              => 5,
                Preassigned             => No),
	Server_Processing_Resource	=> RED_1);

Scheduling_Server (
        Type                       => Fixed_Priority,
	Name 	=> Tarea_12,
	Server_Sched_Parameters 	=> (
        	Type 	           => Fixed_Priority_policy,
        	The_Priority 	        => 4,
                Preassigned             => No),
	Server_Processing_Resource	=> CPU_2);


Scheduling_Server (
        Type                       => Fixed_Priority,
	Name 	=> Tarea_21,
	Server_Sched_Parameters 	=> (
        	Type 	           => Fixed_Priority_policy,
        	The_Priority 	        => 6,
                Preassigned             => No),
	Server_Processing_Resource	=> CPU_1);

Scheduling_Server (
        Type                       => Fixed_Priority,
	Name 	=> Mensaje_21,
	Server_Sched_Parameters 	=> (
                Type               => Non_Preemptible_FP_policy,
	        The_Priority            => 5,
                Preassigned             => No),
	Server_Processing_Resource	=> RED_1);

Scheduling_Server (
        Type                       => Fixed_Priority,
	Name 	=> Tarea_22,
	Server_Sched_Parameters 	=> (
        	Type 	           => Fixed_Priority_policy,
        	The_Priority 	        => 7,
                Preassigned             => No),
	Server_Processing_Resource	=> CPU_2);

Scheduling_Server (
        Type                       => Fixed_Priority,
	Name 	=> Mensaje_22,
	Server_Sched_Parameters 	=> (
                Type               => Non_Preemptible_FP_policy,
	        The_Priority       => 5,
                Preassigned             => No),
	Server_Processing_Resource	=> RED_1);

Scheduling_Server (
        Type                       => Fixed_Priority,
	Name 	=> Tarea_23,
	Server_Sched_Parameters 	=> (
        	Type 	           => Fixed_Priority_policy,
        	The_Priority 	        => 2,
                Preassigned             => No),
	Server_Processing_Resource	=> CPU_1);

-- Transactions


Transaction (
      Type  => Regular,
	Name 	=> Trans_1,
      External_Events => (
	          ( Type 	=> Periodic,
	            Name 	=> EP1,
	            Period 	=> 10000,
	            Max_Jitter	=> 50,
	            Phase 	=> 0)),
                    
	Internal_Events 	=> (
     	      (Type 	=> Regular,
	       Name 	=> e11),
     	      (Type 	=> Regular,
	       Name 	=> e12),
  	      (Type 	=> Regular,
  	       Name 	=> Salida1,
	       Timing_Requirements 	=> (
            	           Type 	=> Hard_Global_Deadline,
	                   Deadline 	=> 10000,
	                   Referenced_Event 	=> EP1))),

	Event_Handlers 	=> (
	      (Type 	      => Activity,
      	 Input_Event 	=> EP1,
	       Output_Event 	=> e11,
	       Activity_Operation 	=> Proc_11,
             Activity_Server => Tarea_11),
	      (Type 	=> Activity,
      	 Input_Event 	=> e11,
	       Output_Event	=> e12,
	       Activity_Operation 	=> Comunic_11,
             Activity_Server => Mensaje_11),
	      (Type 	=> Activity,
      	 Input_Event 	=> e12,
	       Output_Event 	=> Salida1,
	       Activity_Operation 	=> Proc_12,
             Activity_Server => Tarea_12)
	)
);

Transaction (
      Type   => Regular,
      Name   => Trans_2,

      External_Events => (
            (Type   => Periodic,
             Name   => EP2,
             Period   => 5000,
             Max_Jitter 	=> 0,
	       Phase 	=> 0)),

	Internal_Events 	=> (
     	      (Type 	=> Regular,
	       Name 	=> e21),
     	      (Type 	=> Regular,
	       Name 	=> e22),
     	      (Type 	=> Regular,
	       Name 	=> e23),
     	      (Type 	=> Regular,
	       Name 	=> e24),
  	      (Type 	=> Regular,
  	       Name 	=> Salida2,
	       Timing_Requirements 	=> (
            	           Type 	=> Hard_Global_Deadline,
	                   Deadline 	=> 40000,
	                   Referenced_Event 	=> EP2))),

	Event_Handlers 	=> (
	      (Type 	=> Activity,
      	 Input_Event 	=> EP2,
	       Output_Event	=> e21,
	       Activity_Operation 	=> Proc_21,
             Activity_Server => Tarea_21),
	      (Type 	=> Activity,
      	 Input_Event 	=> e21,
	       Output_Event 	=> e22,
	       Activity_Operation 	=> Comunic_21,
             Activity_Server => Mensaje_21),
	      (Type 	=> Activity,
      	 Input_Event 	=> e22,
	       Output_Event 	=> e23,
	       Activity_Operation 	=> Proc_22,
             Activity_Server => Tarea_22),
	      (Type 	=> Activity,
      	 Input_Event 	=> e23,
	       Output_Event 	=> e24,
	       Activity_Operation 	=> Comunic_22,
             Activity_Server => Mensaje_22),
	      (Type 	=> Activity,
      	 Input_Event 	=> e24,
	       Output_Event 	=> Salida2,
	       Activity_Operation 	=> Proc_22,
             Activity_Server => Tarea_22)
	)
);

