#ifndef Autorot_INCLUDED #define Autorot_INCLUDED #include #include #include #ifdef WIN32 #ifdef DOEXPORT_SCRIPT #define EXPORT_SCRIPT __declspec(dllexport) #else #define EXPORT_SCRIPT #endif #else #define EXPORT_SCRIPT #endif // A class to assist with writing the log file. class eventLog { public: eventLog(void); ~eventLog(void); // Destructor closes any open log file void setLogName(bncs_string logFileName); bool openLogFile(void); // Open the log for appending new entries bool isLogOpen(void); // Reports the open/closed state of teh log file void write(bncs_string logEntry); // Add date and time stamp, then add to the log bncs_string lastLogItem(void); // Returns last log message written private: bncs_string logName; // Set up by the constructor bool isOpen; // Keeps note of access to log file bncs_string lastLogMessage; // Last log message written to output. std::ofstream myLogFile; // File stream pointer }; // ===================================== // Define some simple data store classes // Infodriver number and slots class commSlots { public: int driver; // BNCS Driver ID int offset; // Offset into infodriver bool revertReg; // true if registered for revertives }; class stateChange { public: int current; // The newly received state int previous; // The previous state }; // Class hdkStatus is mostly a data store for various HyperDeck properties class hyperdeckStatus { public: stateChange comState; // Converted from the strings in comms status slot int playSpeed; // Expressed in percent of standard int transportState; // Converted from strings used by driver int actSlot; // Currently active slot number stateChange disk1Status; stateChange disk2Status; int mediaTime1; // Time available on media drive 1 (approx) in seconds int mediaTime2; // Time available on media drive 2 (approx) in seconds int clipCount; // Number of clips available on active disk }; // Define an enum that makes program text more readable when checking transport states. // Needs to be in a namespace to avoid name clash of "rewind" with file function std::rewind namespace ts { enum tranStat { unknown = 0, preview, record, stop, play, playloop, forward, rewind }; } // An array of texts for converting transport status strings into integers. These values // must match the strings emitted by the Hyperdeck driver. #define TS_MODES 8 bncs_string ts_names[TS_MODES] = { "", "preview", "record", "stopped", "play", "playloop", "forward", "rewind" }; // Define enum and text array for Hyperdeck status reports namespace hd { enum hyperdeckStatus { unknown=0, connected, disconnected, reconnecting }; } #define HDK_STAT_MODES 4 bncs_string hdkStatName[HDK_STAT_MODES] = { "", "connected", "disconnected", "reconnecting" }; // Define enum and text array for Hyperdeck Disk Status namespace hdDsk { enum hyperDeckDiskStatus { unknown=0, empty, mounting, mounted }; } #define HDK_DISK_STATES 4 bncs_string hdkDiskStatName[HDK_DISK_STATES] = { "", "empty", "mounting", "mounted"}; // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ class Autorot : public bncs_script_helper { public: Autorot(bncs_client_callback *parent, const char* path); virtual ~Autorot(); void buttonCallback(buttonNotify *b); int revertiveCallback(revertiveNotify * r); void databaseCallback(revertiveNotify * r); bncs_string parentCallback(parentNotify *p); void timerCallback(int); private: bncs_string my_instance; bncs_string stemName; bncs_string recFileName; bncs_string logFileName; bncs_string logmsg; // Used to build const char * strings for disk log operations commSlots hdk; // driver id and offset for Hyperdeck commSlots rxTx; // driver id and offset for Reh/Tx status commSlots errFlag; // driver id and offset for indicating an error commSlots errMsg; // driver id and offset for showing error report elsewhere stateChange rehTx; // Studio rehease/transmit states stateChange tState; // Transport state hyperdeckStatus hdkStat; eventLog myLog; int recordTimeout; // Counter for record timeout function bool makeRecording; // Set true when need to start a recording bool transpCmdTimerActive; bool mediaIsAvailable; bool errorFlagActive; // True when error report flag is active int errorStateValue; // Holds last reported error status value bool selectPing; // Causes the infodriver ping-pong to keep changing text bool pingRx; // Set true if reply received bool internErrMode; // Set true on first ping response. Clear when no ping response bool haveInstance; // True when an instance has been received bool haveHdkRevert; // Set true when revertives seen from Hyperdeck Infodriver bool haveStudioStatRevert; // Set true when get revertives form studio status bool initialWaitDone; // Set true when the initial timer timeout has completed bool doProcess; // Set true after all startup stabilisations are complete void initVariables(void); void initCommSlot(commSlots *ds); int newInstance(bncs_string newComposite); // Returns 0 if all ok, 1 on error. void hdkRevertProcess(const int sIndex, const bncs_string sInfo); int transportState_as_int(bncs_string nowState); int diskStatus_as_int(bncs_string nowVal); void makeRecFileName(void); void startRecording(void); void hyperDeckStop(void); void videoInAlarm(bool noInput); bool haveVideoInput(void); void reportErrorState(int errorStatus, bncs_string errMessage); bool checkMediaAvailable(void); }; #endif // Autorot_INCLUDED