package demoPack block EKS class demoPack_Data extends ExternalObject; function constructor input String fileName; output demoPack_Data table; external "C" table = constructor(fileName) annotation(Library="exttest.o",Include="#include \"exttest.h\""); end constructor; function destructor input demoPack_Data table; external "C" destructor(table) annotation(Library="exttest.o",Include="#include \"exttest.h\""); end destructor; end demoPack_Data; function fexttest input Real omega; input Integer Position; input demoPack_Data PPP; output Integer rv; output Integer outx; external "C" rv = exttest(omega, Position, outx, PPP) annotation(Library="exttest.o",Include="#include \"exttest.h\""); end fexttest; demoPack_Data table = demoPack_Data("data.xml"); input Integer HallSignal; input Real omega; input Integer HallPos; output Integer Check(start=0); output Integer BBR(start=0); algorithm if HallSignal <> pre(HallSignal) then (Check, BBR) := fexttest(omega, HallPos, table); end if; end EKS; end demoPack; package PhysicalModels block MotorModel parameter Real R=1; parameter Real L=0.001; parameter Real U=12; parameter Real kphi=0.1; parameter Real J=0.0005; Real I(start=0); output Real omega(start=0); output Real Position(start=-100); protected Real frc(start=0); equation frc = if Position > -25 then -50*(Position+25) else 0; der(I) = (U - R*I - kphi*omega)/L; der(omega) = kphi*I/J + frc; der(Position) = omega; end MotorModel; block Hall input Real Position(start=-100); output Integer HallSignal(start=0); output Integer HallPos(start=0); algorithm if sin(Position*10.0) > 0 then HallSignal := -10; HallPos := HallPos + 1; elseif sin(Position*10.0) < 0 then HallSignal := 0; HallPos := HallPos + 1; end if; end Hall; end PhysicalModels; model externaltest PhysicalModels.MotorModel mot; PhysicalModels.Hall hall; demoPack.EKS dcu; equation connect(mot.Position, hall.Position); connect(dcu.omega, mot.omega); connect(dcu.HallPos, hall.HallPos); connect(hall.HallSignal, dcu.HallSignal); end externaltest;