<commit_before>/*
 *  cam_SXV.cpp
 *  PHD Guiding
 *
 *  Created by <NAME>.
 *  Copyright (c) 2008-2010 <NAME>.
 *  All rights reserved.
 *
 *  This source code is distributed under the following "BSD" license
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *    Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *    Redistributions in binary form must reproduce the above copyright notice,
 *     this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *    Neither the name of <NAME>, Stark Labs nor the names of its
 *     contributors may be used to endorse or promote products derived from
 *     this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *
 */


#include "phd.h"

#if defined (SXV)

#include "cam_SXV.h"
#include "image_math.h"

#include <wx/choicdlg.h>

#if defined(__WINDOWS__)
typedef HANDLE SXHandle;
#else
typedef void* SXHandle;
#endif

extern Camera_SXVClass Camera_SXV;

enum {
    SX_CMOS_GUIDER = 39,
};

inline static bool IsCMOSGuider(int model)
{
    return model == SX_CMOS_GUIDER;
}

static wxString NameFromModel(int model)
{
    wxString m;

    switch (model)
    {
        case 0x05: m = "SX-H5"; break;
        case 0x85: m = "SX-H5C"; break;
        case 0x09: m = "SX-H9"; break;
        case 0x89: m = "SX-H9C"; break;
        case 0x39: m = "SX-LS9"; break;
        case 0x19: m = "SX-SX9"; break;
        case 0x99: m = "SX-SX9C"; break;
        case 0x10: m = "SX-H16"; break;
        case 0x90: m = "SX-H16C"; break;
        case 0x11: m = "SX-H17"; break;
        case 0x91: m = "SX-H17C"; break;
        case 0x12: m = "SX-H18"; break;
        case 0x92: m = "SX-H18C"; break;
        case 0x23: m = "SX-H35"; break;
        case 0xB3: m = "SX-H35C"; break;
        case 0x24: m = "SX-H36"; break;
        case 0xB4: m = "SX-H36C"; break;
        case 0x56: m = "SX-H674"; break;
        case 0xB6: m = "SX-H674C"; break;
        case 0x57: m = "SX-H694"; break;
        case 0xB7: m = "SX-H694C"; break;
        case 0x28: m = "SX-H814"; break;
        case 0xA8: m = "SX-H814C"; break;
        case 0x29: m = "SX-H834"; break;
        case 0xA9: m = "SX-H834C"; break;
        case 0x3B: m = "SX-H825"; break;
        case 0xBB: m = "SX-H825C"; break;
        case 0x3C: m = "SX-US825"; break;
        case 0xBC: m = "SX-US825C"; break;
            // interlaced models
        case 0x45: m = "SX-MX5"; break;
        case 0x84: m = "SX-MX5C"; break;
        case 0x46: m = "SX-LX1"; break;
        case 0x47: m = "SX-MX7"; break;
        case 0xC7: m = "SX-MX7C"; break;
        case 0x48: m = "SX-MX8"; break;
        case 0xC8: m = "SX-MX8C"; break;
        case 0x49: m = "SX-MX9"; break;
        case 0x59: m = "SX-M25"; break;
        case 0x5A: m = "SX-M26"; break;
            // development models
        case 0x0C: m = "SX-DEV1"; break;
        case 0x0D: m = "SX-DEV2"; break;
        case 0x0E: m = "SX-DEV3"; break;
        case 0x0F: m = "SX-DEV4"; break;

        default: m = wxString::Format("SX Camera Model %d", model); break;
    }

    if (model == 70)
        m = _T("SXV-Lodestar");
    else if (model == SX_CMOS_GUIDER)
        m = _T("SX CMOS Guider");
    else if (model == 0x39)
        m = _T("SX Superstar guider");

    return m;
}

Camera_SXVClass::Camera_SXVClass()
{
    Connected = false;
    Name = _T("<NAME>");
    FullSize = m_darkFrameSize = wxSize(1280, 1024);
    HasGainControl = false;
    m_hasGuideOutput = true;
    Interlaced = false;
    RawData = NULL;
    RawDataSize = 0;
    HasSubframes = true;
    PropertyDialogType = PROPDLG_WHEN_DISCONNECTED;
    SquarePixels = pConfig->Profile.GetBoolean("/camera/SXV/SquarePixels", false);
}

wxByte Camera_SXVClass::BitsPerPixel()
{
    return 16;
}

class SXCameraDlg : public wxDialog
{
public:
    wxCheckBox* m_squarePixels;

    SXCameraDlg(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& title = _("SX Camera Settings"),
        const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(268, 133), long style = wxDEFAULT_DIALOG_STYLE);<commit_msg>Add Ultrastar display name, rename CMOS Guider to CoStar<commit_after>/*
 *  cam_SXV.cpp
 *  PHD Guiding
 *
 *  Created by <NAME>.
 *  Copyright (c) 2008-2010 <NAME>.
 *  All rights reserved.
 *
 *  This source code is distributed under the following "BSD" license
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *    Redistributions of source code must retain the above copyright notice,
 *     this list of conditions and the following disclaimer.
 *    Redistributions in binary form must reproduce the above copyright notice,
 *     this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *    Neither the name of Craig Stark, Stark Labs nor the names of its
 *     contributors may be used to endorse or promote products derived from
 *     this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *
 */


#include "phd.h"

#if defined (SXV)

#include "cam_SXV.h"
#include "image_math.h"

#include <wx/choicdlg.h>

#if defined(__WINDOWS__)
typedef HANDLE SXHandle;
#else
typedef void* SXHandle;
#endif

extern Camera_SXVClass Camera_SXV;

enum {
    SX_CMOS_GUIDER = 39,
};

inline static bool IsCMOSGuider(int model)
{
    return model == SX_CMOS_GUIDER;
}

static wxString NameFromModel(int model)
{
    wxString m;

    switch (model)
    {
        case 0x05: m = "SX-H5"; break;
        case 0x85: m = "SX-H5C"; break;
        case 0x09: m = "SX-H9"; break; // this is almost certainly a Superstar
        case 0x89: m = "SX-H9C"; break;
        case 0x39: m = "SX-LS9"; break;
        case 0x19: m = "SX-SX9"; break;
        case 0x99: m = "SX-SX9C"; break;
        case 0x10: m = "SX-H16"; break;
        case 0x90: m = "SX-H16C"; break;
        case 0x11: m = "SX-H17"; break;
        case 0x91: m = "SX-H17C"; break;
        case 0x12: m = "SX-H18"; break;
        case 0x92: m = "SX-H18C"; break;
        case 0x23: m = "SX-H35"; break;
        case 0xB3: m = "SX-H35C"; break;
        case 0x24: m = "SX-H36"; break;
        case 0xB4: m = "SX-H36C"; break;
        case 0x56: m = "SX-H674"; break;
        case 0xB6: m = "SX-H674C"; break;
        case 0x57: m = "SX-H694"; break;
        case 0xB7: m = "SX-H694C"; break;
        case 0x28: m = "SX-H814"; break;
        case 0xA8: m = "SX-H814C"; break;
        case 0x29: m = "SX-H834"; break;
        case 0xA9: m = "SX-H834C"; break;
        case 0x3B: m = "SX-H825"; break;
        case 0xBB: m = "SX-H825C"; break;
        case 0x3C: m = "SX-US825"; break;
        case 0xBC: m = "SX-US825C"; break;
            // interlaced models
        case 0x45: m = "SX-MX5"; break;
        case 0x84: m = "SX-MX5C"; break;
        case 0x46: m = "SX-LX1"; break;
        case 0x47: m = "SX-MX7"; break;
        case 0xC7: m = "SX-MX7C"; break;
        case 0x48: m = "SX-MX8"; break;
        case 0xC8: m = "SX-MX8C"; break;
        case 0x49: m = "SX-MX9"; break;
        case 0x59: m = "SX-M25"; break;
        case 0x5A: m = "SX-M26"; break;
            // development models
        case 0x0C: m = "SX-DEV1"; break;
        case 0x0D: m = "SX-DEV2"; break;
        case 0x0E: m = "SX-DEV3"; break;
        case 0x0F: m = "SX-DEV4"; break;

        default: m = wxString::Format("SX Camera Model %d", model); break;
    }

    if (model == 0x46)
        m = _T("SX Lodestar");
    else if (model == SX_CMOS_GUIDER)
        m = _T("SX CoStar");
    else if (model == 0x3A || model == 0x19)
        m = _T("SX Superstar");
    else if (model == 0x3C || model == 0xBC)
        m = _T("SX Ultrastar");

    return m;
}

Camera_SXVClass::Camera_SXVClass()
{
    Connected = false;
    Name = _T("<NAME>");
    FullSize = m_darkFrameSize = wxSize(1280, 1024);
    HasGainControl = false;
    m_hasGuideOutput = true;
    Interlaced = false;
    RawData = NULL;
    RawDataSize = 0;
    HasSubframes = true;
    PropertyDialogType = PROPDLG_WHEN_DISCONNECTED;
    SquarePixels = pConfig->Profile.GetBoolean("/camera/SXV/SquarePixels", false);
}

wxByte Camera_SXVClass::BitsPerPixel()
{
    return 16;
}

class SXCameraDlg : public wxDialog
{
public:
    wxCheckBox* m_squarePixels;

    SXCameraDlg(wxWindow *parent, wxWindowID id = wxID_ANY, const wxString& title = _("SX Camera Settings"),
        const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(268, 133), long style = wxDEFAULT_DIALOG_STYLE);
{'fraction_non_alphanumeric': 0.11234436830421773, 'fraction_numerical': 0.04323906958787762, 'mean_word_length': 2.695435092724679, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6662596', 'n_tokens_mistral': 4040, 'n_tokens_neox': 3659, 'n_words': 1204}