⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plotarrayly.java~1~

📁 风机在线监测系统,采用sqlserver数据库,有问题联系我
💻 JAVA~1~
字号:
package java2d;
import java.util.*;

public class plotArrayLY implements Runnable
{
	Thread thread;
	static float pts[];
	static float lastdata;
	int LT=500;
	int ptNum;
	String inputtime;
	public plotArrayLY(){
		pts=new float[LT];
		lastdata=0;
	}

	public int getptNum(){
		return ptNum;
	}

	public void inputdata(){
		if (Java2Demo.datapool!=null)
				{
					lastdata=Java2Demo.datapool.getdataF("Z1","high_frequency_table");
                    inputtime=Java2Demo.datapool.getdataT("high_frequency_table").substring(11,19);
					//disptime=samptime.substring(11,19);

		if(pts==null){
				//pts=new int[graphW];
				pts=new float[LT];
				ptNum=0;
			}else if (pts.length!=LT)
			{
				float tmp[]=null;
				if (ptNum<LT)
				{
					tmp=new float[ptNum];
					System.arraycopy(pts,0,tmp,0,tmp.length);
				}else {
					tmp=new float[LT];
					System.arraycopy(pts,pts.length-tmp.length,tmp,0,tmp.length);
					ptNum=tmp.length-2;
				}
				pts=new float[LT];
				System.arraycopy(tmp,0,pts,0,tmp.length);
			}
			else {
				 pts[ptNum]=lastdata;
				if(ptNum+1==pts.length){
					//throw out the oldest data
					for (int j=1;j<ptNum ;j++ )
					{
						pts[j-1]=pts[j];
					}
					--ptNum;
				}else{
					ptNum++;
				}
			}
				}
	}

	public void run(){
		 Thread me = Thread.currentThread();
         while (thread == me) {
               System.out.println("plotArray is running");
          inputdata();
         try{
              Thread.sleep(500);
          }catch(InterruptedException e){
              return;
          }
        
      }
            thread = null;
        }

	  public void start() {
            if (thread == null) {
                thread = new Thread(this);
                thread.setPriority(Thread.MIN_PRIORITY);
                thread.setName("plotArray");
                thread.start();
            }
        }
	
	public synchronized void stop() {
            if (thread != null) {
                thread.interrupt();
            }
            thread = null;
            notifyAll();
        }
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -