home *** CD-ROM | disk | FTP | other *** search
- @KAPPA_APPLICATION_COMMENT
- /*
- This is the Autosim demonstration application for KAPPA.
- 5/17/90
-
-
-
-
- */
-
-
-
- /*********************************************************/
- /* ALL FUNCTIONS ARE SAVED BELOW **/
- /*********************************************************/
-
- /*************************************
- **** FUNCTION: MakeNoise
- *************************************/
- MakeFunction( MakeNoise, [],
- Beep( ) );
-
- /*************************************
- **** FUNCTION: RunExam1
- *************************************/
- MakeFunction( RunExam1, [],
- {
- MarysCar:Battery = Low;
- Assert( MarysCar, Battery );
- ForwardChain( LowBatt, CarRules );
- } );
-
- /*************************************
- **** FUNCTION: Clear
- *************************************/
- MakeFunction( Clear, [],
- SendMessage( MarysCar, INIT ) );
-
-
-
- /*********************************************************/
- /** ALL CLASSES ARE SAVED BELOW **/
- /*********************************************************/
-
- /*************************************
- **** CLASS: Image
- *************************************/
- Image:Width = 150;
- Image:Height = 120;
- Image:WinType = Make_ImageWindow;
- Image:Visible = FALSE;
- Image:ShowBorder = TRUE;
- Image:Transparent = FALSE;
-
- /*************************************
- **** CLASS: SlotView
- *************************************/
-
- /*************************************
- **** CLASS: OutputView
- *************************************/
-
- /*************************************
- **** CLASS: Meter
- *************************************/
- Meter:Draw = Draw_HMeter;
- Meter:Update = Update_HMeter;
-
- /*************************************
- **** CLASS: StateBox
- *************************************/
- SetSlotOption( StateBox:AllowableValues, MULTIPLE );
- StateBox:Draw = Draw_RectLight;
- StateBox:Update = Update_RectLight;
-
- /*************************************
- **** CLASS: InputOutputView
- *************************************/
-
- /*************************************
- **** CLASS: Slider
- *************************************/
- Slider:Width = 200;
- Slider:Height = 75;
- Slider:WinType = Make_SliderWindow;
- Slider:Draw = Draw_Slider;
- Slider:Update = Update_Slider;
-
- /*************************************
- **** CLASS: Edit
- *************************************/
- Edit:ShowBorder = FALSE;
- Edit:Width = 100;
- Edit:Height = 25;
- Edit:WinType = Make_EditWindow;
- Edit:Update = Update_Edit;
-
- /*************************************
- **** CLASS: Transcript
- *************************************/
- Transcript:ProportionalFont = TRUE;
- Transcript:WinType = Make_TransWindow;
-
- /*************************************
- **** CLASS: Button
- *************************************/
- Button:ShowBorder = FALSE;
- Button:Width = 100;
- Button:Height = 25;
- Button:WinType = Make_ButtonWindow;
- Button:Draw = Draw_Bitmap;
-
- /*************************************
- **** CLASS: Bitmap
- *************************************/
- Bitmap:FitToScreen = FALSE;
- Bitmap:Draw = Draw_Bitmap;
-
- /*************************************
- **** CLASS: Drawing
- *************************************/
- Drawing:XLeft = 0;
- Drawing:YTop = 100;
- Drawing:XRight = 100;
- Drawing:YBottom = 0;
- Drawing:Draw = Draw_Drawing;
- Drawing:Print = Print_Drawing;
-
- /*************************************
- **** CLASS: Text
- *************************************/
- Text:Justification = CENTER;
- Text:ShowBorder = FALSE;
- Text:Width = 100;
- Text:Height = 25;
- Text:WinType = Make_StaticWindow;
-
- /*************************************
- **** CLASS: LinePlot
- *************************************/
- LinePlot:AutoScale = FALSE;
- LinePlot:Grid = FALSE;
- LinePlot:Draw = Draw_LinePlot;
- LinePlot:Update = Update_LinePlot;
- LinePlot:Print = Print_LinePlot;
-
- /*************************************
- **** CLASS: Autos
- *************************************/
- MakeClass( Autos, Root );
-
- /************** METHOD: ResetVal ***************/
- MakeMethod( Autos, ResetVal, [],
- ResetValue( Self, ElectricalSystem ) And ResetValue( Self,
- Status )
- And ResetValue( Self, Battery ) );
-
- /************** METHOD: ManualInit ***************/
- MakeMethod( Autos, ManualInit, [],
- {
- ResetValue( Self:Battery );
- ResetValue( Self:Colors );
- ResetValue( Self:Distance );
- ResetValue( Self:Drivers );
- ResetValue( Self:ElectricalSystem );
- ResetValue( Self:Engine );
- ResetValue( Self:EngineTurnover );
- ResetValue( Self:Gallons );
- ResetValue( Self:GasSystem );
- ResetValue( Self:Ignition );
- ResetValue( Self:IgnitionKey );
- ResetValue( Self:LightAppearance );
- ResetValue( Self:LightSwitch );
- ResetValue( Self:ModelYear );
- ResetValue( Self:Owner );
- ResetValue( Self:Registered );
- ResetValue( Self:SparkPlug );
- ResetValue( Self:SparkPlugCondition );
- ResetValue( Self:Speed );
- ResetValue( Self:Status );
- ResetValue( Self:Tank );
- ResetValue( Self:Timing );
- ResetValue( Self:Passengers );
- PostMessage( "Initialization is complete." );
- } );
-
- /************** METHOD: INIT ***************/
- MakeMethod( Autos, INIT, [],
- {
- GetSlotList( Self, Global:TempList );
- EnumList( Global:TempList, SlotName, ResetValue( Self:SlotName ) );
- PostMessage( "Initialization is complete" );
- } );
- MakeSlot( Autos:Gallons );
- MakeSlot( Autos:Distance );
- MakeSlot( Autos:Tank );
- MakeSlot( Autos:Status );
- SetSlotOption( Autos:Status, ALLOWABLE_VALUES, Running, Stopped );
- MakeSlot( Autos:EngineTurnover );
- MakeSlot( Autos:Engine );
- MakeSlot( Autos:SparkPlug );
- MakeSlot( Autos:Ignition );
- MakeSlot( Autos:Passengers );
- MakeSlot( Autos:Speed );
- SetSlotOption( Autos:Speed, VALUE_TYPE, NUMBER );
- SetSlotOption( Autos:Speed, MINIMUM_VALUE, 0 );
- SetSlotOption( Autos:Speed, MAXIMUM_VALUE, 75 );
- Autos:Speed = 55;
- MakeSlot( Autos:Drivers );
- SetSlotOption( Autos:Drivers, MULTIPLE );
- MakeSlot( Autos:ModelYear );
- MakeSlot( Autos:Registered );
- MakeSlot( Autos:NumberofDoors );
- MakeSlot( Autos:Colors );
- SetSlotOption( Autos:Colors, MULTIPLE );
- MakeSlot( Autos:Owner );
- MakeSlot( Autos:Battery );
- SetSlotOption( Autos:Battery, ALLOWABLE_VALUES, Low, Charged );
- MakeSlot( Autos:SparkPlugCondition );
- SetSlotOption( Autos:SparkPlugCondition, ALLOWABLE_VALUES, Good, Bad );
- MakeSlot( Autos:Timing );
- SetSlotOption( Autos:Timing, ALLOWABLE_VALUES, InSynch, OutOfSynch );
- MakeSlot( Autos:ElectricalSystem );
- SetSlotOption( Autos:ElectricalSystem, ALLOWABLE_VALUES, Good, Bad );
- MakeSlot( Autos:LightSwitch );
- SetSlotOption( Autos:LightSwitch, ALLOWABLE_VALUES, On, Off );
- Autos:LightSwitch = ON;
- MakeSlot( Autos:LightAppearance );
- SetSlotOption( Autos:LightAppearance, ALLOWABLE_VALUES, Dim, Bright );
- MakeSlot( Autos:IgnitionKey );
- SetSlotOption( Autos:IgnitionKey, ALLOWABLE_VALUES, On, Off );
- MakeSlot( Autos:GasSystem );
- SetSlotOption( Autos:GasSystem, ALLOWABLE_VALUES, Good, Bad );
-
- /*************************************
- **** CLASS: Sedans
- *************************************/
- MakeClass( Sedans, Autos );
-
- /*************************************
- **** CLASS: StationWagons
- *************************************/
- MakeClass( StationWagons, Autos );
- MakeSlot( StationWagons:LengthOfCargo );
-
- /*************************************
- **** CLASS: People
- *************************************/
- MakeClass( People, Root );
- MakeSlot( People:Age );
- MakeSlot( People:Height );
- SetSlotOption( People:Height, VALUE_TYPE, NUMBER );
- MakeSlot( People:Weight );
- SetSlotOption( People:Weight, VALUE_TYPE, NUMBER );
- MakeSlot( People:Licensed );
- SetSlotOption( People:Licensed, VALUE_TYPE, BOOLEAN );
- MakeSlot( People:House );
- SetSlotOption( People:House, VALUE_TYPE, BOOLEAN );
- MakeSlot( People:Income );
- MakeSlot( People:Friends );
- SetSlotOption( People:Friends, MULTIPLE );
-
-
-
- /*********************************************************/
- /** ALL INSTANCES ARE SAVED BELOW **/
- /*********************************************************/
- MakeSlot( Global:CarRules );
- SetSlotOption( Global:CarRules, MULTIPLE );
- SetValue( Global:CarRules, BadElecSys, GoodElecSys, BadEngineSys, BrightLights, NoLights, BriskTurnover, NoTurnover, DimLights, GoodEngSys, SluggishTurnover );
- MakeSlot( Global:PeopleRules );
- SetSlotOption( Global:PeopleRules, MULTIPLE );
- SetValue( Global:PeopleRules, CalculateAge );
- MakeSlot( Global:List );
- SetSlotOption( Global:List, MULTIPLE );
- SetValue( Global:List, Gallons, Distance, Tank, Status, EngineTurnover, Engine, SparkPlug, Ignition, Passengers, Speed, Drivers, ModelYear, Registered, NumberofDoors, Colors, Owner, Battery, SparkPlugCondition, Timing, ElectricalSystem, LightSwitch, LightAppearance, IgnitionKey, GasSystem );
- MakeSlot( Global:TempList );
- SetSlotOption( Global:TempList, MULTIPLE );
- SetValue( Global:TempList, Gallons, Distance, Tank, Status, EngineTurnover, Engine, SparkPlug, Ignition, Passengers, Speed, Drivers, ModelYear, Registered, NumberofDoors, Colors, Owner, Battery, SparkPlugCondition, Timing, ElectricalSystem, LightSwitch, LightAppearance, IgnitionKey, GasSystem );
-
- /*************************************
- **** INSTANCE: TomsCar
- *************************************/
- MakeInstance( TomsCar, Sedans );
- TomsCar:Battery = Low;
- TomsCar:Speed = 65;
- SetValue( TomsCar:Drivers, Mary );
-
- /*************************************
- **** INSTANCE: MarysCar
- *************************************/
- MakeInstance( MarysCar, Sedans );
-
- /************** METHOD: InitMarysCar ***************/
- MakeMethod( MarysCar, InitMarysCar, [],
- ResetValue( MarysCar:ElectricalSystem ) And ResetValue( MarysCar:Status )
- And ResetValue( MarysCar:Battery ) And ResetValue( MarysCar:Speed ) );
- SetSlotOption( MarysCar:Battery, IMAGE, StateBox1 );
- SetSlotOption( MarysCar:Speed, IMAGE, Slider1, Meter1 );
-
- /*************************************
- **** INSTANCE: DicksCar
- *************************************/
- MakeInstance( DicksCar, StationWagons );
-
- /*************************************
- **** INSTANCE: Mary
- *************************************/
- MakeInstance( Mary, People );
- Mary:Income = 50000;
- Mary:House = FALSE;
-
- /*************************************
- **** INSTANCE: Dick
- *************************************/
- MakeInstance( Dick, People );
-
- /*************************************
- **** INSTANCE: Tom
- *************************************/
- MakeInstance( Tom, People );
-
- /*************************************
- **** INSTANCE: Text1
- *************************************/
- MakeInstance( Text1, Text );
- Text1:X = 208;
- Text1:Y = 10;
- Text1:Width = 58;
- Text1:Height = 44;
- Text1:Visible = TRUE;
- Text1:Title = "The Autosim Example";
- Text1:ShowBorder = TRUE;
- Text1:Justification = CENTER;
- ResetImage ( Text1 );
-
- /*************************************
- **** INSTANCE: Bitmap3
- *************************************/
- MakeInstance( Bitmap3, Bitmap );
- Bitmap3:X = 280;
- Bitmap3:Y = 1;
- Bitmap3:Visible = TRUE;
- Bitmap3:FileName = Bitone.bmp;
- Bitmap3:ShowBorder = TRUE;
- Bitmap3:FitToScreen = FALSE;
- Bitmap3:Width = 292;
- Bitmap3:Height = 80;
- ResetImage ( Bitmap3 );
-
- /*************************************
- **** INSTANCE: Button1
- *************************************/
- MakeInstance( Button1, Button );
- Button1:X = 8;
- Button1:Y = 36;
- Button1:Title = "INITialize MarysCar";
- Button1:Visible = TRUE;
- Button1:Width = 175;
- Button1:Height = 27;
- Button1:Action = Clear;
- Button1:ShowBorder = FALSE;
- ResetImage ( Button1 );
-
- /*************************************
- **** INSTANCE: StateBox1
- *************************************/
- MakeInstance( StateBox1, StateBox );
- StateBox1:X = 9;
- StateBox1:Y = 86;
- StateBox1:Visible = TRUE;
- StateBox1:Title = "Status of MarysCar Battery";
- StateBox1:ShowBorder = TRUE;
- StateBox1:Width = 162;
- StateBox1:Height = 87;
- StateBox1:Owner = MarysCar;
- StateBox1:OwnerSlot = Battery;
- ResetImage ( StateBox1 );
-
- /*************************************
- **** INSTANCE: Button2
- *************************************/
- MakeInstance( Button2, Button );
- Button2:X = 8;
- Button2:Y = 3;
- Button2:Title = "Check MarysCar Battery";
- Button2:Visible = TRUE;
- Button2:Width = 188;
- Button2:Height = 27;
- Button2:Action = RunExam1;
- Button2:ShowBorder = TRUE;
- ResetImage ( Button2 );
-
- /*************************************
- **** INSTANCE: Meter1
- *************************************/
- MakeInstance( Meter1, Meter );
- Meter1:X = 187;
- Meter1:Y = 86;
- Meter1:Visible = TRUE;
- Meter1:Title = "Show Speed of MarysCar";
- Meter1:ShowBorder = TRUE;
- Meter1:Value = 55;
- Meter1:Width = 181;
- Meter1:Height = 85;
- Meter1:Owner = MarysCar;
- Meter1:OwnerSlot = Speed;
- ResetImage ( Meter1 );
-
- /*************************************
- **** INSTANCE: Slider1
- *************************************/
- MakeInstance( Slider1, Slider );
- Slider1:X = 376;
- Slider1:Y = 87;
- Slider1:Visible = TRUE;
- Slider1:Title = "Set Speed of MarysCar";
- Slider1:RightAction = INIT;
- Slider1:ShowBorder = TRUE;
- Slider1:Value = 55;
- Slider1:Width = 191;
- Slider1:Height = 85;
- Slider1:Owner = MarysCar;
- Slider1:OwnerSlot = Speed;
- ResetImage ( Slider1 );
-
-
-
- /*********************************************************/
- /** ALL RULES ARE SAVED BELOW **/
- /*********************************************************/
-
- /*************************************
- **** RULE: BadElecSys
- *************************************/
- MakeRule( BadElecSys, [car|Autos],
- car:SparkPlugCondition #= Bad Or car:Timing #= OutOfSynch
- Or car:Battery #= Low,
- car:ElectricalSystem = Bad );
-
- /*************************************
- **** RULE: GoodElecSys
- *************************************/
- MakeRule( GoodElecSys, [car|Autos],
- car:SparkPlugCondition #= Okay And car:Timing #= InSynch And
- car:Battery #= Charged,
- car:ElectricalSystem = Okay );
-
- /*************************************
- **** RULE: BadEngineSys
- *************************************/
- MakeRule( BadEngineSys, [car|Autos],
- car:IgnitionKey #= Off Or car:GasSystem #= Bad Or car:ElectricalSystem
- #= Bad,
- car:Status = Stopped );
-
- /*************************************
- **** RULE: BrightLights
- *************************************/
- MakeRule( BrightLights, [car|Autos],
- car:LightSwitch #= On And car:Battery #= Charged,
- car:LightsAppearance = Bright );
-
- /*************************************
- **** RULE: NoLights
- *************************************/
- MakeRule( NoLights, [car|Autos],
- car:LightSwitch #= Off,
- car:LightAppearance = Dark );
-
- /*************************************
- **** RULE: BriskTurnover
- *************************************/
- MakeRule( BriskTurnover, [car|Autos],
- car:Ignition #= On And car:ElectricalSystem #= Okay,
- car:EngineTurnover = Brisk );
-
- /*************************************
- **** RULE: NoTurnover
- *************************************/
- MakeRule( NoTurnover, [car|Autos],
- car:IgnitionKey #= Off,
- car:EngineTurnover = Absent );
-
- /*************************************
- **** RULE: DimLights
- *************************************/
- MakeRule( DimLights, [car|Autos],
- car:LightSwitch #= On And car:Battery #= Low,
- car:LightsAppearance = Dim );
-
- /*************************************
- **** RULE: GoodEngSys
- *************************************/
- MakeRule( GoodEngSys, [car|Autos],
- car:IgnitionKey #= On And car:GasSystem #= Okay And car:Battery
- #= Charged,
- car:Status = Running );
-
- /*************************************
- **** RULE: SluggishTurnover
- *************************************/
- MakeRule( SluggishTurnover, [car|Autos],
- car:IgnitionKey #= On And car:ElectricalSystem #= Bad,
- car:EngineTurnover = Sluggish );
-
- /*************************************
- **** RULE: CalculateAge
- *************************************/
- MakeRule( CalculateAge, [person|People],
- person:Age #= 21,
- person:licensed = yes );
-
- /*************************************
- **** RULE: HaveHouse
- *************************************/
- MakeRule( HaveHouse, [person|People],
- person:Income > 100000,
- person:House = TRUE );
-
- /*************************************
- **** RULE: NotHaveHouse
- *************************************/
- MakeRule( NotHaveHouse, [person|People],
- person:Income <= 100000,
- person:House = FALSE );
-
-
-
- /*********************************************************/
- /** ALL GOALS ARE SAVED BELOW **/
- /*********************************************************/
-
- /*************************************
- **** GOAL: Planeflying
- *************************************/
- MakeGoal( Planeflying,
- Plane:Flying );
-
- /*************************************
- **** GOAL: LowBatt
- *************************************/
- MakeGoal( LowBatt,
- MarysCar:Battery #= Low );
-
- /*************************************
- **** GOAL: ElecSys
- *************************************/
- MakeGoal( ElecSys,
- MarysCar:ElectricalSystem #= Bad );
-
- /*************************************
- **** GOAL: Running
- *************************************/
- MakeGoal( Running,
- MarysCar:Status #= Running );
-
- /*************************************
- **** GOAL: MCStatus
- *************************************/
- MakeGoal( MCStatus,
- MarysCar:Status #= Running );
-
- /*************************************
- **** GOAL: MaryHouse
- *************************************/
- MakeGoal( MaryHouse,
- KnownValue?( Mary:House ) );
-