--
-- Controller
--
controllerUnit :: ComponentInstance
controllerUnit = ComponentInstance c $ BasicComponent nameController sig beh
 where
  m2  = mkMessage "m2" "{urlVid:String,urlPic:String}"
  m3  = mkMessage "m3" "{url:String}"
  sig = Signature
    [run]
    [askVid, askPic]
    (fromList [(run, m1), (askVid, m1), (askPic, m1)])
    (fromList [(run, Just m2), (askVid, Just m3), (askPic, Just m3)])
  beh = LabelledTransitionSystem
    mempty
    [ receive run
    , reply run
    , invoke askVid
    , result askVid
    , invoke askPic
    , result askPic
    ]
    (State <$> ["0", "1", "2", "3", "4", "5", "6"])
    (State "0")
    [State "6"]
    [ "0" -| receive run |-> "1"
    , "1" -| invoke askVid |-> "2"
    , "2" -| result askVid |-> "3"
    , "3" -| invoke askPic |-> "4"
    , "4" -| result askPic |-> "5"
    , "5" -| reply run |-> "6"
    ]

--
-- Store Unit
--
controllerUnit :: ComponentInstance
controllerUnit = ComponentInstance c $ BasicComponent nameController sig beh
 where
  m2  = mkMessage "m2" "{urlVid:String,urlPic:String}"
  m3  = mkMessage "m3" "{url:String}"
  sig = Signature
    [run]
    [askVid, askPic]
    (fromList [(run, m1), (askVid, m1), (askPic, m1)])
    (fromList [(run, Just m2), (askVid, Just m3), (askPic, Just m3)])
  beh = LabelledTransitionSystem
    mempty
    [ receive run
    , reply run
    , invoke askVid
    , result askVid
    , invoke askPic
    , result askPic
    ]
    (State <$> ["0", "1", "2", "3", "4", "5", "6"])
    (State "0")
    [State "6"]
    [ "0" -| receive run |-> "1"
    , "1" -| invoke askVid |-> "2"
    , "2" -| result askVid |-> "3"
    , "3" -| invoke askPic |-> "4"
    , "4" -| result askPic |-> "5"
    , "5" -| reply run |-> "6"
    ]

--
-- Store Unit
--
controllerUnit = ComponentInstance c $ BasicComponent nameController sig beh
 where
  m2  = mkMessage "m2" "{urlVid:String,urlPic:String}"
  m3  = mkMessage "m3" "{url:String}"
  sig = Signature
    [run]
    [askVid, askPic]
    (fromList [(run, m1), (askVid, m1), (askPic, m1)])
    (fromList [(run, Just m2), (askVid, Just m3), (askPic, Just m3)])
  beh = LabelledTransitionSystem
    mempty
    [ receive run
    , reply run
    , invoke askVid
    , result askVid
    , invoke askPic
    , result askPic
    ]
    (State <$> ["0", "1", "2", "3", "4", "5", "6"])
    (State "0")
    [State "6"]
    [ "0" -| receive run |-> "1"
    , "1" -| invoke askVid |-> "2"
    , "2" -| result askVid |-> "3"
    , "3" -| invoke askPic |-> "4"
    , "4" -| result askPic |-> "5"
    , "5" -| reply run |-> "6"
    ]

--
-- Store Unit
--