Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

src/net/threebit/jvr/console/Example7.java

Go to the documentation of this file.
00001 package net.threebit.jvr.console;
00002 
00003 /*
00004  * $Id: Example7.java,v 1.4 2005/01/08 20:12:26 kevino Exp $
00005  *
00006  * Copyright (c) 2003,2004 Kevin O'Donnell
00007  * 
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307,  USA.
00021  */
00022 
00023 import java.awt.*;
00024 import java.awt.event.*;
00025 import java.awt.image.*;
00026 import java.io.*;
00027 import java.lang.reflect.*;
00028 import java.lang.reflect.Constructor;
00029 import java.net.URL;
00030 import java.net.URLClassLoader;
00031 import java.util.*;
00032 import java.util.logging.*;
00033 import javax.imageio.*;
00034 import javax.imageio.stream.*;
00035 import javax.swing.*;
00036 import net.threebit.jvr.*;
00037 
00038 /**
00039  *
00040  */
00041 public class Example7 extends AbstractExample {
00042 
00043   JDialog dlg = null;
00044   int d7;
00045   int d8;
00046   JVRMetaEventListener m = new JVRMetaEventListener() {
00047     public boolean handleEvent (MetaEvent e) throws JVRException {
00048       if (e.evtdev != d8) { return true; } // ignore
00049       if (e.evttype == ms.MSEV_SIGEVT) {
00050         int hook = ((Integer)e.evtdata).intValue();
00051         if (hook == ms.MSMM_OFFHOOK) {
00052           info("OFFHOOK");
00053         }
00054         else if (hook == ms.MSMM_ONHOOK) {
00055           info("ONHOOK");
00056         }
00057         else if (hook == ms.MSMM_HOOKFLASH) {
00058           info("FLASH");
00059         }
00060         else {
00061           info("Unknown hook event: " + hook);
00062         }
00063       }
00064       return true;
00065     }
00066   };
00067 
00068   /**
00069    *
00070    */
00071   public String getName() { return "MSI Gen Ring"; }
00072 
00073   public void finalize() {
00074     try {
00075       jvr.removeEventListener(m);
00076       ms.close(d7);
00077       ms.close(d8);
00078     }
00079     catch (Throwable ignore) { }
00080   }
00081 
00082   /**
00083    *
00084    */
00085   public void run () {
00086     try {
00087 
00088       d7 = ms.open("msiB1C7",0);
00089       d8 = ms.open("msiB1C8",0);
00090       jvr.addEventListener(m);
00091 
00092       ms.listen(d7, ms.getxmitslot(d8));
00093       ms.listen(d8, ms.getxmitslot(d7));
00094       
00095       ms.setevtmsk(d8,ms.DTG_SIGEVT,
00096         ms.MSMM_OFFHOOK|ms.MSMM_ONHOOK|ms.MSMM_HOOKFLASH,ms.DTA_ADDMSK);
00097   
00098       // Collect some user data.
00099       dlg = new JDialog(console.frame,"Example 1 Setup",true);
00100       dlg.getContentPane().setLayout(new BorderLayout());
00101   
00102       // Properties area
00103       JPanel propPanel = new JPanel();
00104       dlg.getContentPane().add(propPanel,BorderLayout.CENTER);
00105   
00106       JButton b = new JButton("Ring");
00107       b.addActionListener(new AbstractAction(){
00108         public void actionPerformed (ActionEvent e) {
00109           try {
00110             ms.genring(d8,2,ms.EV_ASYNC);
00111           }
00112           catch (Throwable ignore) {
00113             ignore.printStackTrace();
00114           }
00115         }
00116       });
00117       propPanel.add(b);
00118 
00119       dlg.pack();
00120       dlg.setLocationRelativeTo(console.frame);
00121       dlg.setVisible(true);
00122     }
00123     catch (Throwable ignore) { }
00124 
00125   }
00126 
00127 }
00128 

Generated on Sat Jul 16 03:47:34 2005 for JVR by doxygen 1.3.5