<commit_before>/*
 * Copyright 2014-2015 CyberVision, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kaaproject.kaa.demo.iotworld.climate.deivce;

import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.kaaproject.kaa.client.KaaClient;
import org.kaaproject.kaa.client.event.FindEventListenersCallback;
import org.kaaproject.kaa.demo.iotworld.DeviceEventClassFamily;
import org.kaaproject.kaa.demo.iotworld.GeoFencingEventClassFamily;
import org.kaaproject.kaa.demo.iotworld.ThermoEventClassFamily;
import org.kaaproject.kaa.demo.iotworld.climate.data.event.FunControlUpdatedEvent;
import org.kaaproject.kaa.demo.iotworld.climate.data.event.ThermostatUpdatedEvent;
import org.kaaproject.kaa.demo.iotworld.climate.data.event.UserAttachEvent;
import org.kaaproject.kaa.demo.iotworld.climate.data.event.UserDetachEvent;
import org.kaaproject.kaa.demo.iotworld.device.DeviceChangeNameRequest;
import org.kaaproject.kaa.demo.iotworld.device.DeviceInfo;
import org.kaaproject.kaa.demo.iotworld.device.DeviceInfoRequest;
import org.kaaproject.kaa.demo.iotworld.device.DeviceInfoResponse;
import org.kaaproject.kaa.demo.iotworld.device.DeviceStatusSubscriptionRequest;
import org.kaaproject.kaa.demo.iotworld.fan.FanStatus;
import org.kaaproject.kaa.demo.iotworld.geo.GeoFencingPosition;
import org.kaaproject.kaa.demo.iotworld.geo.GeoFencingPositionUpdate;
import org.kaaproject.kaa.demo.iotworld.geo.GeoFencingStatusRequest;
import org.kaaproject.kaa.demo.iotworld.geo.GeoFencingStatusResponse;
import org.kaaproject.kaa.demo.iotworld.geo.OperationMode;
import org.kaaproject.kaa.demo.iotworld.geo.OperationModeUpdateRequest;
import org.kaaproject.kaa.demo.iotworld.thermo.ChangeDegreeRequest;
import org.kaaproject.kaa.demo.iotworld.thermo.ThermostatInfo;
import org.kaaproject.kaa.demo.iotworld.thermo.ThermostatStatusUpdate;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import de.greenrobot.event.EventBus;


public class ThermostatDevice implements DeviceEventClassFamily.Listener,
                                         GeoFencingEventClassFamily.Listener,
                                         ThermoEventClassFamily.Listener {
    
    private static final String TAG = ThermostatDevice.class.getSimpleName();
    
    private static final String DEVICE_NAME_PROP = "deviceName";
    private static final String OPERATION_MODE_PROP = "operationMode";
    private static final String DEGREE_PROP = "degree";
    private static final String TARGET_DEGREE_PROP = "targetDegree";
    
    private static final String DEFAULT_DEVICE_NAME = "Climate control";
    private static final OperationMode DEFAULT_OPERATION_MODE = OperationMode.GEOFENCING;
    
    private static final long DEGREE_CHANGE_SPEED_MS = 5000;
    private static final int MAX_DEGREE_DEVIATION = 2;
    private static final int DEFAULT_DEGREE = 80;
    private static final int DEFAULT_TARGET_DEGREE = 70;

    private final SharedPreferences mPreferences;
    private final KaaClient mClient;
    private final EventBus mEventBus;
    private final DeviceEventClassFamily mDeviceEventClassFamily;
    private final GeoFencingEventClassFamily mGeoFencingEventClassFamily;
    private final ThermoEventClassFamily mThermoEventClassFamily;

    private final Set<String> mSubscribedEndpoints = new HashSet<>();
    
    private DeviceInfo mDeviceInfo;
    private OperationMode mOperationMode;
    private GeoFencingPosition mPosition = GeoFencingPosition.AWAY;
    private ThermostatInfo mThermostatInfo;
    
    private ThermostatUpdatedEvent mThermostatUpdatedEvent = new ThermostatUpdatedEvent();<commit_msg>KAA-463: Change default thermostat degree to 100 F<commit_after>/*
 * Copyright 2014-2015 CyberVision, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.kaaproject.kaa.demo.iotworld.climate.deivce;

import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.kaaproject.kaa.client.KaaClient;
import org.kaaproject.kaa.client.event.FindEventListenersCallback;
import org.kaaproject.kaa.demo.iotworld.DeviceEventClassFamily;
import org.kaaproject.kaa.demo.iotworld.GeoFencingEventClassFamily;
import org.kaaproject.kaa.demo.iotworld.ThermoEventClassFamily;
import org.kaaproject.kaa.demo.iotworld.climate.data.event.FunControlUpdatedEvent;
import org.kaaproject.kaa.demo.iotworld.climate.data.event.ThermostatUpdatedEvent;
import org.kaaproject.kaa.demo.iotworld.climate.data.event.UserAttachEvent;
import org.kaaproject.kaa.demo.iotworld.climate.data.event.UserDetachEvent;
import org.kaaproject.kaa.demo.iotworld.device.DeviceChangeNameRequest;
import org.kaaproject.kaa.demo.iotworld.device.DeviceInfo;
import org.kaaproject.kaa.demo.iotworld.device.DeviceInfoRequest;
import org.kaaproject.kaa.demo.iotworld.device.DeviceInfoResponse;
import org.kaaproject.kaa.demo.iotworld.device.DeviceStatusSubscriptionRequest;
import org.kaaproject.kaa.demo.iotworld.fan.FanStatus;
import org.kaaproject.kaa.demo.iotworld.geo.GeoFencingPosition;
import org.kaaproject.kaa.demo.iotworld.geo.GeoFencingPositionUpdate;
import org.kaaproject.kaa.demo.iotworld.geo.GeoFencingStatusRequest;
import org.kaaproject.kaa.demo.iotworld.geo.GeoFencingStatusResponse;
import org.kaaproject.kaa.demo.iotworld.geo.OperationMode;
import org.kaaproject.kaa.demo.iotworld.geo.OperationModeUpdateRequest;
import org.kaaproject.kaa.demo.iotworld.thermo.ChangeDegreeRequest;
import org.kaaproject.kaa.demo.iotworld.thermo.ThermostatInfo;
import org.kaaproject.kaa.demo.iotworld.thermo.ThermostatStatusUpdate;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import de.greenrobot.event.EventBus;


public class ThermostatDevice implements DeviceEventClassFamily.Listener,
                                         GeoFencingEventClassFamily.Listener,
                                         ThermoEventClassFamily.Listener {
    
    private static final String TAG = ThermostatDevice.class.getSimpleName();
    
    private static final String DEVICE_NAME_PROP = "deviceName";
    private static final String OPERATION_MODE_PROP = "operationMode";
    private static final String DEGREE_PROP = "degree";
    private static final String TARGET_DEGREE_PROP = "targetDegree";
    
    private static final String DEFAULT_DEVICE_NAME = "Climate control";
    private static final OperationMode DEFAULT_OPERATION_MODE = OperationMode.GEOFENCING;
    
    private static final long DEGREE_CHANGE_SPEED_MS = 5000;
    private static final int MAX_DEGREE_DEVIATION = 2;
    private static final int DEFAULT_DEGREE = 100;
    private static final int DEFAULT_TARGET_DEGREE = 70;

    private final SharedPreferences mPreferences;
    private final KaaClient mClient;
    private final EventBus mEventBus;
    private final DeviceEventClassFamily mDeviceEventClassFamily;
    private final GeoFencingEventClassFamily mGeoFencingEventClassFamily;
    private final ThermoEventClassFamily mThermoEventClassFamily;

    private final Set<String> mSubscribedEndpoints = new HashSet<>();
    
    private DeviceInfo mDeviceInfo;
    private OperationMode mOperationMode;
    private GeoFencingPosition mPosition = GeoFencingPosition.AWAY;
    private ThermostatInfo mThermostatInfo;
    
    private ThermostatUpdatedEvent mThermostatUpdatedEvent = new ThermostatUpdatedEvent();
{'fraction_non_alphanumeric': 0.07532826537664132, 'fraction_numerical': 0.005643860861552638, 'mean_word_length': 4.8788083953960735, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6039532', 'n_tokens_mistral': 2662, 'n_tokens_neox': 2570, 'n_words': 560}