00001 import gridlabd.*;
00002 import java.util.Hashtable;
00003
00004 public class SampleClass{
00006 private static GClass oclass;
00009 private static Hashtable<Long, SampleClass> objtable = new Hashtable<Long, SampleClass>();
00011 protected GObject obj;
00013 private SampleClass(GObject o, long paddr){
00014 obj = o;
00015 obj.SetParent(paddr);
00016 }
00017
00018
00019
00020
00021
00022
00023 public static void register(GClass c){
00024
00025 oclass = c;
00026
00027 oclass.AddProperty("bingo", "char8");
00028 oclass.AddProperty("zingo", "int16");
00029 oclass.AddProperty("zango", "complex");
00030 oclass.AddProperty("zingo", "double");
00031 }
00032
00050 public static long create(long paddr){
00051 GObject o = GObject.BuildSingle(oclass);
00052 if(o == null){
00053 GridlabD.error("GObject.BuildSingle() failed");
00054 return 0;
00055 }
00056 SampleClass sc = new SampleClass(o, paddr);
00057 objtable.put(new Long(o.GetAddr()), sc);
00058
00059
00060
00061 return o.GetAddr();
00062 }
00063
00064
00065
00066
00067
00068
00069 public static int init(long oaddr, long paddr){
00070 SampleClass sc = objtable.get(new Long(oaddr));
00071 if(sc == null){
00072 GridlabD.error("SampleClass.init(): not one of our objects at 0x"+Long.toHexString(oaddr));
00073 }
00074
00075 System.out.println("SampleClass.init()");
00076
00077 return 1;
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 public static int commit(long oaddr){
00089 SampleClass sc = objtable.get(new Long(oaddr));
00090 if(sc == null){
00091 GridlabD.error("SampleClass.commit(): not one of our objects at 0x"+Long.toHexString(oaddr));
00092 }
00093
00094 System.out.println("SampleClass.commit()");
00095
00096 return 1;
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 public static long sync(long oaddr, long t0, int pass){
00109 SampleClass sc = objtable.get(new Long(oaddr));
00110 if(sc == null){
00111 GridlabD.error("SampleClass.sync(): not one of our objects at 0x"+Long.toHexString(oaddr));
00112 }
00113
00114 System.out.println("SampleClass.sync("+t0+")");
00115
00116 return GridlabD.TS_NEVER;
00117 }
00118
00119
00120
00121
00122
00123
00124
00125 public static int notify(long oaddr, int msg){
00126 SampleClass sc = objtable.get(new Long(oaddr));
00127 if(sc == null){
00128 GridlabD.error("SampleClass.notify(): not one of our objects at 0x"+Long.toHexString(oaddr));
00129 }
00130
00131 return 0;
00132 }
00133
00134
00135
00136
00137
00138
00139 public static int isa(long oaddr){
00140 if(objtable.containsKey(new Long(oaddr)))
00141 return 1;
00142 else
00143 return 0;
00144 }
00145
00155 public static long plc(long oaddr, long t1){
00156 return GridlabD.TS_NEVER;
00157 }
00158 }