Package com.gmv.its.deepsy.hal.mcu
  | Classes | |
| interface | CanBusStatus | 
| Mcu Can Bus status.  More... | |
| interface | ConfigBatteryProtection | 
| interface | ConfigGUID | 
| interface | ConfigLeds | 
| Config LEDs.  More... | |
| interface | GpioActiveEvent | 
| enum | GpioInput | 
| Gpio Available in the system.  More... | |
| interface | LedsColor | 
| Leds color.  More... | |
| interface | Mcu | 
| Mcu.  More... | |
| interface | McuEvent | 
| Mcu event.  More... | |
| interface | McuFirmwareInfo | 
| Mcu Firmware Info.  More... | |
| class | McuLowLevelException | 
| Mcu low level exception.  More... | |
| interface | McuManager | 
| Mcu Manager.  More... | |
| class | McuNotAvailableException | 
| Mcu not available exception.  More... | |
| class | McuObserver | 
| Mcu observer.  More... | |
| interface | McuPowerEvent | 
| GpioActiveEvent Mcu GPI Event.  More... | |
| class | McuPowerInformation | 
| Mcu Power Information.  More... | |
Detailed Description
To work with Deepsy mcu service it is necessary to use DeepsyMcuManager located in com.gmv.its.deepsy.mcu for getting the initial McuManager object.
McuManager mcuManager = DeepsyMcuManager.getInstance();
 
 DeepsyMcuManager.getInstance has an optional parameter indicating the ip address of remote service. For instance: 
McuManager mcuManager = DeepsyMcuManager.getInstance("192.168.1.10");
 
 In order to finalize properly, it is recommended to call to mcuManager.close(); 
mcuManager.close();
Examples
 Subscribe to GPIO events
 
 
 Get CAN bus status
 
package com.gmv.its.dpyjavaexamples.mcu;
public class GetCanBusStatusApp {
    public static void main(String[] args) {
        try (DeepsyMcuManager mcuManager = DeepsyMcuManager.getInstance("192.168.0.215")){
            Mcu mcu = mcuManager.getMcu();
            CanBusStatus canBusStatus = mcu.getCanStatus();
            System.out.println("Can Bus status: " + canBusStatus.value());
    } catch (McuNotAvailableException e) {
        e.printStackTrace();
    } catch (McuLowLevelException e) {
        e.printStackTrace();
    }       
    }
}
 
 Get power information
 
