package com.example.lfrmobileapp;

import android.accounts.NetworkErrorException;
import android.util.Log;

import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Objects;

public class Communication {
    public String telegram(int[] wheels, int strenght){
        String tel = "";
        tel += "0"; //Manuel mode

        for(int i = 0; i < wheels.length; i++){
            if(wheels[i] == 1){
                tel += ";" + Float.toString(((float)strenght)/100)  ;
            }else if(wheels[i] == -1)
                tel += ";" + Float.toString(((float)-strenght)/100);
            else{
                tel += ";0.00";
            }
        }
        return tel;
    }

    public String telegram(boolean startStop, ArrayList<String> list){
        String tel = "";
        tel += "1"; //Autonomous mode
        if(startStop){
            tel += ";1";
        }else{
            tel += ";0";
        }

        for (String i : list) {
            if(i.equals("Links")){
                tel += ";0";
            }else if (i.equals("Rechts")){
                tel += ";1";
            }
        }
        return tel;
    }

}