Advertisement
Guest User

Untitled

a guest
May 30th, 2019
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 3.43 KB | None | 0 0
  1. with Ada.Real_Time; use Ada.Real_Time;
  2. with System; use System;
  3. with baseDatos; use baseDatos;
  4. with Control; use Control;
  5. with Datos; use Datos;
  6. with Ada.Float_Text_IO; use Ada.Float_Text_IO;
  7. with Ada.Text_IO; use Ada.Text_IO;
  8. with STR_Tasking; use STR_Tasking;
  9.  
  10. procedure instalacionPrioridad is
  11.  
  12.    T : Time; -- Controlar el tiempo
  13.    ST1: Temperatura := 60.00;
  14.    ST2: Temperatura := 85.00;
  15.    SC1: Caudal := 0.00;
  16.    SC2: Caudal := 0.00;
  17.    SD1: Caudal := 25.00;
  18.    A : System.Priority := 3;
  19.    B : System.Priority := 2;
  20.    C : System.Priority := 1;
  21.    
  22.    -- Definimos la tarea de la pantalla
  23.    task Pantalla is
  24.       entry Mostrar(C:Caudal);
  25.       entry Mostrar(T:Temperatura);
  26.       entry Mostrar(R:Radiacion);
  27.    end Pantalla;
  28.    task body Pantalla is
  29.    begin
  30.       loop
  31.          select
  32.             accept Mostrar(C:Caudal) do
  33.                Put_Line("El valor del caudal es: "&Float(C)'Img);
  34.             end Mostrar;
  35.          or
  36.             accept Mostrar(T:Temperatura) do
  37.                Put_Line("El valor de la temperatura es: "&Float(T)'Img);
  38.             end Mostrar;
  39.          or
  40.             accept Mostrar(R:Radiacion) do
  41.                Put_Line("El valor de la radiacion es: "&Integer(R)'Img);
  42.             end Mostrar;
  43.          end select;
  44.       end loop;
  45.      
  46.  
  47.    end Pantalla;
  48.    
  49.    -- Definimos la tarea del sistema de seguridad
  50.    task seguridad is
  51.       pragma Priority(A);
  52.    end seguridad;
  53.    
  54.    
  55.    task body seguridad is
  56.       SC1, SC2 : Caudal;
  57.       ST2 : Temperatura;
  58.       Periodo : Time_Span := Milliseconds(50); -- Definimos el periodo
  59.      
  60.    begin
  61.       T := Clock;
  62.       loop
  63.          T := T + Periodo;
  64.          Delay until (T);
  65.          -- Tiempo_Computo(tmin => 0, tmax => 20, id=>1);
  66.          baseDatos.recursoCompartido.LecturaT(ST2);
  67.          SistemaSeguridad(ST2, SC1, SC2);
  68.          if (SC1 = 0.00) then
  69.             baseDatos.recursoCompartido.EscrituraC(SC1);
  70.             Pantalla.Mostrar(SC1);
  71.          elsif (SC2 = 0.00) then
  72.             baseDatos.recursoCompartido.EscrituraC(SC2);
  73.             Pantalla.Mostrar(SC2);
  74.          end if;
  75.       end loop;
  76.    end seguridad;
  77.    
  78.  
  79.      -- Definimos la tarea del campo solar
  80.    task campoSolar is
  81.        pragma Priority(B);
  82.    end campoSolar;
  83.    
  84.    task body campoSolar is
  85.       ST2 : Temperatura;
  86.       SC1 : Caudal;
  87.       Periodo : Time_Span := Milliseconds(100);-- Definimos el periodo
  88.    begin
  89.       T := Clock;
  90.       loop
  91.          T := T + Periodo;
  92.          Delay until (T);
  93.          -- Tiempo_Computo(tmin => 0, tmax => 10, id=>2);
  94.          baseDatos.recursoCompartido.LecturaT(ST2);
  95.          ControlST2(ST2, SC1);
  96.          baseDatos.recursoCompartido.EscrituraC(SC1);
  97.          Pantalla.Mostrar(SC1);
  98.       end loop;
  99.    end campoSolar;
  100.    
  101.    -- Definimos la tarea del campo solar
  102.    task moduloMD is
  103.        pragma Priority(C);
  104.    end moduloMD;
  105.    
  106.    task body moduloMD is
  107.       SD1 : Radiacion;
  108.       SC2 : Caudal;
  109.       Periodo : Time_Span := Milliseconds(200);-- Definimos el periodo
  110.    begin
  111.       T := Clock;
  112.       loop
  113.          T := T + Periodo;
  114.          Delay until (T);
  115.          -- Tiempo_Computo(tmin => 0, tmax => 10, id=>3);
  116.          baseDatos.recursoCompartido.LecturaR(SD1);
  117.          ControlSD1(SD1, SC2);
  118.          baseDatos.recursoCompartido.EscrituraC(SC2);
  119.          Pantalla.Mostrar(SC2);
  120.       end loop;
  121.    end moduloMD;
  122.    
  123. begin
  124.    null;
  125. end instalacionPrioridad;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement