import os, sys
if 'nt' in sys.builtin_module_names:
    import winapps

from typing import List
from fdsreader import Simulation
from theng.models import Model

class FDSModel(Model, Simulation):
    """Represents a single FDS / PyroSim simulation and it's results.
    
    This class is a thin wrapper around the `Simulation <https://firedynamics.github.io/fdsreader/simulation.html>`_ class of fdsreader.

    Args:
        results_file_name (str): The basename of the .smv Results file generated by FDS
    """
    
    def __init__(self, results_file_name: str):
        
        Model.__init__(self, results_file_name, ".fds")
        Simulation.__init__(self, results_file_name)
        
    def take_screenshot(
        self, 
        app_name: str, 
        ssview: str | List[str], 
        ssname: str | List[str] | None = None, 
        sswidth: int = 800, 
        ssheight: int = 600, 
        sstime: float | int = 0
    ) -> List[str]:
        if 'nt' in sys.builtin_module_names:
            apps = [app for app in winapps.search_installed("pyrosim")]
            app = apps[0]
            
            results_path = f"{app.install_location}{os.sep}PyroSimResults.exe"
            return super()._take_screenshot(results_path, ssview, ssname, sswidth, ssheight, sstime)
        else:
            self._log.error("Tried to take a screenshot on a non-Windows platform")