Пример #1
0
  public synchronized void updateSingleShedule(
      String command, String commandID, String commantModeText) {

    int cmdID = Integer.parseInt(commandID);
    if (!conainsCommandInDevice(command)) {
      return;
    }

    System.out.println(
        "found command in device for signle update   #ncommand:"
            + command
            + "#ncommandID="
            + commandID
            + " commantModeText:"
            + commantModeText);

    System.out.println("commandID= " + commandID);
    // int position = -1;
    Shedule shedule = null;
    for (int i = 0; i < sheduleList.size(); i++) {
      if (sheduleList.get(i).getId() == cmdID) {
        shedule = sheduleList.get(i);
        System.out.println("found update id");
        if (commantModeText.startsWith(IS_WEEKLY)) {
          System.out.println(
              commantModeText.substring(IS_WEEKLY.length(), commantModeText.length()));
          // boolean
          // isActive=Boolean.parseBoolean(commantModeText.substring(IS_WEEKLY.length(),commantModeText.length()));
          shedule.setIsWeekly(
              commantModeText.substring(IS_WEEKLY.length(), commantModeText.length()));
          updateShedule();
        } else if (commantModeText.startsWith(IS_ACTIVE)) {
          // boolean isActive=Boolean.parseBoolean(commantModeText.substring(IS_ACTIVE.length()));
          System.out.println(
              commantModeText.substring(IS_ACTIVE.length(), commantModeText.length()));
          shedule.setIsActive(
              commantModeText.substring(IS_ACTIVE.length(), commantModeText.length()));
          updateShedule();
        }
        //   position = i;

      }
    }

    //   if (position != -1) {
    //    sheduleList.remove(position);
    //   sheduleList.add(position,shedule);
    //  }

    if (shedule == null) {
      System.out.println("shedule did not found");
      return;
    }
    sh.sendToAll("updatedOk:DeviceID:" + SH.DeviceID + COMMAND_SPLIT_STRING + shedule.toString());
  }
Пример #2
0
  public synchronized String updateShedule(Shedule shedule) {

    int position = -1;
    for (int i = 0; i < sheduleList.size(); i++) {
      if (sheduleList.get(i).getId() == shedule.getId()) {
        position = i;
      }
    }

    if (position != -1) {
      sheduleList.remove(position);
      sheduleList.add(position, shedule);
    }

    updateShedule();
    return "UpdatedOk:DeviceID:" + SH.DeviceID + COMMAND_SPLIT_STRING + shedule.toString();
  }
Пример #3
0
  public synchronized void updateShedule(String command, String commandID) {

    String sendingToAllCommand = "";
    //  Shedule shedule = new Shedule();

    // System.out.println("command = "+command);
    if (!conainsCommandInDevice(getCommandText(command))) {
      return;
    }
    System.out.println(
        "found command in device for update   command:" + command + "#ncommandID=" + commandID);
    //   int position = -1;
    Shedule shedule = null;
    int cmdID = Integer.parseInt(commandID);
    for (int i = 0; i < sheduleList.size(); i++) {
      if (sheduleList.get(i).getId() == cmdID) {
        shedule = sheduleList.get(i);
        shedule.setId(cmdID); // /////// iDD
        shedule.setActiveDays(getDays(command));
        shedule.setTime(getTime(command));
        shedule.setIsWeekly(getIsWeekly(command));
        shedule.setIsActive(getIsActive(command));
        shedule.setCommandText(getCommandText(command));
        updateShedule();
        //   position = i;
      }
    }

    // if (position != -1) {
    //    sheduleList.remove(position);
    //     sheduleList.add(position,shedule);
    //  }

    if (shedule == null) {
      return;
    }
    sh.sendToAll("updatedOk:DeviceID:" + SH.DeviceID + COMMAND_SPLIT_STRING + shedule.toString());

    //   return"updatedOk:DeviceID:"+SH.DeviceID+COMMAND_SPLIT_STRING+shedule.toString();
  }
Пример #4
0
  public void removeShedule(String command, String textCommand) { // // px "updateShedule:ID:1"
    System.out.println("removeShedule::::" + command + "  " + textCommand);

    if (!conainsCommandInDevice(textCommand)) {
      return;
    }
    int remId = Integer.parseInt(command);
    String output = null;
    int position = -1;
    for (int i = 0; i < sheduleList.size(); i++) {
      if (sheduleList.get(i).getId() == remId) {
        position = i;
      }
    }

    if (position != -1) {
      sheduleList.remove(position);
      updateShedule();
    }
    output = "removeShedule:DeviceID:" + SH.DeviceID + COMMAND_SPLIT_STRING + COMMAND_ID + command;
    sh.sendToAll(output);
    //  return output;
  }