#!/usr/bin/env python
# -*- encoding: utf-8 -*-


from ui.download import Download
from ui.own.frame_theme import MyFrame
from ui.own.my_chart_view import MyChartView
from utils.globalvar import SD
from utils.qt import QMessageBox, QChart, QValueAxis, QHBoxLayout, QPainter, Qt, Signal, Slot, QLegendMarker


class Win_Download(Download, MyFrame):
    bms_sn_signal = Signal()
    bat_sn_signal = Signal()

    def __init__(self, parent=None):
        super(Win_Download, self).__init__(parent)
        self.setupUi(self)

        self.btn_bms_sn.clicked.connect(self._bms_sn)
        self.btn_battery_sn.clicked.connect(self._battery_sn)

    def _bms_sn(self):
        self.bms_sn_signal.emit()

    def _battery_sn(self):
        self.bat_sn_signal.emit()

    def can_connect_error(self):
        QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败！" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error！")

    def index_error(self):
        QMessageBox.critical(self, "错误的SN" if SD.SYSTEM_LANGUAGE == 0 else "SN error", "SN不符！" if SD.SYSTEM_LANGUAGE == 0 else "SN not aviable！")
