 class LogReaderViewController: UITableViewController, SenStickDeviceDelegate {
     var device: SenStickDevice?
     var logID: UInt8?
-    
+    var dataModels : [SensorDataModel]?
     var accelerationDataModel:  AccelerationDataModel?
     var gyroDataModel:          GyroDataModel?
     var magneticFieldDataModel: MagneticFieldDataModel?

        self.navigationController?.popToRootViewControllerAnimated(true)
    }
    
    // methods
    
    func setServices()
    {
        accelerationDataModel?.service  = device?.accelerationSensorService
        gyroDataModel?.service          = device?.gyroSensorService
        magneticFieldDataModel?.service = device?.magneticFieldSensorService
        brightnessDataModel?.service    = device?.brightnessSensorService
        uvDataModel?.service            = device?.uvSensorService
        humidityDataModel?.service      = device?.humiditySensorService
        pressureDataModel?.service      = device?.pressureSensorService
    }
    
    func startToReadLog(logid: UInt8)
    {
        accelerationDataModel?.startToReadLog(logid)
        gyroDataModel?.startToReadLog(logid)
        magneticFieldDataModel?.startToReadLog(logid)
        brightnessDataModel?.startToReadLog(logid)
        uvDataModel?.startToReadLog(logid)
        humidityDataModel?.startToReadLog(logid)
        pressureDataModel?.startToReadLog(logid)
    }
    
    // table view source/delegate
    override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath)
    {
        let dataCell = cell as? SensorDataCellView
        dataCell?.iconButton?.userInteractionEnabled = false
        
        switch (indexPath.row) {
        case 0:
            accelerationDataModel?.cell    = dataCell
            dataCell?.iconButton?.enabled  = (accelerationDataModel?.service?.logMetaData?.availableSampleCount != 0)
            dataCell?.iconButton?.selected = (accelerationDataModel?.service?.logMetaData?.availableSampleCount != 0)
            
        case 1:
            gyroDataModel?.cell            = dataCell
            dataCell?.iconButton?.enabled  = (gyroDataModel?.service?.logMetaData?.availableSampleCount != 0)
            dataCell?.iconButton?.selected = (gyroDataModel?.service?.logMetaData?.availableSampleCount != 0)
            
        case 2:
            magneticFieldDataModel?.cell   = dataCell
            dataCell?.iconButton?.enabled  = (magneticFieldDataModel?.service?.logMetaData?.availableSampleCount != 0)
            dataCell?.iconButton?.selected = (magneticFieldDataModel?.service?.logMetaData?.availableSampleCount != 0)
            
        case 3:
            brightnessDataModel?.cell      = dataCell
            dataCell?.iconButton?.enabled  = (brightnessDataModel?.service?.logMetaData?.availableSampleCount != 0)
            dataCell?.iconButton?.selected = (brightnessDataModel?.service?.logMetaData?.availableSampleCount != 0)
            
        case 4:
            uvDataModel?.cell              = dataCell
            dataCell?.iconButton?.enabled  = (uvDataModel?.service?.logMetaData?.availableSampleCount != 0)
            dataCell?.iconButton?.selected = (uvDataModel?.service?.logMetaData?.availableSampleCount != 0)
            
        case 5:
            humidityDataModel?.cell        = dataCell
            dataCell?.iconButton?.enabled  = (humidityDataModel?.service?.logMetaData?.availableSampleCount != 0)
            dataCell?.iconButton?.selected = (humidityDataModel?.service?.logMetaData?.availableSampleCount != 0)
            
        case 6:
            pressureDataModel?.cell        = dataCell
            dataCell?.iconButton?.enabled  = (pressureDataModel?.service?.logMetaData?.availableSampleCount != 0)
            dataCell?.iconButton?.selected = (pressureDataModel?.service?.logMetaData?.availableSampleCount != 0)
            
        default: break
        }
    }
}


        uvDataModel            = UVDataModel()
        humidityDataModel      = HumidityDataModel()
        pressureDataModel      = PressureDataModel()

        dataModels = [accelerationDataModel!, gyroDataModel!, magneticFieldDataModel!, brightnessDataModel!, uvDataModel!, humidityDataModel!]
    }
    
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        
        device?.delegate = self

        // set services
        accelerationDataModel?.service  = device?.accelerationSensorService
        gyroDataModel?.service          = device?.gyroSensorService
        magneticFieldDataModel?.service = device?.magneticFieldSensorService
        brightnessDataModel?.service    = device?.brightnessSensorService
        uvDataModel?.service            = device?.uvSensorService
        humidityDataModel?.service      = device?.humiditySensorService
        pressureDataModel?.service      = device?.pressureSensorService

        for model in dataModels! {
            model.startToReadLog(self.logID!)
        }
    }
    
    override func viewWillDisappear(animated: Bool) {
