Package modbuspal.generator

Examples of modbuspal.generator.Generator


            @Override
            public void actionPerformed(ActionEvent e)
            {
                try
                {
                    Generator gen = generatorFactory.newInstance(className);
                    automation.addGenerator(gen);
                }
                catch (InstantiationException ex)
                {
                    Logger.getLogger(AutomationEditor.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here


     * Moves the specified generator down in the list of generators.
     * @param source the generator to move down
     */
    public void down(GeneratorRenderer source)
    {
        Generator gen = source.getGenerator();
        automation.down(gen);
    }
View Full Code Here

     * @param renderer the generator to remove
     */
    public void remove(GeneratorRenderer renderer)
    {
        // get the generator
        Generator gen = renderer.getGenerator();

        // remove generator from the list
        automation.removeGenerator(gen);
    }
View Full Code Here

     * Moves the specified generator up in the generators list
     * @param source the generator to move up
     */
    public void up(GeneratorRenderer source)
    {
        Generator gen = source.getGenerator();
        automation.up(gen);
    }
View Full Code Here

        automation.up(gen);
    }

    private void addAlreadyExistingGeneratorsToList()
    {
        Generator generators[]=automation.getGenerators();
        if(generators==null)
        {
            return;
        }
View Full Code Here

    /**
     * Removes all generators from the automation.
     */
    public void removeAllGenerators()
    {
        Generator list[] = new Generator[0];
        list = generators.toArray(list);
        for( int i=0; i<list.length; i++ )
        {
            removeGenerator( list[i] );
        }
View Full Code Here

     * the specified classname
     * @param classname classname of the generators to remove
     */
    public void removeAllGenerators(String classname)
    {
        Generator list[] = new Generator[0];
        list = generators.toArray(list);
        for( int i=0; i<list.length; i++ )
        {
            if( list[i].getClassName().compareTo(classname)==0 )
            {
View Full Code Here

        {
            Node node = nodes.item(i);
            if( node.getNodeName().compareTo("generator")==0 )
            {
                String className = XMLTools.getAttribute("class", node);
                Generator gen = gf.newInstance( className );

                if( gen==null )
                {
                    throw new InstantiationException("Generator "+className+" cannot be instanciated");
                }
               
                gen.load(node);
                addGenerator(gen);
            }
        }
    }
View Full Code Here

    public void run()
    {
        System.out.println("start automation thread");
       
        // Get generators
        Generator genList[] = new Generator[generators.size()];
        genList = generators.toArray(genList);

        // init automation:
        int currentIndex = 0;
        currentValue = initialValue;
        boolean reloaded = false;
        double currentTime = 0.0;
        double startTime = 0.0;

        // init historic:
        double totalDuration = getTotalDuration();
        int histoNbPoints = (int)Math.ceil( totalDuration / stepDelay );

        fireAutomationHasStarted();

        while( (currentIndex < genList.length) && (quit==false) )
        {
            if( reloaded )
            {
                fireAutomationReloaded();
            }

            // prepare to execute generator:
            Generator currentGen = genList[currentIndex];
            currentGen.setInitialValue(currentValue);
            double duration = currentGen.getDuration();
            startTime = currentTime;
            notifyGeneratorHasStarted(currentGen);

            while( (currentTime < startTime + duration) && (quit==false) )
            {
                // set current automation value:
                currentValue = currentGen.getValue( currentTime-startTime );
                //if( previousValue != currentValue )
                //{
                    fireCurrentValueChanged(currentTime, currentValue);
                //}

                try
                {
                    while( (suspended == true) && (quit == false) )
                    {
                        System.out.println("suspended");
                        synchronized(this)
                        {
                            wait();
                        }
                    }
                    suspended = false;
                    if( quit == false )
                    {
                        Thread.sleep( (long)(stepDelay*1000.0) );
                    }
                }
                catch (InterruptedException ex)
                {
                    Logger.getLogger(Automation.class.getName()).log(Level.SEVERE, null, ex);
                }
                currentTime += stepDelay;
                //previousValue = currentValue;
            }

            // finish the execution of the generator
            //previousValue = currentValue;
            currentValue = currentGen.getValue(duration);
            notifyGeneratorHasEnded(currentGen);

            currentIndex++;
            if( currentIndex >= genList.length )
            {
View Full Code Here

        }
    }

    private void swap(int i1, int i2)
    {
        Generator g1 = generators.get(i1);
        Generator g2 = generators.get(i2);
        generators.set(i1, g2);
        generators.set(i2, g1);
        fireGeneratorSwap(g1,g2);
    }
View Full Code Here

TOP

Related Classes of modbuspal.generator.Generator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.