RoboCommNode.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /******************************************************************************
  2. |* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  3. |* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  4. |* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  5. |* PARTICULAR PURPOSE.
  6. |*
  7. |* Copyright 1995-2005 Nero AG. All Rights Reserved.
  8. |*-----------------------------------------------------------------------------
  9. |* NeroSDK / NeroRobo
  10. |*
  11. |* PROGRAM: RoboCommNode.h
  12. |*
  13. |* PURPOSE: Interface for robot communication node
  14. ******************************************************************************/
  15. /* This file describes the robot communication node interface that is
  16. * passed to each robo driver upon initialization.
  17. * A robo driver can use this communication node to communicate to
  18. * it's hardware, the user and, in some limited ways, to the operating
  19. * system */
  20. #ifndef ROBOCOMMNODE_H
  21. #define ROBOCOMMNODE_H
  22. #include "AbstractConfigurationStorage.h"
  23. #define TEMPSTORAGEMUTEXNAME "TempStorageAccess"
  24. /* Abstract thread handle for multithreaded robo drivers */
  25. class IRoboThread
  26. {
  27. public:
  28. /* Thread entry point */
  29. typedef UINT(*StartUp)(void *pUserData);
  30. /* If this method returns TRUE, dwResult will contain the exit code of the thread.
  31. * If FALSE is returned, specified thread is still running */
  32. virtual BOOL GetExitCodeThread(DWORD *dwResult) = 0;
  33. virtual ~IRoboThread() {};
  34. };
  35. /* Abstract mutex interface for multithreaded robo drivers */
  36. class IRoboMutex
  37. {
  38. public:
  39. /* Lock a mutex, pass -1 as a timeout and it will try to lock the mutex indefinitely */
  40. virtual BOOL Lock(DWORD dwTimeOut = (DWORD)-1) = 0;
  41. virtual BOOL Unlock() = 0;
  42. virtual ~IRoboMutex() {};
  43. };
  44. class CUserDialogHandle;
  45. class IConfigurationStorage;
  46. class CSerial;
  47. class IRoboPrinter;
  48. /* Since Nero 5.5.4.0 */
  49. /* First robo common node interface. */
  50. class IRoboCommNodeV1
  51. :virtual public IConfigurationStorage
  52. {
  53. public:
  54. /* This will return a serial interface to the hardware this driver
  55. * will handle. Caller must *not* free this object with delete.
  56. * Nero knows about the relations between drivers and hardware
  57. * so this method will return an instance of the type of
  58. * interface Nero chose to present to
  59. * the driver. Also note that multiple calls to this method will
  60. * always return the same instance of the interface */
  61. virtual CSerial *GetSerialInterface() = 0;
  62. /* Open/Close the recorder's CD tray. If TRUE is passed to this method,
  63. * the tray will be opened and closed otherwise.
  64. * The method will return TRUE if sucessful and FALSE in case of
  65. * an error */
  66. virtual BOOL MoveRecorderTray(BOOL bOpen) = 0;
  67. /* MultiThreading and MultiTasking control */
  68. /* Create a new thread. */
  69. virtual IRoboThread *CreateThread(IRoboThread::StartUp, void* pUserData) = 0;
  70. /* Create a mutex. */
  71. virtual IRoboMutex *CreateMutex() = 0;
  72. /* Suspend Robo thread for specified amount of time */
  73. virtual void SuspendThread(DWORD dwTimeInMS) = 0;
  74. /* Return some value whose only guaranteed property is that it is increased by 1 every ms.
  75. * Good for timeouts */
  76. virtual DWORD GetSyncTime() = 0;
  77. /* Returns the currently selected Nero Language or NULL if no internationalization support */
  78. virtual const char *GetCurrentLanguage() = 0;
  79. /* Return the currently set OEM name for some device given in szTemplateName.
  80. * If no matching OEM substitution could be found, return szTemplateName */
  81. virtual const char *GetOEMName(const char *szTemplateName) = 0;
  82. typedef enum
  83. {
  84. PRINT_OK,
  85. PRINT_FAILURE,
  86. PRINT_ABORTED
  87. } PrintResult;
  88. /* This method can be used to determine whether a label should be printed at all.
  89. * It will return TRUE if a label should be printed to the CD, i.e the user specified
  90. * a printer and label to print. */
  91. virtual BOOL LabelPrintEnabled() = 0;
  92. /* The driver must call this method at the appropriate time if it
  93. * wants to print onto the disc. It must ensure that the
  94. * disc is already in the printer when this method is being called */
  95. virtual PrintResult PrintLabel() = 0;
  96. /* -- User Interface methods:
  97. * The following methods will return a user interface handle.
  98. * It can be used to query the user for actions or to just
  99. * display some sort of status information while the robo
  100. * is performing it's tasks. The primary thread will take care
  101. * of keeping the message queue of the GUI running so
  102. * the robo task can modally wait for a dialog to be closed again
  103. * or just leave it alone entirely.
  104. *
  105. * --> Simply delete CUserDialogHandles when done.
  106. * -- */
  107. /* Create a dialog representing the current action the Robo device
  108. * is performing. */
  109. typedef enum
  110. {
  111. ERLN_INPUT,
  112. ERLN_RECORDER,
  113. ERLN_OUTPUT,
  114. ERLN_PRINTER,
  115. ERLN_WASTEBIN
  116. } ERoboLocationNode;
  117. virtual CUserDialogHandle *CreateMoveCDDialog(ERoboLocationNode source, ERoboLocationNode destination) = 0;
  118. virtual CUserDialogHandle *CreatePrintCoverDialog() = 0;
  119. /* Layout of the dialog type mask:
  120. * Bits 0-7: Message Type
  121. * Bits 8-31: Options */
  122. #define ROBOCOMMNODE_MSG_ERROR 0
  123. #define ROBOCOMMNODE_MSG_WARNING 1
  124. #define ROBOCOMMNODE_MSG_QUESTION 2
  125. #define ROBOCOMMNODE_MSG_HINT 3
  126. /* Dialogs created this way will return
  127. * CUserDialogHandle::DLGRESULT_OK or
  128. * CUserDialogHandle::DLGRESULT_CANCEL */
  129. virtual CUserDialogHandle *CreateMessage(const char *message, DWORD options) = 0;
  130. };
  131. /* Since Nero 5.5.7.9 */
  132. /* Extended the previous interface for synchronization of multiple robots and especially of
  133. * robots with multiple drives. */
  134. class IRoboCommNodeV2
  135. :public IRoboCommNodeV1
  136. {
  137. public:
  138. /* Synced temporary storage is used to store values accessible to all active robo drivers.
  139. * This means that if you know the key to a value, you can synchronize two drivers using
  140. * this facility. */
  141. virtual IConfigurationStorage *GetSyncedTemporaryStorage() = 0;
  142. /* This method can be used to get a global mutex common to all robo drivers
  143. * Use this to synchronize access to temporary storage. */
  144. virtual void LockNamedMutex(const char *szMutexName) = 0;
  145. virtual void UnlockNamedMutex(const char *szMutexName) = 0;
  146. };
  147. /* This enum can be used to specify the recorder location in method SetRecorderLocation of IRoboCommNode
  148. * interface below. At time there can be only specified left and right recorder respectively. The default
  149. * recorder is used e.g. for robots with only one drive. Later we have to adapt these values for other robos. */
  150. typedef enum
  151. {
  152. DEFAULT_RECORDER = 0,
  153. LEFT_RECORDER = 1,
  154. RIGHT_RECORDER = 2
  155. }
  156. ERoboRecorderLocation;
  157. /* Since Nero 5.5.9.4 */
  158. /* New CommNode Interface for additional functionality. */
  159. class IRoboCommNode
  160. :public IRoboCommNodeV2
  161. {
  162. public:
  163. /* The driver can use this method to check if the user wish to immediatelly abort current
  164. * robot movement. */
  165. virtual BOOL IsAbortedImmediate() = 0;
  166. /* This method is used to move the tray of recorder which is marked as LEFT_RECORDER.
  167. * It's specific to robots with two recorders for e.g. close the recorder tray which
  168. * is located above waste bin. */
  169. virtual void MoveSecondaryRecTray(BOOL bOpen) = 0;
  170. /* Call this method if print thread was created, to inform Nero, there is any print job in
  171. * progress. This will prevent Nero from exit the burn loop before the label was printed. */
  172. virtual void AddMyPrintThread() = 0;
  173. /* Remove your print thread after printing was finished.
  174. * NOTE: it's a good style to create separate thread for printing, so the robo can do another stuff
  175. * during the label is created. */
  176. virtual void RemoveMyPrintThread() = 0;
  177. /* This method specifies the recorder location. The driver can call this method to inform the
  178. * robo manager if its recorder is the left recorder which will be opened in MoveSecondaryRecTray
  179. * method. */
  180. virtual void SetRecorderLocation(int iRecorderLocation) = 0;
  181. /* Get current recorder location currently served by the driver. */
  182. virtual int GetRecorderLocation() = 0;
  183. /* This method enables the robot driver to write some error or status messages to common NeroHistory.log
  184. * file. These messages will be append at the and of current burn process info. */
  185. virtual void WriteErrorToLog(const char *cpErroMsg) = 0;
  186. };
  187. /* Defines an interface to the printer. Processed by AbstractRoboGuiManager when the Robo wants to print something */
  188. class IRoboPrinter
  189. {
  190. public:
  191. /* Print and return error. iNumCopy is a counter starting at 1, increased by one with every
  192. * print job (counter is global, it affects all connected robos) */
  193. virtual IRoboCommNode::PrintResult operator ()(int iNumCopy, IRoboCommNode *pCommNode) = 0;
  194. /* This method returns TRUE if printing is currently enabled.
  195. * Another option to disable printing still is to not provide a IRoboPrinter instance at all
  196. * but this method allows us to be more flexible regaring printer control */
  197. virtual BOOL IsPrintingEnabled() const = 0;
  198. /* Create a copy of this exact interface */
  199. virtual IRoboPrinter *Clone() const = 0;
  200. virtual ~IRoboPrinter() {};
  201. };
  202. #endif // ROBOCOMMNODE_H