{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IoTFleetWise.Types.Sensor
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTFleetWise.Types.Sensor where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTFleetWise.Types.NodeDataType
import qualified Amazonka.Prelude as Prelude

-- | An input component that reports the environmental condition of a
-- vehicle.
--
-- You can collect data about fluid levels, temperatures, vibrations, or
-- battery voltage from sensors.
--
-- /See:/ 'newSensor' smart constructor.
data Sensor = Sensor'
  { -- | A list of possible values a sensor can take.
    Sensor -> Maybe [Text]
allowedValues :: Prelude.Maybe [Prelude.Text],
    -- | A brief description of a sensor.
    Sensor -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The specified possible maximum value of the sensor.
    Sensor -> Maybe Double
max :: Prelude.Maybe Prelude.Double,
    -- | The specified possible minimum value of the sensor.
    Sensor -> Maybe Double
min :: Prelude.Maybe Prelude.Double,
    -- | The scientific unit of measurement for data collected by the sensor.
    Sensor -> Maybe Text
unit :: Prelude.Maybe Prelude.Text,
    -- | The fully qualified name of the sensor. For example, the fully qualified
    -- name of a sensor might be @Vehicle.Body.Engine.Battery@.
    Sensor -> Text
fullyQualifiedName :: Prelude.Text,
    -- | The specified data type of the sensor.
    Sensor -> NodeDataType
dataType :: NodeDataType
  }
  deriving (Sensor -> Sensor -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Sensor -> Sensor -> Bool
$c/= :: Sensor -> Sensor -> Bool
== :: Sensor -> Sensor -> Bool
$c== :: Sensor -> Sensor -> Bool
Prelude.Eq, ReadPrec [Sensor]
ReadPrec Sensor
Int -> ReadS Sensor
ReadS [Sensor]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Sensor]
$creadListPrec :: ReadPrec [Sensor]
readPrec :: ReadPrec Sensor
$creadPrec :: ReadPrec Sensor
readList :: ReadS [Sensor]
$creadList :: ReadS [Sensor]
readsPrec :: Int -> ReadS Sensor
$creadsPrec :: Int -> ReadS Sensor
Prelude.Read, Int -> Sensor -> ShowS
[Sensor] -> ShowS
Sensor -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Sensor] -> ShowS
$cshowList :: [Sensor] -> ShowS
show :: Sensor -> String
$cshow :: Sensor -> String
showsPrec :: Int -> Sensor -> ShowS
$cshowsPrec :: Int -> Sensor -> ShowS
Prelude.Show, forall x. Rep Sensor x -> Sensor
forall x. Sensor -> Rep Sensor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Sensor x -> Sensor
$cfrom :: forall x. Sensor -> Rep Sensor x
Prelude.Generic)

-- |
-- Create a value of 'Sensor' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'allowedValues', 'sensor_allowedValues' - A list of possible values a sensor can take.
--
-- 'description', 'sensor_description' - A brief description of a sensor.
--
-- 'max', 'sensor_max' - The specified possible maximum value of the sensor.
--
-- 'min', 'sensor_min' - The specified possible minimum value of the sensor.
--
-- 'unit', 'sensor_unit' - The scientific unit of measurement for data collected by the sensor.
--
-- 'fullyQualifiedName', 'sensor_fullyQualifiedName' - The fully qualified name of the sensor. For example, the fully qualified
-- name of a sensor might be @Vehicle.Body.Engine.Battery@.
--
-- 'dataType', 'sensor_dataType' - The specified data type of the sensor.
newSensor ::
  -- | 'fullyQualifiedName'
  Prelude.Text ->
  -- | 'dataType'
  NodeDataType ->
  Sensor
newSensor :: Text -> NodeDataType -> Sensor
newSensor Text
pFullyQualifiedName_ NodeDataType
pDataType_ =
  Sensor'
    { $sel:allowedValues:Sensor' :: Maybe [Text]
allowedValues = forall a. Maybe a
Prelude.Nothing,
      $sel:description:Sensor' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:max:Sensor' :: Maybe Double
max = forall a. Maybe a
Prelude.Nothing,
      $sel:min:Sensor' :: Maybe Double
min = forall a. Maybe a
Prelude.Nothing,
      $sel:unit:Sensor' :: Maybe Text
unit = forall a. Maybe a
Prelude.Nothing,
      $sel:fullyQualifiedName:Sensor' :: Text
fullyQualifiedName = Text
pFullyQualifiedName_,
      $sel:dataType:Sensor' :: NodeDataType
dataType = NodeDataType
pDataType_
    }

