コード例 #1
0
    def _findSchedule(self, point):
        """
		Check if the point is on a schedule and return the schedule
		"""
        sched = None
        for schedule, pointMin, pointMax in self._schedulesCoords:
            inX = (pointMin.x <= point.x) & (point.x <= pointMax.x)
            inY = (pointMin.y <= point.y) & (point.y <= pointMax.y)

            if inX & inY:
                sched = schedule.GetClientData()

        datet = None
        dateExacte = None
        for dt, pointMin, pointMax in self._datetimeCoords:
            inX = (pointMin.x <= point.x) & (point.x <= pointMax.x)
            inY = (pointMin.y <= point.y) & (point.y <= pointMax.y)

            if inX & inY:
                datet = utils.copyDateTime(dt)
                minutes = int(30.0 * (point.y - pointMin.y) /
                              (pointMax.y - pointMin.y))
                minutes = minutes - (minutes % 5)
                if 'phoenix' in wx.PlatformInfo:
                    dateExacte = datet.Add(wx.TimeSpan(hours=0, min=minutes))
                else:
                    dateExacte = datet.AddTS(wx.TimeSpan(minutes=minutes))

        return sched, datet, dateExacte
コード例 #2
0
ファイル: ClientGUIPredicates.py プロジェクト: salrana/hydrus
    def __init__(self, parent):

        PanelPredicateSystem.__init__(self, parent)

        self._sign = wx.RadioBox(self, choices=['<', u'\u2248', '=', '>'])

        self._date = wx.adv.CalendarCtrl(self)

        wx_dt = wx.DateTime.Today()

        wx_dt.Subtract(wx.TimeSpan(24 * 7))

        self._date.SetDate(wx_dt)

        self._sign.SetStringSelection('>')

        hbox = wx.BoxSizer(wx.HORIZONTAL)

        hbox.Add(
            ClientGUICommon.BetterStaticText(self, 'system:time imported'),
            CC.FLAGS_VCENTER)
        hbox.Add(self._sign, CC.FLAGS_VCENTER)
        hbox.Add(self._date, CC.FLAGS_VCENTER)

        self.SetSizer(hbox)
コード例 #3
0
    def ReadTag(self, tag_string):
        for i in range(0, len(tag_string)):
            if tag_string[i].find(settings.MESSAGE_ERROR_TAG) >= 0:
                utils.MessageBox("Error reading tag")
                return False

        ret = self.TestString(tag_string[1], settings.TAG_TAG_ID)
        if ret[0] != False and ret[1] != False:
            tag_id = ret[2]
        else:
            return False

        secret = []
        for i in range(0, 5):
            ret = self.TestString(tag_string[2 + i], settings.TAG_FOX[i])
            if ret[0] != False and ret[1] != False:
                secret.append(ret[2])
            else:
                return False
        
        history_tag_id = []
        history_timestamp = []
        for j in range(0, 5):
            history_tag_id.append([])
            history_timestamp.append([])
            for i in range(0, settings.TAG_HISTORY_ENTRIES_PER_FOX):
                ret = self.TestString(tag_string[9 + j * (settings.TAG_HISTORY_ENTRIES_PER_FOX * 2 + 2) + 2 * i], settings.TAG_TAG_ID) # + 2 because of one line with "" and one line with "Fox x:"
                if ret[0] != False and ret[1] != False:
                    history_tag_id[j].append(ret[2])
                else:
                    return False
                ret = self.TestString(tag_string[9 + j * (settings.TAG_HISTORY_ENTRIES_PER_FOX * 2 + 2) + 2 * i + 1], settings.TAG_TIMESTAMP) # + 2 because of one line with "" and one line with "Fox x:"
                if ret[0] != False and ret[1] != False:
                    history_timestamp[j].append(ret[2])
                else:
                    return False

        # check secret:
        correct_secret = [True, True, True, True, True]
        all_secrets_correct = True
        secret_msg = ""
        for i in range(0, 5):
            if self.panel_fox.GetSecret()[i] != secret[i]:
                correct_secret[i] = False
                secret_msg += "n"
                all_secrets_correct = False
            else:
                secret_msg += "y"

        time = []
        for i in range(0, 5):
            tim = self.panel_fox.GetStartTime()
            tim.AddTS(wx.TimeSpan(0, 0, history_timestamp[i][0], 0))
            time.append(tim.FormatISOTime())

        self.AddElement(tag_id, time, secret_msg)