package com.gmv.its.dpyjavaexamples.mcu;
import java.util.List;
class PowerMcuObserver extends McuObserver {
   @Override
   public void notifyPowerEvent(McuPowerEvent event) {
        System.out.println("Mcu power information event:");
        System.out.println("\tIgnition ON: " + event.getPowerInformation().getIgnition() );
        System.out.println("\tExtern Battery Voltage:" + event.getPowerInformation().getBatteryExternVoltage() );
        System.out.println("\tInner Battery Percentage: " + event.getPowerInformation().getBatteryInnerPercent() );
        System.out.println("\tBattery Type: " + event.getPowerInformation().getBatteryType());
        System.out.println("\tEntering in Battery Protection Mode: " + event.getPowerInformation().getBatteryProtectionMode() );
        System.out.println("\tMCU Temperature: " + event.getPowerInformation().getTemperature() );
        System.out.println("\tVoltage Fault/Overcurrent Fault: " + event.getPowerInformation().getPowerFaultStatus() + "\n");
    }
   @Override
   public void notifyGpioActive(GpioActiveEvent event) {
    System.out.println("Mcu GPIO event");
   }
}
public class GetMcuPowerInformation {
    public static void main(String[] args) {
        DeepsyMcuManager mcuManager = DeepsyMcuManager.getInstance("192.168.0.150");
        try  {
            Mcu mcu = mcuManager.getMcu();
            //First get current power information
            McuPowerInformation powerInfo = mcu.getPowerInformation();
            System.out.println("Mcu Power information status:");
            System.out.println("\tIgnition ON: " + powerInfo.getIgnition() );
            System.out.println("\tExtern Battery Voltage: " + powerInfo.getBatteryExternVoltage() );
            System.out.println("\tInner Battery Percentage: " + powerInfo.getBatteryInnerPercent() );
            System.out.println("\tBattery Type: " + powerInfo.getBatteryType());
            System.out.println("\tEntering in Battery Protection Mode: " + powerInfo.getBatteryProtectionMode() );
            System.out.println("\tMCU Temperature: " + powerInfo.getTemperature() );
            //Subscribe to power information periodic events
            mcu.subscribe(new PowerMcuObserver());
        } catch (McuNotAvailableException e) {
            e.printStackTrace();
        } catch (McuLowLevelException e) {
            e.printStackTrace();
        } catch (CannotSubscribeException e) {
            e.printStackTrace();
        }
        try {
            Thread.sleep(120000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        mcuManager.close();
    }
}
 
  Manage MCU GPIOs
 
package com.gmv.its.dpyjavaexamples.mcu;
import java.util.List;
class GpioInputObserver extends McuObserver {
    @Override
    public void notifyPowerEvent(McuPowerEvent event) {
        System.out.println("Mcu power information event");
    }
    @Override
    public void notifyGpioActive(GpioActiveEvent event) {
    }
}
public class ManageMcuGpios {
    public static void main(String[] args) {
        DeepsyMcuManager mcuManager = DeepsyMcuManager.getInstance("192.168.0.125");
        try {
            Mcu mcu = mcuManager.getMcu();
            // Get state of the GPOs
            Boolean gpio_one = mcu.getGpioValue(1);
            Boolean gpio_two = mcu.getGpioValue(2);
            Boolean gpio_three = mcu.getGpioValue(3);
            Boolean gpio_four = mcu.getGpioValue(4);
            // Set state of a specific GPO
            System.out.println("Setting GPIO 4 to 0");
            mcu.setGpioValue(4, false);
            gpio_four = mcu.getGpioValue(4);
            // Subscribe to state of the GPIs
            mcu.subscribe(new GpioInputObserver());
        } catch (McuNotAvailableException e) {
            e.printStackTrace();
        } catch (McuLowLevelException e) {
            e.printStackTrace();
        } catch (CannotSubscribeException e) {
            e.printStackTrace();
        }
        try {
            Thread.sleep(120000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        mcuManager.close();
    }
}
 
  Get Set IC2 Values
 
package com.gmv.its.dpyjavaexamples.mcu;
import java.util.Arrays;
import java.util.List;
public class GetSeti2cValues {
    public static void main(String[] args) {
        McuManager mcuManager = DeepsyMcuManager.getInstance("192.168.0.126");
        try {
            Mcu mcu = mcuManager.getMcu();
            Byte[] array = {3,4,3,4};
            List<Byte> values = Arrays.asList(array);
            Byte address = 0x10;
            System.out.print("Set I2C values {3,4,3,4} at address 0x10 \n");
            mcu.setI2CValues((byte) 0x1, (byte) 0x50, address , values);
            List<Byte> result =  mcu.getI2CValues((byte) 0x1, (byte) 0x50, address, (byte) 4);
            System.out.print("Get I2C Values result:  ");
            for(Byte b: result) {
                System.out.print(b +"  ");
            }
            System.out.print("\n");
        } catch (McuNotAvailableException e) {
            e.printStackTrace();
        } catch (McuLowLevelException e) {
            e.printStackTrace();
        }
        mcuManager.close();
    }
}
 
Get firmware information
package com.gmv.its.dpyjavaexamples.mcu;
import java.util.List;
public class GetFirmwareInfo {
    public static void main(String[] args) {
        DeepsyMcuManager mcuManager = DeepsyMcuManager.getInstance("192.168.0.122");
        try  {
            Mcu mcu = mcuManager.getMcu();
            //First get current power information
            McuFirmwareInfo firmwareInfoCurrent = mcu.getCurrentMcuFirmwareInfo();
            System.out.println("Mcu Current Firmware information:");
            System.out.println("\tFirmware: " + firmwareInfoCurrent.getFirmwareVersion() );
            McuFirmwareInfo firmwareInfoAlternative = mcu.getAlternativeMcuFirmwareInfo();
            System.out.println("Mcu Alternative Firmware information:");
            System.out.println("\tFirmware: " + firmwareInfoAlternative.getFirmwareVersion() );
        } catch (McuNotAvailableException e) {
            e.printStackTrace();
        } catch (McuLowLevelException e) {
            System.out.println(e.getMessage() );
        }
        try {
            Thread.sleep(120000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        mcuManager.close();
    }
}
 
  Get GUID information
package com.gmv.its.dpyjavaexamples.mcu;
import java.util.List;
public class GetGUIDInfo {
    public static void main(String[] args) {
        DeepsyMcuManager mcuManager = DeepsyMcuManager.getInstance("192.168.0.122");
        try  {
            Mcu mcu = mcuManager.getMcu();
            //First get current power information
            List<ConfigGUID> guidInfo = mcu.getConfigGUID();
            System.out.println("Mcu GUID information:");
            for(ConfigGUID guid: guidInfo){
                if(guid.getPartNumber().indexOf("EQ") !=-1 ) {
                    System.out.println("\tEQ Part number: " + guid.getPartNumber() );
                    System.out.println("\tEQ Serial Number: " + guid.getSerialNumber() );
                    System.out.println("\tEQ CIDL number: " + guid.getCidlNumber() );
                }else if (guid.getPartNumber().indexOf("CIDL") !=-1) {
                    System.out.println("\tCIDL Part number: " + guid.getPartNumber() );
                    System.out.println("\tCIDL Serial Number: " + guid.getSerialNumber() );
                    System.out.println("\tCIDL CIDL number: " + guid.getCidlNumber() );
                } else {
                    System.out.println("\tPart number: " + guid.getPartNumber() );
                    System.out.println("\tSerial Number: " + guid.getSerialNumber() );
                    System.out.println("\tCIDL number: " + guid.getCidlNumber() );
                }
                    System.out.println("----------------"  );
            }
        } catch (McuNotAvailableException e) {
            e.printStackTrace();
        } catch (McuLowLevelException e) {
            System.out.println(e.getMessage() );
        }
        try {
            Thread.sleep(120000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        mcuManager.close();
    }
}
 
  Get battery configuration
Battery information, when available for the device, can be obtained as shown in the following example.
package com.gmv.its.dpyjavaexamples.mcu;
import java.util.List;
public class GetSetBatteryConfig {
    public static void main(String[] args) {
        DeepsyMcuManager mcuManager = DeepsyMcuManager.getInstance("192.168.0.122");
        try  {
            Mcu mcu = mcuManager.getMcu();
            //First get current power information
            ConfigBatteryProtection batteryProtection = mcu.getBatteryProtectionConfig();
            System.out.println("\tIdle Voltage: " + batteryProtection.getIdleVoltage() );
            System.out.println("\tVoltage Percentage Threshold: " + batteryProtection.getVoltagePercentageThreshold() );
            System.out.println("\tHysteresis Percentage: " + batteryProtection.getHysteresisPercentage() );
            System.out.println("\tGrace Period Minutes: " + batteryProtection.getGracePeriodMinutes() );
            mcu.setBatteryProtectionConfig((float)12.3, (float)81.2, (float)2.3, 5);
            System.out.println("-------------------------------"  );
            ConfigBatteryProtection batteryProtectionAfter = mcu.getBatteryProtectionConfig();
            System.out.println("\tIdle Voltage: " + batteryProtectionAfter.getIdleVoltage() );
            System.out.println("\tVoltage Percentage Threshold: " + batteryProtectionAfter.getVoltagePercentageThreshold() );
            System.out.println("\tHysteresis Percentage: " + batteryProtectionAfter.getHysteresisPercentage() );
            System.out.println("\tGrace Period Minutes: " + batteryProtectionAfter.getGracePeriodMinutes() );
        } catch (McuNotAvailableException e) {
            e.printStackTrace();
        } catch (McuLowLevelException e) {
            System.out.println(e.getMessage() );
        }
        try {
            Thread.sleep(120000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        mcuManager.close();
    }
}
 
 
          
          