-- | A list of possible values a sensor can take.
sensor_allowedValues :: Lens.Lens' Sensor (Prelude.Maybe [Prelude.Text])
sensor_allowedValues :: Lens' Sensor (Maybe [Text])
sensor_allowedValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sensor' {Maybe [Text]
allowedValues :: Maybe [Text]
$sel:allowedValues:Sensor' :: Sensor -> Maybe [Text]
allowedValues} -> Maybe [Text]
allowedValues) (\s :: Sensor
s@Sensor' {} Maybe [Text]
a -> Sensor
s {$sel:allowedValues:Sensor' :: Maybe [Text]
allowedValues = Maybe [Text]
a} :: Sensor) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A brief description of a sensor.
sensor_description :: Lens.Lens' Sensor (Prelude.Maybe Prelude.Text)
sensor_description :: Lens' Sensor (Maybe Text)
sensor_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sensor' {Maybe Text
description :: Maybe Text
$sel:description:Sensor' :: Sensor -> Maybe Text
description} -> Maybe Text
description) (\s :: Sensor
s@Sensor' {} Maybe Text
a -> Sensor
s {$sel:description:Sensor' :: Maybe Text
description = Maybe Text
a} :: Sensor)

-- | The specified possible maximum value of the sensor.
sensor_max :: Lens.Lens' Sensor (Prelude.Maybe Prelude.Double)
sensor_max :: Lens' Sensor (Maybe Double)
sensor_max = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sensor' {Maybe Double
max :: Maybe Double
$sel:max:Sensor' :: Sensor -> Maybe Double
max} -> Maybe Double
max) (\s :: Sensor
s@Sensor' {} Maybe Double
a -> Sensor
s {$sel:max:Sensor' :: Maybe Double
max = Maybe Double
a} :: Sensor)

-- | The specified possible minimum value of the sensor.
sensor_min :: Lens.Lens' Sensor (Prelude.Maybe Prelude.Double)
sensor_min :: Lens' Sensor (Maybe Double)
sensor_min = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sensor' {Maybe Double
min :: Maybe Double
$sel:min:Sensor' :: Sensor -> Maybe Double
min} -> Maybe Double
min) (\s :: Sensor
s@Sensor' {} Maybe Double
a -> Sensor
s {$sel:min:Sensor' :: Maybe Double
min = Maybe Double
a} :: Sensor)

-- | The scientific unit of measurement for data collected by the sensor.
sensor_unit :: Lens.Lens' Sensor (Prelude.Maybe Prelude.Text)
sensor_unit :: Lens' Sensor (Maybe Text)
sensor_unit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sensor' {Maybe Text
unit :: Maybe Text
$sel:unit:Sensor' :: Sensor -> Maybe Text
unit} -> Maybe Text
unit) (\s :: Sensor
s@Sensor' {} Maybe Text
a -> Sensor
s {$sel:unit:Sensor' :: Maybe Text
unit = Maybe Text
a} :: Sensor)

-- | The fully qualified name of the sensor. For example, the fully qualified
-- name of a sensor might be @Vehicle.Body.Engine.Battery@.
sensor_fullyQualifiedName :: Lens.Lens' Sensor Prelude.Text
sensor_fullyQualifiedName :: Lens' Sensor Text
sensor_fullyQualifiedName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sensor' {Text
fullyQualifiedName :: Text
$sel:fullyQualifiedName:Sensor' :: Sensor -> Text
fullyQualifiedName} -> Text
fullyQualifiedName) (\s :: Sensor
s@Sensor' {} Text
a -> Sensor
s {$sel:fullyQualifiedName:Sensor' :: Text
fullyQualifiedName = Text
a} :: Sensor)