コード例 #4
0
ファイル: tag-counter.py プロジェクト: cogilv25/Tag-Counter
	def update(self):
		#Calculate the number of trays of tags still to be completed
		traysToGo = int((self.tagTarget.GetValue() - self.tagsPrinted.GetValue()) / self.tagsPerTray.GetValue() + .99)
		self.gauge.SetValue(self.tagsPrinted.GetValue()/self.tagTarget.GetValue()*100)

		#Calculate time to finish all tags
		timetuple = self.trayTime.GetTime()
		timespan = wx.TimeSpan(timetuple[0],timetuple[1],timetuple[2]) * traysToGo
		self.timeToGoLabel.SetLabel(timespan.Format("%H:%M:%S"))

		#Update current time
		self.statusbar.timeLabel.SetLabel(time.strftime("%H:%M:%S %d/%m/%y",time.localtime(time.time())))
コード例 #5
0
ファイル: showlog.py プロジェクト: wenatuhs/chinchilla-farm
 def OnPrev(self, evt):
     date = self.panel.dpc.GetValue()
     day = wx.TimeSpan().Day()
     date -= day
     self.panel.dpc.SetValue(date)
     s = date.Format('%Y-%m-%d')
     try:
         records = self.farm.logs[s]
         content = self.sep.join([record.show() for record in records])
     except KeyError:
         content = u"暂无记录!"
     self.panel.log.Clear()
     self.panel.log.write(content)
コード例 #6
0
    def test_longlong(self):
        val1 = 2**50  # make a big value

        # setting the timespan's seconds property will use the mapped type
        # code to convert to a wxLongLong...
        ts = wx.TimeSpan(hours=0, min=0, sec=val1)

        # ...and fetching it from the timespan will use the mapped type to
        # convert back from a wxLongLong to a Python object...
        val2 = ts.GetSeconds()

        # ...which we can compare with the original.
        self.assertTrue(val1 == val2)
コード例 #7
0
ファイル: EasyAlarmer.py プロジェクト: walker8088/easyworld
    def OnTimer(self, evt):
        """ """
        now = wx.DateTime_Now()
        #log.debug("On Timer: " + now.Format("%H:%M:%S"))
        timeSpan = now.Subtract(self.LastClockTime)
        self.LastClockTime = now

        #Time rollback  or ajusted
        clkSpan = wx.TimeSpan(0, 0, int(self.ClockInterval * 2), 0)
        if timeSpan.IsNegative() or timeSpan.IsLongerThan(clkSpan):
            print "Time Revised"
            for item in self.AlamerList:
                item.AlarmReset()

        for item in self.AlamerList:
            if item.AlarmUp(now, self.ClockInterval):
                item.AlarmNotify(self)
