startOrbit method

Future<void> startOrbit(
  1. String tourKml
)

Starts the orbit animation on the Liquid Galaxy.

This method sends a KML file representing the orbit to the Liquid Galaxy and starts the orbit animation.

tourKml is the KML content defining the orbit.

Implementation

Future<void> startOrbit(String tourKml) async {
  if (!await sshConnection.isConnected()) {
    return;
  }

  const fileName = 'Orbit.kml';

  SftpClient sftp = await sshConnection.getSftp();

  // Open a remote file for writing
  final remoteFile = await sftp.open('/var/www/html/$fileName',
      mode: SftpFileOpenMode.create |
          SftpFileOpenMode.write |
          SftpFileOpenMode.truncate);

  // Convert KML string to a stream
  final kmlStreamBytes = Stream.value(Uint8List.fromList(tourKml.codeUnits));

  // Write the KML content to the remote file
  await remoteFile.write(kmlStreamBytes);

  await remoteFile.close();
  sftp.close();

  // Prepare the orbit
  await sshConnection.sendCommand(
      "echo '\nhttp://lg1:81/$fileName' >> /var/www/html/kmls.txt");

  await Future.delayed(const Duration(seconds: 1));

  // Start the orbit
  await sshConnection.sendCommand('echo "playtour=Orbit" > /tmp/query.txt');
}