// infrastructure 2

void tInfrastructure::SetGlobalStatus(const tGlobalStatus NewStatus)
  { // routine ID 2080
    digitalWrite(pinConnectedToWindows, HIGH);
    GlobalStatus = NewStatus;
    switch (NewStatus)
      { case   gsNotConnected: TellWindows(btwDisconnectedBS);
                               digitalWrite(pinConnectedToWindows, LOW);
                               TV.SmallPrintString("(not)");
                               break;
        case  gsJustConnected: TellWindows(btwJustConnected);
                               TV.SmallPrintString("(just)");
                               break;
        case gsDumpInProgress: TellWindows(btwDumping);
                               TV.SmallPrintString("(dump)");
                               break;
        case    gsPassThrough: TellWindows(btwPassThrough);
                               TV.SmallPrintString("(pass)");
                               break;
      } // switch
  } // tInfrastructure::SetGlobalStatus

void tInfrastructure::TellWindows(const char Message[], const int MessageID)
  { // routine ID 2070
    //   XBee lines are NOT displayed locally in this code, because they are
    // displayed by tXBee::ProcessLine (routine #6070)

    char LongMessage[200];
    sprintf(LongMessage, "%d\t%s", MessageID, Message);

    if ((GlobalStatus != gsNotConnected) or InIDE)
      { // Windows available
        WindowsSerial.println(LongMessage);
      } // Windows available

    switch (MessageID)
      { case     btwDumpData: // not useful on TV
        case     btwLiveData: // handled in tXBee::ProcessLine
        case btwSavingBuffer: // handled in tFileBuffer::SaveContents
                              break;

                    default: TV.SmallPrintString(LongMessage);
                             TV.SmallPrint(BLANK);
                             break;
      } // switch
  } // tInfrastructure::TellWindows(const char Message[], const int MessageID)

void tInfrastructure::TellWindows(const int MessageID)
  { // just a code; Windows can interpret it
    char Message[12];
    sprintf(Message, "%d ", MessageID);
    WindowsSerial.println(MessageID);
    TV.SmallPrintString(Message);
  } // tInfrastructure::TellWindows(const int MessageID)


// **************** end infrastructure ******************************************