コード例 #8
0
    def colSplit32(self, array):
        oneMinute = wx.TimeSpan(0, 1, 0, 0)
        rownum = 1
        parts = []
        for rowdata in array:  # determine how many files are needed
            if rownum == 1:
                numofParts = int(math.ceil(
                    (len(rowdata) - 10) /
                    32.0))  # number of separate files needed
                for num in range(0, numofParts):
                    parts.append(
                        [])  # create an empty list for each file to be created

                realdatetime = self.start_datetime  # get the date and time for this row of data
            else:
                realdatetime = realdatetime.AddTS(oneMinute)

            prefix = str(rownum) + '\t' + realdatetime.Format(
                '%d %b %y')  # column 0 is the row number, column 1 is the date
            prefix = prefix + '\t' + realdatetime.Format(
                '%H:%M:%S')  # column 2 is the time
            prefix = prefix + '\t1\t1\t0\t0\t0\t0\t0'  # next 7 columns are not used but DAMFileScan110X does not take 0000000 or 1111111

            for batch in range(0, numofParts):  # add 32 columns to each part
                datastring = prefix
                startcol = batch * 32
                endcol = startcol + 32
                #                datastring = ("\t%d" % number for number in rowdata[startcol: endcol])
                for number in rowdata[startcol:endcol]:
                    datastring = datastring + '\t%d' % number

                parts[batch].append(
                    datastring +
                    '\n')  # append all of the rows to list "parts[batch]"

            rownum = rownum + 1

        if len(rowdata
               ) != numofParts * 32:  # need to fill empty columns with zeroes
            morecols = (numofParts * 32) - len(rowdata)
            for rownum in range(0, len(parts[numofParts - 1])):
                parts[numofParts - 1][rownum] = parts[numofParts - 1][rownum][0:-1] + \
                                                '\t' + '\t'.join(list(repeat('0', morecols))) + '\n'
        return parts
コード例 #9
0
    def __init__(self, parent, size):
        self.parent = parent
        self.size = size
        super().__init__(parent,size=size)
        self.exit_pos = wx.Point(self.Size.x - 10, 20)
        self.exit_hot = False

        self.center = wx.Point(500,360)
        self.wtitle_text = "Stand-up Timer v1.0"
        self.grid_font = wx.Font(16*fontFactor,wx.SWISS,wx.NORMAL,wx.NORMAL,False,fontface)

        self.title_center = self.center + wx.Point(0, -170)
        self.title = wx.StaticText(self,-1,"...",pos=self.title_center,style=wx.ALIGN_CENTRE_HORIZONTAL)
        self.title.Font = wx.Font(28*fontFactor,wx.SWISS,wx.NORMAL,wx.NORMAL,False,fontface)
        self.title.ForegroundColour = wx.Colour(240, 240, 0)

        self.time = Panel.Timer(self)

        self.agenda = Panel.Agenda(self, topics)
        self.agenda.Rect = (40,120,120,0)

        self.topic_idx = 0
        self.nextup_idx = None

        self.set_topic(self.agenda[0])

        prev15MinBoundary = wx.DateTime()
        prev15MinBoundary.SetToCurrent()
        prev15MinBoundary += wx.TimeSpan(0, min=2)
        alignTimestamp(prev15MinBoundary, 15)
        self.ResetTopicStartTime(prev15MinBoundary)
        self.Topic.topic.Running = True

        self.agenda.grid.Fit(self.agenda)
        self.agenda.Layout()
        self.agenda.Size = (200, self.agenda.Size.Height)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.update_time, self.timer)
        self.timer.Start(250)

        self.Bind(wx.EVT_PAINT, self.onPaint)
コード例 #10
0
ファイル: EasyAlarmer.py プロジェクト: walker8088/easyworld
    def AlarmUp(self, now, ClockInterval):
        if (not self.Enable) or (self.Alarmed == True):
            return False
        if self.InRing == True:
            print "On Ringing: " + self.Name
            return False

        timeNow = now.Subtract(wx.DateTime_Today())
        if timeNow.IsLongerThan(self.AlarmTime):
            clkSpan = wx.TimeSpan(0, 0, ClockInterval, 500)
            timeSpan = timeNow.Subtract(self.AlarmTime)
            if timeSpan.IsShorterThan(clkSpan):
                self.Alarmed = True
                print "Alarm Up :" + self.Name
                return True
            else:
                return False
        else:
            #self.Alarmed = True;
            return False
