<commit_before>/*
   Copyright 2008-2010 CNR-ISTI, http://isti.cnr.it
   Institute of Information Science and Technologies 
   of the Italian National Research Council 


   See the NOTICE file distributed with this work for additional 
   information regarding copyright ownership

   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 it.cnr.isti.zigbee.ha;

import it.cnr.isti.zigbee.ha.cluster.factory.HAClustersFactory;
import it.cnr.isti.zigbee.ha.device.api.generic.LevelControlSwitch;
import it.cnr.isti.zigbee.ha.device.api.generic.OnOffOutput;
import it.cnr.isti.zigbee.ha.device.api.generic.OnOffSwitch;
import it.cnr.isti.zigbee.ha.device.api.hvac.TemperatureSensor;
import it.cnr.isti.zigbee.ha.device.api.lighting.DimmableLight;
import it.cnr.isti.zigbee.ha.device.api.lighting.OccupancySensor;
import it.cnr.isti.zigbee.ha.device.api.lighting.OnOffLightSwitch;
import it.cnr.isti.zigbee.ha.device.factory.OnOffLightFactory;
import it.cnr.isti.zigbee.ha.device.impl.DimmableLightDevice;
import it.cnr.isti.zigbee.ha.device.impl.LevelControlSwitchDevice;
import it.cnr.isti.zigbee.ha.device.impl.OccupancySensorDevice;
import it.cnr.isti.zigbee.ha.device.impl.OnOffLightSwitchDevice;
import it.cnr.isti.zigbee.ha.device.impl.OnOffOutputDevice;
import it.cnr.isti.zigbee.ha.device.impl.OnOffSwitchDevice;
import it.cnr.isti.zigbee.ha.device.impl.TemperatureSensorDevice;
import it.cnr.isti.zigbee.ha.driver.HADriverConfiguration;
import it.cnr.isti.zigbee.ha.driver.HAImporter;
import it.cnr.isti.zigbee.ha.driver.core.GenericHADeviceFactory;
import it.cnr.isti.zigbee.ha.driver.core.HADeviceFactoryBase;
import it.cnr.isti.zigbee.ha.driver.core.ReportingConfiguration;

import java.util.ArrayList;
import java.util.Properties;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.ManagedService;

/**
 * 
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $LastChangedRevision$ ($LastChangedDate$)
 *
 */
public class Activator implements BundleActivator {

	private static final String HA_CONFIG_PID = "it.cnr.isti.zigbee.ha.configuration";

    private HAImporter haImporter;
    
    private final ArrayList<HADeviceFactoryBase> factories = new ArrayList<HADeviceFactoryBase>();

	private ServiceRegistration configRegistration;

    private static HADriverConfiguration configuration = null;
    
    public static HADriverConfiguration getConfiguration(){
    	return configuration;
    }
    
    private void doRegisterConfigurationService(BundleContext ctx){
		Properties properties = new Properties();
		
		properties.setProperty(Constants.SERVICE_PID, HA_CONFIG_PID);
    	
    	configuration = new HADriverConfiguration(ctx);
    	configRegistration = ctx.registerService(
    			new String[]{ManagedService.class.getName(), ReportingConfiguration.class.getName()}, 
    			configuration, 
    			null
    	);
    }
    
    public void start(BundleContext ctx) throws Exception {

    	doRegisterConfigurationService(ctx);
    	
		new HAClustersFactory(ctx).register();
	
		factories.add(new OnOffLightFactory(ctx).register());
		
		//factories.add(new GenericHADeviceFactory(ctx, HADevice.class, GenericHADevice.class).register());
	
		factories.add(new GenericHADeviceFactory(ctx, DimmableLight.class, DimmableLightDevice.class).register());
	
		factories.add(new GenericHADeviceFactory(ctx, LevelControlSwitch.class, LevelControlSwitchDevice.class).register());
	
		factories.add(new GenericHADeviceFactory(ctx, OccupancySensor.class, OccupancySensorDevice.class).register());
	
		factories.add(new GenericHADeviceFactory(ctx, OnOffLightSwitch.class, OnOffLightSwitchDevice.class).register());
	
		factories.add(new GenericHADeviceFactory(ctx, OnOffOutput.class, OnOffOutputDevice.class).register());
	
		factories.add(new GenericHADeviceFactory(ctx, OnOffSwitch.class, OnOffSwitchDevice.class).register());
	
		factories.add(new GenericHADeviceFactory(ctx, TemperatureSensor.class, TemperatureSensorDevice.class).register());
		
		haImporter = new HAImporter(ctx);
    }

