cron job dev!

owly

闇の伝説
Staff member
戦闘 コーダー
:s82:because team fuki rules @fukurou

trgEvery // mod minutes== 0 instead of == minutes

trgNag:
maxTimes
counter = 0
resetTime = ""

trigger(){
if trgTime() {c = 0;return c}
if c < max {if trgEvery(now){c++;return c}}
}
 

fukurou

the supreme coder
ADMIN
Java:
import LivinGrimoire.PlayGround;

import java.util.Random;

public class TrgEveryNMinutes extends TrGEV3{
    // trigger true at minute once per hour
    private PlayGround playGround = new PlayGround();
    int minutes; // minute interval between triggerings
    private PlayGround pl = new PlayGround();
    private TrgTime trgTime;
    private String timeStamp = "";

    public TrgEveryNMinutes(String startTime, int minutes) {
        this.minutes = minutes;
        this.timeStamp = startTime;
        trgTime = new TrgTime();
        trgTime.setTime(startTime);
    }

    public void setMinutes(int minutes) {
            if (minutes > -1) {
            this.minutes = minutes;}
    }

    @Override
    public Boolean trigger() {
        if (trgTime.alarm()){
            timeStamp = pl.getFutureInXMin(minutes);
            trgTime.setTime(timeStamp);
            return true;
        }
        return false;
    }

    @Override
    public void reset() {
        timeStamp = pl.getCurrentTimeStamp();
    }
}
 

fukurou

the supreme coder
ADMIN
Java:
package AXJava;

import LivinGrimoire.PlayGround;

import java.util.Random;

public class Cron extends TrGEV3{
    // trigger true limit times, after initial time, and every minutes interval
    private PlayGround playGround = new PlayGround();
    int minutes; // minute interval between triggerings
    private PlayGround pl = new PlayGround();
    private TrgTime trgTime;
    private String timeStamp = "";
    private String initialTimeStamp = "";
    private int limit;
    private int counter = 0;

    public Cron(String startTime, int minutes, int limit) {
        this.minutes = minutes;
        this.timeStamp = startTime;
        this.initialTimeStamp = startTime;
        trgTime = new TrgTime();
        trgTime.setTime(startTime);
        this.limit = limit;
        if(limit<0){this.limit = 1;}
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        if (limit>-1){
        this.limit = limit;}
    }

    public int getCounter() {
        return counter;
    }

    public void setMinutes(int minutes) {
        if (minutes > -1) {
            this.minutes = minutes;}
    }
    @Override
    public Boolean trigger() {
        // delete counter = 0 if you don't want the trigger to work the next day
        if (counter == limit) {trgTime.setTime(initialTimeStamp);counter = 0;return false;}
        if (trgTime.alarm()){
            timeStamp = pl.getFutureInXMin(minutes);
            trgTime.setTime(timeStamp);
            counter++;
            return true;
        }
        return false;
    }
    @Override
    public void reset() {
        counter = 0;
    }
}
 
Top