コード例 #11
0
        def onShowPopup(self, e, pos=None):
            for m in self.popupmenu.MenuItems:
                self.popupmenu.DestroyItem(m.Id)

            now = wx.DateTime(); now.SetToCurrent()
            def T(dt, align):
                dt = alignTimestamp(wx.DateTime(dt), align)
                return (dt.hour, dt.minute)

            menuitem = self.popupmenu.AppendCheckItem(-1, "Pause")
            menuitem.Check(self.master.Topic.state == "paused")
            self.Bind(wx.EVT_MENU, lambda e:self.master.toggle_pause(), menuitem)

            if self.master.Topic is self.master.agenda[0]:
                times = {
                    T(now, 1),
                    T(now + wx.TimeSpan(0, min=1), 1),
                    T(now - wx.TimeSpan(0, min=5), 5), 
                    T(now - wx.TimeSpan(0, min=10), 5),
                    T(now, 5),
                    T(now, 10),
                    T(now, 15),
                    T(now, 30),
                    T(now, 60),
                    T(now + wx.TimeSpan(0, min=5), 5),
                    T(now + wx.TimeSpan(0, min=10), 10),
                    T(now + wx.TimeSpan(0, min=15), 15),
                    T(now + wx.TimeSpan(0, min=30), 30),
                }
                times = list(times)
                times.sort()

                self.popupmenu.AppendSeparator()
                for t in times:
                    menuitem = self.popupmenu.Append(-1, ("%02d:%02d" % t))
                    self.Bind(wx.EVT_MENU, lambda e,t=t:self.setStartTime(e, t), menuitem)

            self.PopupMenu(self.popupmenu)
コード例 #12
0
    def colSplit32(self):
        parts = []
        inputfile = self.inputfile.GetValue()
        self.outputprefix = os.path.split(inputfile)[1][0:-4]

        if self.outputprefix != '':
            with open(inputfile, 'rb') as f_in:
                input_tsv = csv.reader(f_in, delimiter='\t')

                self.interval = wx.TimeSpan(
                    0, 1, 0)  # one minute of data per row of output

                for rowdata in input_tsv:  # determine how many files are needed
                    rownum = int(rowdata[0])
                    if rownum == 1:
                        self.numofParts = int(
                            math.ceil((len(rowdata) - 10) /
                                      32.0))  # number of separate files needed
                        for num in range(0, self.numofParts):
                            parts.append(
                                []
                            )  # create a list of data for each file to be created

                        # fix the date and time
                        realdatetime = self.startDate.Value + self.startTime.GetValue(
                            as_wxTimeSpan=True)
                        self.outputprefix = self.noOverwrite()

                    else:
                        realdatetime = realdatetime + self.interval

                    rowdata[1] = realdatetime.Format(
                        '%d %b %y')  # column 1 is the date
                    rowdata[2] = realdatetime.Format(
                        '%H:%M:%S')  # column 2 is the time

                    prefix = '\t'.join(
                        rowdata[0:10]
                    )  # first 10 columns are part of each file

                    for batch in range(
                            0, self.numofParts):  # add 32 columns to each part
                        startcol = 10 + batch * 32
                        endcol = startcol + 32
                        parts[batch].append(
                            prefix + '\t' +
                            '\t'.join(rowdata[startcol:endcol]) + '\n'
                        )  # append all of the rows to list "part[batch]"

                if len(
                        rowdata
                ) != self.numofParts * 32 + 10:  # need to fill empty columns with zeroes
                    morecols = (self.numofParts * 32 +
                                10) - input_tsv.__sizeof__()
                    for rownum in range(0, len(parts[self.numofParts - 1])):
                        parts[self.numofParts - 1][rownum] = parts[self.numofParts - 1][rownum][0:-1] + \
                                                        '\t' + '\t'.join(list(repeat('0', morecols))) + '\n'

                for batch in range(0, self.numofParts):
                    outputfile = self.outputprefix + str(
                        batch + 1) + '.txt'  # create a filename for saving

                    f_out = open(outputfile, 'a')
                    for rownum in range(0, len(parts[batch])):
                        f_out.write(
                            parts[batch][rownum]
                        )  # save "part" to the file in tab delimited format

            f_in.close()
            f_out.close()

            filename = os.path.split(self.outputprefix)[1]

        if filename == '':
            self.statusbar.SetValue('Cancelled.')
            self.startBtn.Enable(True)
        else:
            self.statusbar.SetValue('Done. Output file names start with:  ' +
                                    filename)
            self.startBtn.Enable(True)