/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package serverapp;

import java.util.StringTokenizer;
import Hardware.windmill;

/**
 *
 * @author André
 */
public class DeviceLib {
    
    private windmill lib;

    public DeviceLib() {
        //AULA 3 - inicializar as lib
        lib = new windmill();
    }

    protected String callHardware(String content) {
        
        String reply = null;
        StringTokenizer st = new StringTokenizer(content, utilities.constants.token);
        String operation = st.nextToken();
        if (operation.equals("ChangeState")) {
            // AULA 3 - Chamar a DLL para mudar o estado
            int state = Integer.parseInt(st.nextToken());
            String error=lib.errorString();
            System.err.println(error);            //Deve desaparecer
        }
        //Aula 3 - Esta parte deve ser removida e a chamada à DLL deve ser feita aqui
        System.err.println("ERROR: Impossible to collect data");                //Deve desaparecer
        reply = "-1" + utilities.constants.token +                              //Deve desaparecer
                "-1" + utilities.constants.token +                              //Deve desaparecer
                "-1" + utilities.constants.token;                               //Deve desaparecer
        return reply;
    }
}

@@ -756,78 +756,142 @@
     
-String error=lib.errorString();%0A            System.err.println(error
+int rval = lib.turn_on(state);%0A            if(rval==0)%7B%0A                System.err.println(%22System was already in pretended state!%22
 );
+%0A
     
@@ -898,34 +898,17 @@
         
-//Deve desaparecer
+%7D
 %0A       
@@ -996,32 +996,34 @@
 ta aqui%0A        
+//
 System.err.print
@@ -1062,24 +1062,25 @@
  data%22);
+%0A
         
         
@@ -1075,34 +1075,116 @@
     
-        //Deve desaparecer
+int isOn=lib.is_on();%0A        float power = lib.energy_production();%0A        String err = lib.errorString();
 %0A   
@@ -1196,20 +1196,20 @@
 reply = 
-%22-1%22
+isOn
  + utili
@@ -1287,36 +1287,37 @@
                 
-%22-1%22
+power
  + utilities.con
@@ -1399,12 +1399,11 @@
     
-%22-1%22
+err
  + u

Update ServerApp :+1: :rocket: ->18