-- | The specified data type of the sensor.
sensor_dataType :: Lens.Lens' Sensor NodeDataType
sensor_dataType :: Lens' Sensor NodeDataType
sensor_dataType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Sensor' {NodeDataType
dataType :: NodeDataType
$sel:dataType:Sensor' :: Sensor -> NodeDataType
dataType} -> NodeDataType
dataType) (\s :: Sensor
s@Sensor' {} NodeDataType
a -> Sensor
s {$sel:dataType:Sensor' :: NodeDataType
dataType = NodeDataType
a} :: Sensor)

instance Data.FromJSON Sensor where
  parseJSON :: Value -> Parser Sensor
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Sensor"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text
-> Maybe Double
-> Maybe Double
-> Maybe Text
-> Text
-> NodeDataType
-> Sensor
Sensor'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"allowedValues" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"description")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"max")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"min")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"unit")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"fullyQualifiedName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"dataType")
      )

instance Prelude.Hashable Sensor where
  hashWithSalt :: Int -> Sensor -> Int
hashWithSalt Int
_salt Sensor' {Maybe Double
Maybe [Text]
Maybe Text
Text
NodeDataType
dataType :: NodeDataType
fullyQualifiedName :: Text
unit :: Maybe Text
min :: Maybe Double
max :: Maybe Double
description :: Maybe Text
allowedValues :: Maybe [Text]
$sel:dataType:Sensor' :: Sensor -> NodeDataType
$sel:fullyQualifiedName:Sensor' :: Sensor -> Text
$sel:unit:Sensor' :: Sensor -> Maybe Text
$sel:min:Sensor' :: Sensor -> Maybe Double
$sel:max:Sensor' :: Sensor -> Maybe Double
$sel:description:Sensor' :: Sensor -> Maybe Text
$sel:allowedValues:Sensor' :: Sensor -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
allowedValues
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
max
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
min
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
unit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fullyQualifiedName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NodeDataType
dataType

instance Prelude.NFData Sensor where
  rnf :: Sensor -> ()
rnf Sensor' {Maybe Double
Maybe [Text]
Maybe Text
Text
NodeDataType
dataType :: NodeDataType
fullyQualifiedName :: Text
unit :: Maybe Text
min :: Maybe Double
max :: Maybe Double
description :: Maybe Text
allowedValues :: Maybe [Text]
$sel:dataType:Sensor' :: Sensor -> NodeDataType
$sel:fullyQualifiedName:Sensor' :: Sensor -> Text
$sel:unit:Sensor' :: Sensor -> Maybe Text
$sel:min:Sensor' :: Sensor -> Maybe Double
$sel:max:Sensor' :: Sensor -> Maybe Double
$sel:description:Sensor' :: Sensor -> Maybe Text
$sel:allowedValues:Sensor' :: Sensor -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
allowedValues
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
max
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
min
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
unit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
fullyQualifiedName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NodeDataType
dataType

instance Data.ToJSON Sensor where
  toJSON :: Sensor -> Value
toJSON Sensor' {Maybe Double
Maybe [Text]
Maybe Text
Text
NodeDataType
dataType :: NodeDataType
fullyQualifiedName :: Text
unit :: Maybe Text
min :: Maybe Double
max :: Maybe Double
description :: Maybe Text
allowedValues :: Maybe [Text]
$sel:dataType:Sensor' :: Sensor -> NodeDataType
$sel:fullyQualifiedName:Sensor' :: Sensor -> Text
$sel:unit:Sensor' :: Sensor -> Maybe Text
$sel:min:Sensor' :: Sensor -> Maybe Double
$sel:max:Sensor' :: Sensor -> Maybe Double
$sel:description:Sensor' :: Sensor -> Maybe Text
$sel:allowedValues:Sensor' :: Sensor -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"allowedValues" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
allowedValues,
            (Key
"description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Key
"max" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
max,
            (Key
"min" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
min,
            (Key
"unit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
unit,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"fullyQualifiedName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
fullyQualifiedName),
            forall a. a -> Maybe a
Prelude.Just (Key
"dataType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NodeDataType
dataType)
          ]
      )