async fn log_temperatures(&self, elapsed: zx::Duration) {
        // Execute a query to each temperature sensor driver.
        let queries = FuturesUnordered::new();
        for (index, driver) in self.drivers.iter().enumerate() {
            let query = async move {
                let result = match driver.proxy.get_temperature_celsius().await {
                    Ok((zx_status, temperature)) => match zx::Status::ok(zx_status) {
                        Ok(()) => Ok(temperature),
                        Err(e) => Err(format_err!(
                            "{}: get_temperature_celsius returned an error: {}",
                            driver.topological_path,
                            e
                        )),
                    },
                    Err(e) => Err(format_err!(
                        "{}: get_temperature_celsius IPC failed: {}",
                        driver.topological_path,
                        e
                    )),
                };
                (index, result)
            };
            queries.push(query);
        }
        let results = queries.collect::<Vec<(usize, Result<f32, Error>)>>().await;

        // Log the temperatures to Inspect and to a trace counter.
        let mut trace_args = Vec::new();
        for (index, result) in results.into_iter() {
            match result {
                Ok(temperature) => {
                    self.inspect.log_temperature(index, temperature, elapsed.into_millis());

                    trace_args.push(fuchsia_trace::ArgValue::of(
                        self.drivers[index].name(),
                        temperature as f64,
                    ));
                }
                // In case of a polling error, the previous value will from this sensor will not be
                // updated. We could do something fancier like exposing an error count, but this
                // sample will be missing from the trace counter as is, and any serious analysis
                // should be performed on the trace.
                Err(e) => fx_log_err!("Error reading temperature: {:?}", e),
            };
        }

        fuchsia_trace::counter(
            fuchsia_trace::cstr!("temperature_logger"),
            fuchsia_trace::cstr!("temperature"),
            0,
            &trace_args,
        );
    }
/// Polls temperature sensors and logs the resulting data to Inspect and trace.
Polls temperature sensors and logs the resulting data to Inspect and trace.
Polls temperature sensors and logs the resulting data to Inspect and trace .
async fn log_temperatures(&self, elapsed: zx::Duration) {
        // Execute a query to each temperature sensor driver.
        let queries = FuturesUnordered::new();
        for (index, driver) in self.drivers.iter().enumerate() {
            let query = async move {
                let result = match driver.proxy.get_temperature_celsius().await {
                    Ok((zx_status, temperature)) => match zx::Status::ok(zx_status) {
                        Ok(()) => Ok(temperature),
                        Err(e) => Err(format_err!(
                            "{}: get_temperature_celsius returned an error: {}",
                            driver.topological_path,
                            e
                        )),
                    },
                    Err(e) => Err(format_err!(
                        "{}: get_temperature_celsius IPC failed: {}",
                        driver.topological_path,
                        e
                    )),
                };
                (index, result)
            };
            queries.push(query);
        }
        let results = queries.collect::<Vec<(usize, Result<f32, Error>)>>().await;
        // Log the temperatures to Inspect and to a trace counter.
        let mut trace_args = Vec::new();
        for (index, result) in results.into_iter() {
            match result {
                Ok(temperature) => {
                    self.inspect.log_temperature(index, temperature, elapsed.into_millis());
                    trace_args.push(fuchsia_trace::ArgValue::of(
                        self.drivers[index].name(),
                        temperature as f64,
                    ));
                }
                // In case of a polling error, the previous value will from this sensor will not be
                // updated. We could do something fancier like exposing an error count, but this
                // sample will be missing from the trace counter as is, and any serious analysis
                // should be performed on the trace.
                Err(e) => fx_log_err!("Error reading temperature: {:?}", e),
            };
        }
        fuchsia_trace::counter(
            fuchsia_trace::cstr!("temperature_logger"),
            fuchsia_trace::cstr!("temperature"),
            0,
            &trace_args,
        );
    }
async fn log_temperatures ( & self , elapsed : zx :: Duration ) { // Execute a query to each temperature sensor driver. let queries = FuturesUnordered :: new ( ) ; for ( index , driver ) in self . drivers . iter ( ) . enumerate ( ) { let query = async move { let result = match driver . proxy . get_temperature_celsius ( ) . await { Ok ( ( zx_status , temperature ) ) => match zx :: Status :: ok ( zx_status ) { Ok ( ( ) ) => Ok ( temperature ) , Err ( e ) => Err ( format_err ! ( " " driver topological_path e ) ) , } , Err ( e ) => Err ( format_err ! ( " " driver topological_path e ) ) , } ; ( index , result ) } ; queries . push ( query ) ; } let results = queries . collect :: < Vec < ( usize , Result < f32 , Error > ) > > ( ) . await ; // Log the temperatures to Inspect and to a trace counter. let mut trace_args = Vec :: new ( ) ; for ( index , result ) in results . into_iter ( ) { match result { Ok ( temperature ) => { self . inspect . log_temperature ( index , temperature , elapsed . into_millis ( ) ) ; trace_args . push ( fuchsia_trace :: ArgValue :: of ( self . drivers [ index ] . name ( ) , temperature as f64 , ) ) ; } // In case of a polling error, the previous value will from this sensor will not be // updated. We could do something fancier like exposing an error count, but this // sample will be missing from the trace counter as is, and any serious analysis // should be performed on the trace. Err ( e ) => fx_log_err ! ( " " e ) , } ; } fuchsia_trace :: counter ( fuchsia_trace :: cstr ! ( " " ) , fuchsia_trace :: cstr ! ( " " ) , 0 , & trace_args , ) ; }
Polls temperature sensors and logs the resulting data to Inspect and trace.
Polls temperature sensors and logs the resulting data to Inspect and trace .
&self
elapsed
zx::Duration
&self
elapsed
zx::Duration