anchor.diff:  test_stop_response( ok ) ->
       Id = make_ref(),
       Id2 = make_ref(),
  -    Device = #device{ id = Id, state = running },
  +    Device = #device{ id = Id, state = running,
  +                      stopped_by = { make_ref(), self() } },
       Devices = orddict:store( Id, Device, orddict:new() ),
       S0 = #state{ devices = Devices },
   
  
positive.code:     NewState = State#state{ devices = Devices },
      { noreply, NewState };
  
  handle_call( { stop_device, DeviceId }, _From, State ) ->
      case orddict:find( DeviceId, State#state.devices ) of
          { ok, Device } ->
              ok = lurch_device:stop( Device#device.id ),
              NewDevices = orddict:update(
                  DeviceId,
                  fun( D ) -> D#device{ state = stopping } end,
                  State#state.devices
              ),
              NewState = State#state{ devices = NewDevices },
              % FIXME - reply when the device really stops
              { reply, ok, NewState };
          error -> {reply, { error, no_such_device }, State }
      end;
  
  
negative.code:     gen_server:reply( Device#device.started_by, Msg ).
  
  handle_stop( shutdown, DeviceId, State ) ->
      reply_stop( DeviceId, State ),
      Devices = orddict:erase( DeviceId, State#state.devices ),
      State#state{ devices = Devices };
  
  handle_stop( _Error, DeviceId, State ) ->
      reply_stop( DeviceId, State ),
      Devices = orddict:update(
          DeviceId,
          fun( D ) -> D#device{ os_pid = undefined, state = crashed } end,
          State#state.devices
      ),
      State#state{ devices = Devices }.
  
  reply_stop( DeviceId, State ) ->
      Device = orddict:fetch( DeviceId, State#state.devices ),
      reply_stop( Device#device.stopped_by ).
  
  % This can happen when there was device stop requested,
  % however the device has exited meanwhile.
  reply_stop( undefined ) -> ok;
  reply_stop( From ) -> gen_server:reply( From, ok ).
  
  
  handle_poll( _Msg, _DeviceId, State ) ->
      % FIXME - propagate to subscribers
  