Advertisement
Guest User

Untitled

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