    public void stop(BundleContext context) throws Exception {
    	haImporter.close();
	
		for (HADeviceFactoryBase factory : factories) {
		    factory.unregister();
		}
		
    }

}<commit_msg>register all the devices correctly developed<commit_after>/*
   Copyright 2008-2010 CNR-ISTI, http://isti.cnr.it
   Institute of Information Science and Technologies 
   of the Italian National Research Council 


   See the NOTICE file distributed with this work for additional 
   information regarding copyright ownership

   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 it.cnr.isti.zigbee.ha;

import it.cnr.isti.zigbee.ha.cluster.factory.HAClustersFactory;
import it.cnr.isti.zigbee.ha.device.api.generic.LevelControlSwitch;
import it.cnr.isti.zigbee.ha.device.api.generic.MainsPowerOutlet;
import it.cnr.isti.zigbee.ha.device.api.generic.OnOffOutput;
import it.cnr.isti.zigbee.ha.device.api.generic.OnOffSwitch;
import it.cnr.isti.zigbee.ha.device.api.hvac.TemperatureSensor;
import it.cnr.isti.zigbee.ha.device.api.lighting.DimmableLight;
import it.cnr.isti.zigbee.ha.device.api.lighting.OccupancySensor;
import it.cnr.isti.zigbee.ha.device.api.lighting.OnOffLight;
import it.cnr.isti.zigbee.ha.device.api.lighting.OnOffLightSwitch;
import it.cnr.isti.zigbee.ha.device.factory.OnOffLightFactory;
import it.cnr.isti.zigbee.ha.device.impl.DimmableLightDevice;
import it.cnr.isti.zigbee.ha.device.impl.LevelControlSwitchDevice;
import it.cnr.isti.zigbee.ha.device.impl.MainsPowerOutletDevice;
import it.cnr.isti.zigbee.ha.device.impl.OccupancySensorDevice;
import it.cnr.isti.zigbee.ha.device.impl.OnOffLightDevice;
import it.cnr.isti.zigbee.ha.device.impl.OnOffLightSwitchDevice;
import it.cnr.isti.zigbee.ha.device.impl.OnOffOutputDevice;
import it.cnr.isti.zigbee.ha.device.impl.OnOffSwitchDevice;
import it.cnr.isti.zigbee.ha.device.impl.TemperatureSensorDevice;
import it.cnr.isti.zigbee.ha.driver.HADriverConfiguration;
import it.cnr.isti.zigbee.ha.driver.HAImporter;
import it.cnr.isti.zigbee.ha.driver.core.GenericHADeviceFactory;
import it.cnr.isti.zigbee.ha.driver.core.HADeviceFactoryBase;
import it.cnr.isti.zigbee.ha.driver.core.ReportingConfiguration;

import java.util.ArrayList;
import java.util.Properties;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.cm.ManagedService;

/**
 * 
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $LastChangedRevision$ ($LastChangedDate$)
 *
 */
public class Activator implements BundleActivator {

	private static final String HA_CONFIG_PID = "it.cnr.isti.zigbee.ha.configuration";

	private HAImporter haImporter;

	private final ArrayList<HADeviceFactoryBase> factories = new ArrayList<HADeviceFactoryBase>();

	private ServiceRegistration configRegistration;

	private static HADriverConfiguration configuration = null;

	public static HADriverConfiguration getConfiguration(){
		return configuration;
	}

	private void doRegisterConfigurationService(BundleContext ctx){
		Properties properties = new Properties();

		properties.setProperty(Constants.SERVICE_PID, HA_CONFIG_PID);

		configuration = new HADriverConfiguration(ctx);
		configRegistration = ctx.registerService(
				new String[]{ManagedService.class.getName(), ReportingConfiguration.class.getName()}, 
				configuration, 
				null
				);
	}

	public void start(BundleContext ctx) throws Exception {

		doRegisterConfigurationService(ctx);

		new HAClustersFactory(ctx).register();

		factories.add(new OnOffLightFactory(ctx).register());

		//factories.add(new GenericHADeviceFactory(ctx, HADevice.class, GenericHADevice.class).register());

		factories.add(new GenericHADeviceFactory(ctx, DimmableLight.class, DimmableLightDevice.class).register());

		factories.add(new GenericHADeviceFactory(ctx, LevelControlSwitch.class, LevelControlSwitchDevice.class).register());

		factories.add(new GenericHADeviceFactory(ctx, MainsPowerOutlet.class, MainsPowerOutletDevice.class).register());

		factories.add(new GenericHADeviceFactory(ctx, OccupancySensor.class, OccupancySensorDevice.class).register());

		factories.add(new GenericHADeviceFactory(ctx, OnOffLight.class, OnOffLightDevice.class).register());

		factories.add(new GenericHADeviceFactory(ctx, OnOffLightSwitch.class, OnOffLightSwitchDevice.class).register());

		factories.add(new GenericHADeviceFactory(ctx, OnOffOutput.class, OnOffOutputDevice.class).register());

		factories.add(new GenericHADeviceFactory(ctx, OnOffSwitch.class, OnOffSwitchDevice.class).register());

		factories.add(new GenericHADeviceFactory(ctx, TemperatureSensor.class, TemperatureSensorDevice.class).register());		

		haImporter = new HAImporter(ctx);
	}

	public void stop(BundleContext context) throws Exception {
		haImporter.close();

		for (HADeviceFactoryBase factory : factories) {
			factory.unregister();
		}

	}

}
{'fraction_non_alphanumeric': 0.10467509556012937, 'fraction_numerical': 0.0023522493384298734, 'mean_word_length': 5.256284488044145, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2370626', 'n_tokens_mistral': 3258, 'n_tokens_neox': 3098, 'n_words': 597}