Jess Variables comparison not working.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Jess Variables comparison not working.

c.chy
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hello, I'm beginner in Jess. Trying to implement a program where it will compare variables imported from Java class and fire a rule. But somehow it's not working. I couldn't find where is the mistake. Can anyone please help me to find out what's the mistake in my program?
Thank you.
This is the way I'm trying...

(import signals.*)
(deftemplate CurrentSignal (declare (from-class CurrentSignal)))
(deftemplate DERSignal (declare (from-class DERSignal)))

(defrule Get-CT-Number
   
   (CurrentSignal (cTNumber ?m) (measuredCurrent ?c) (cPhase ?p))
 =>
      (printout t "Measured Current : " ?c "Amps" crlf)
      (printout t "CT :" ?m crlf)  
      (printout t "Phase :" ?p  crlf)
    )


(defrule Get-DER
   
   (DERSignal  (vTNumber ?n) (measuredVoltage ?d) (vPhase ?q) )
 =>
      (printout t "Measured Voltage : " ?d "V" crlf)
      (printout t "VT :" ?n crlf)
      (printout t "Phase :" ?q  crlf)
    )

(defrule Power-Calculation-DER-signal
 
  (CurrentSignal (cTNumber ?x)(measuredCurrent ?y)(cPhase ?z))
  (DERSignal  (vTNumber ?e) (measuredVoltage ?f) (vPhase ?g) )
   
     (and (CurrentSignal {cTNumber == ?e} )
            (DERSignal {vPhase == ?z}) )
   
     ;(test(= ?x ?e))
     ;(and (test (= ?z ?g)))
=>
  (printout t "Total Power Generation : " (* ?y ?f) crlf)
)



The output is.........


Signal ID: =W61.Q406;M_VT406_UL1:4(WGEN_1500000W)   <------------ Signal ID output is from Java class

Measured Voltage : 19897.7856V
VT :406
Phase :1


Signal ID: =W61.Q406;M_VT406_UL2:5(WGEN_1500000W)   <------------ Signal ID output is from Java class

Measured Voltage : 19897.7856V
VT :406
Phase :2


Signal ID: =W61.Q406;M_VT406_UL3:6(WGEN_1500000W)  <------------ Signal ID output is from Java class

Measured Voltage : 19897.7856V
VT :406
Phase :3



Signal ID: =W61.Q406;M_CT406_IL1:4    <------------ Signal ID output is from Java class

Measured Current : 53.45Amps
CT :406
Phase :1


Signal ID: =W61.Q406;M_CT406_IL2:5  <------------ Signal ID output is from Java class

Measured Current : 53.45Amps
CT :406
Phase :2


Signal ID: =W61.Q406;M_CT406_IL3:6  <------------ Signal ID output is from Java class

Measured Current : 53.45Amps
CT :406
Phase :3

...................................................................................................................................................

I'm trying to do here if VT and CT is same and both Phases are same then multiply Measured Current and Measured Voltage to calculate power.
Loading...