pictureUnit :: ComponentInstance
pictureUnit = ComponentInstance p $ BasicComponent namePictureUnit sig beh
 where
  m2  = mkMessage "m2" "{data:RawPicture}"
  sig = Signature
    [askPic]
    [getPic, storePic]
    (fromList [(askPic, m1), (getPic, m1), (storePic, m1s)])
    (fromList [(askPic, Just m4), (getPic, Just m2), (storePic, Nothing)])
  beh = LabelledTransitionSystem
    mempty
    [ receive askPic
    , reply askPic
    , invoke getPic
    , result getPic
    , invoke storePic
    , tau (TimeValue 2) (TimeValue 4)
    ]
    (State <$> ["0", "1", "2", "3", "4", "5", "6"])
    (State "0")
    [State "6"]
    [ "0" -| receive askPic |-> "1"
    , "1" -| invoke getPic |-> "2"
    , "2" -| result getPic |-> "3"
    , "3" -| tau (TimeValue 2) (TimeValue 4) |-> "4"
    , "3" -| tau (TimeValue 2) (TimeValue 4) |-> "5"
    , "4" -| invoke storePic |-> "5"
    , "5" -| reply askPic |-> "6"
    ]

--
-- Video Unit
--
pictureUnit :: ComponentInstance
pictureUnit = ComponentInstance p $ BasicComponent namePictureUnit sig beh
 where
  m2  = mkMessage "m2" "{data:RawPicture}"
  sig = Signature
    [askPic]
    [getPic, storePic]
    (fromList [(askPic, m1), (getPic, m1), (storePic, m1s)])
    (fromList [(askPic, Just m4), (getPic, Just m2), (storePic, Nothing)])
  beh = LabelledTransitionSystem
    mempty
    [ receive askPic
    , reply askPic
    , invoke getPic
    , result getPic
    , invoke storePic
    , tau (TimeValue 2) (TimeValue 4)
    ]
    (State <$> ["0", "1", "2", "3", "4", "5", "6"])
    (State "0")
    [State "6"]
    [ "0" -| receive askPic |-> "1"
    , "1" -| invoke getPic |-> "2"
    , "2" -| result getPic |-> "3"
    , "3" -| tau (TimeValue 2) (TimeValue 4) |-> "4"
    , "3" -| tau (TimeValue 2) (TimeValue 4) |-> "5"
    , "4" -| invoke storePic |-> "5"
    , "5" -| reply askPic |-> "6"
    ]

--
-- Video Unit
--
pictureUnit = ComponentInstance p $ BasicComponent namePictureUnit sig beh
 where
  m2  = mkMessage "m2" "{data:RawPicture}"
  sig = Signature
    [askPic]
    [getPic, storePic]
    (fromList [(askPic, m1), (getPic, m1), (storePic, m1s)])
    (fromList [(askPic, Just m4), (getPic, Just m2), (storePic, Nothing)])
  beh = LabelledTransitionSystem
    mempty
    [ receive askPic
    , reply askPic
    , invoke getPic
    , result getPic
    , invoke storePic
    , tau (TimeValue 2) (TimeValue 4)
    ]
    (State <$> ["0", "1", "2", "3", "4", "5", "6"])
    (State "0")
    [State "6"]
    [ "0" -| receive askPic |-> "1"
    , "1" -| invoke getPic |-> "2"
    , "2" -| result getPic |-> "3"
    , "3" -| tau (TimeValue 2) (TimeValue 4) |-> "4"
    , "3" -| tau (TimeValue 2) (TimeValue 4) |-> "5"
    , "4" -| invoke storePic |-> "5"
    , "5" -| reply askPic |-> "6"
    ]

--
-- Video Unit
--