我无法发送请求

时间:2014-02-11 13:48:24

标签: java

我认为我的问题对你来说是笑声。

我有三个叫(CloudCommunicator,EnergyManagerJob和Main)的类

我的 CloudCommunicator 看起来像这样:

public class CloudCommunicator {

      private String _chargingStationId;
      public  void cloudCommunicator(String charginStationId)
      {
            _chargingStationId = charginStationId;
      }

      public  EnergyManagerJob SendRequest(boolean chargingOnGoing, boolean setCarConnectedToChargePoint, int setChargingStationDisfunction, float setMeterValue, String setUserId)
      {
           DChargingStationRequest dChargingStationRequest = new DChargingStationRequest();
           dChargingStationRequest.chargingOnGoing=chargingOnGoing;
     dChargingStationRequest.carConnectedToChargePoint=setCarConnectedToChargePoint;
     dChargingStationRequest.chargingStationDisfunction=setChargingStationDisfunction;
           dChargingStationRequest.chargingStationId = _chargingStationId; 
           dChargingStationRequest.meterValue=setMeterValue;
           dChargingStationRequest.userId=setUserId;

           try
           {        
                EVSEHeartbeatService_Service hbs = new EVSEHeartbeatService_Service();
                EVSEHeartbeatService h = hbs.getEVSEHeartbeatServiceSoap11();
                DChargingStationResponse response = h.chargingStation(dChargingStationRequest);

                EnergyManagerJob emj = new EnergyManagerJob();
                emj.allowedMaximumCurrent = response.allowedMaximumCurrent;
                emj.chargingPending = response.chargingPending;
                emj.powerOn = response.powerOn;
          }
          catch(Exception e)
          {
                System.out.println("Exception = " + e.getMessage());
          }

          return SendRequest(chargingOnGoing = true, setCarConnectedToChargePoint =false, setChargingStationDisfunction = 0, setMeterValue = 44, setUserId ="ich");
      }

和我的 EnergyManagerJob 看起来像这样:

public class EnergyManagerJob {


    public double allowedMaximumCurrent;

    public boolean chargingPending;

    public boolean powerOn;

}

所以我们会遇到问题。在我的主要我有一段时间。我想将de CloudCommunicator的日期发送到服务器。然后我得到了答案。

我的主要看起来像这样。

public class Main {

 public static void main(String[] args){

    while (true) 
    {

        CloudCommunicator ccc = new CloudCommunicator();
        ccc.SendRequest (chargingOnGoing, setCarConnectedToChargePoint, setChargingStationDisfunction , setMeterValue , setUserId);


        DChargingStationResponse response = new DChargingStationResponse();
        System.out.println("\nDie Lade Station Startet: "  + response.allowedMaximumCurrent);
        System.out.println("Die Lade Station wurde gestartet: " +response.isChargingPending());
        System.out.println("Die Lade Station wurde gestartet: " +response.isPowerOn());
        try {
            Thread.sleep(30000);
        } catch(InterruptedException ex) {
            Thread.currentThread().interrupt();
        }       
    }   
  } 
}

感谢您的帮助。我认为这不是一个大问题,但我有一个停电。 xD

1 个答案:

答案 0 :(得分:0)

您的代码无法编译。变量chargingOnGoingsetCarConnectedToChargePointsetChargingStationDisfunctionsetMeterValuesetUserId根本就没有定义。在main方法中。

定义它们(boolean charginOnGoing = true)或使用内联值(SendRequest)调用ccc.SendRequest( true, ... )