Home Reference Source

src/tangojs/core/api/CommandProxy.js

  1.  
  2. import { DeviceProxy } from './DeviceProxy'
  3.  
  4. /** @private */
  5. const _proxy = Symbol.for('_proxy')
  6.  
  7. /** @private */
  8. const _cmdname = Symbol.for('_cmdname')
  9.  
  10. export class CommandProxy {
  11.  
  12. /**
  13. * @param {string} devname device name
  14. * @param {string} cmdname command name
  15. */
  16. constructor (devname, cmdname) {
  17.  
  18. /** @private */
  19. this[_cmdname] = cmdname
  20.  
  21. /** @private */
  22. this[_proxy] = new DeviceProxy(devname)
  23. }
  24.  
  25. /**
  26. * @return {Promise<CommandInfo,Error>}
  27. */
  28. get_info () {
  29. return this[_proxy].command_query(this[_cmdname])
  30. }
  31.  
  32. /**
  33. * @param {undefined|DeviceData} argin
  34. * @return {Promise<DeviceData,Error>}
  35. */
  36. inout (argin) {
  37. return this[_proxy].command_inout(this[_cmdname], argin)
  38. }
  39. }