library PluginHisis22; { Camera Plugin exemple for TeleAuto Allow to drive the Hisis 22 camera Direct conversion of the original capt14.pas driver of Gilles Revillon Doesn't leave he shutter closed for darks} uses SysUtils, Classes, Windows; // Only for the sleep function; type TLigInt=array[1..999999] of SmallInt; PLigInt=^TLigInt; TImgInt=array[1..999999] of PLigInt; PImgInt=^TImgInt; TTabImgInt=array[1..255] of PImgInt; PTabImgInt=^TTabImgInt; // Prototype of the TeleAuto function you can call to have precise hour // New in version 2.8 TGetHour = procedure (var Year,Month,Day,Hour,Min,Sec,MSec:Word); var // TeleAuto function giving precise hour // New in version 2.8 GetHour:TGetHour; var // Variables provided by the TeleAuto user to set up the CD camera Adress:Word; // The adress of the paralel port used by the camera x1,y1,x2,y2:Integer; // The window to acquire in equivalent binning 1x1 Sx,Sy:Integer; // Size of the CCD detector Binning:Integer; // Binning used Pose:Double; // The pose in seconds EmptyingDelay:Double; // Delay needed to empty the CCD (Hisis cameras) ReadingDelay:Double; // Reading delay (Hisis cameras) DateTimeBegin:TDateTime; // The time of the expose begining DateTimeEnd:TDateTime; // The time of the expose begining PCMinusUT:Double; // Difference hour PC minus hour UT OSiSNT:Boolean; // Ta is used under NT ? // Variables used in this driver YearBegin,MonthBegin,DayBegin,HourBegin,MinBegin,SecBegin,MSecBegin:Word; YearEnd,MonthEnd,DayEnd,HourEnd,MinEnd,SecEnd,MSecEnd:Word; // Hisis 22 specific variables PoseLo : Word; PoseHi : Byte; PoseI : LongInt absolute PoseLo; {$R *.RES} // Give BIOS hour // Give only seconds function GetRealDateTime:TDateTime; var Heures,Minutes,Secondes,Siecles,Annees,Mois,Jours:Byte; WHeures,WMinutes,WSecondes,WAnnees,WMois,WJours:Word; begin asm // Hour mov ah,02 int $1a mov Heures,ch mov Minutes,cl mov Secondes,dh // Date mov ah,04 int $1a mov Siecles,ch mov Annees,cl mov Mois,dh mov Jours,dl end; // BCD Convertion WHeures:=((Heures and $f0) shr 4)*10+(Heures and $0f); WMinutes:=((Minutes and $f0) shr 4)*10+(Minutes and $0f); WSecondes:=((Secondes and $f0) shr 4)*10+(Secondes and $0f); WAnnees:=(((Siecles and $f0) shr 4)*10+(Siecles and $0f))*100+((Annees and $f0) shr 4)*10+(Annees and $0f); WMois:=((Mois and $f0) shr 4)*10+(Mois and $0f); WJours:=((Jours and $f0) shr 4)*10+(Jours and $0f); Result:=EncodeTime(WHeures,WMinutes,WSecondes,0)+EncodeDate(WAnnees,WMois,WJours)-PCMinusUT/24; end; // Functions to read/write on the // port procedure PortWrite(Contenu:Byte;Adresse:Word); asm mov AL,Contenu mov DX,Adresse out DX,AL end; function PortRead(Adresse:Word):Byte; asm mov DX,Adresse in AL,DX mov @Result,Al end; // Hisis 22 Specific Function function WritePar(Adress:Word;Par:Byte):Boolean; var i:integer; begin Result:=True; i:=0; repeat inc(i) until ((PortRead(Adress+1) and $40)=$40) or (i>10000); if i>10000 then begin Result:=False; Exit; end; PortWrite(Par,Adress); for i:=1 to 10000 do; PortWrite($0D,Adress+2); i:=0; repeat inc(i) until ((PortRead(Adress+1) and $40)=0) or (i>10000); if i>10000 then begin Result:=False; Exit; end; PortWrite($0C,Adress+2); end; function PluginGetXSize:Integer; cdecl; // Here you must provide x size of the CCD chip in pixels begin Result:=768; end; function PluginGetYSize:Integer; cdecl; // Here you must provide y size of the CCD chip in pixels begin Result:=512; end; procedure PluginSetPort(_Adress:Word); cdecl; // The adress of the // port to use begin Adress:=_Adress; end; function PluginSetWindow(_x1,_y1,_x2,_y2:Integer):Boolean; cdecl; // The window to use for the exposure begin if (_x1>0) and (_x2>0) and (_x10) and (_y2>0) and (_y1_x1) and (_y2>_y1) then begin x1:=_x1; y1:=_y1; x2:=_x2; y2:=_y2; Result:=True; end else Result:=False; end; function PluginSetBinning(_Binning:Integer):Boolean; cdecl; // The binning to use for the exposure begin if (_Binning=1) or (_Binning=2) or (_Binning=3) or (_Binning=4) then begin Binning:=_Binning; Result:=True; end else Result:=False; end; function PluginSetPose(_Pose:Double):Boolean; cdecl; // The pose to use for the exposure in seconds begin if _Pose>0 then begin if _Pose>50331.645 then _Pose:=50331.645; Pose:=_Pose; Result:=True; end else Result:=False; end; function PluginSetEmptyingDelay(_EmptyingDelay:Double):Boolean; cdecl; // The time taken to empty the CCD chip (for Hisis 22 cameras) begin if (_EmptyingDelay>0) then begin EmptyingDelay:=_EmptyingDelay; Result:=True; end else Result:=False; end; function PluginSetReadingDelay(_ReadingDelay:Double):Boolean; cdecl; // The reading delay to slow down the // port speed (Hisis 22) begin if (_ReadingDelay>0) then begin ReadingDelay:=_ReadingDelay; Result:=True; end else Result:=False; end; function PluginSetShutterCloseDelay(Delay:Double):Boolean; cdecl; // The closing delay of the shutter (Audine/Genesis with R. David shutter) begin // Not used end; function PluginIsConnectedAndOK:Boolean; cdecl; // Here you must provide a function used by TeleAuto to know if the CCD camera is connected and operating // Return true if everything is OK var i:Integer; begin Result:=True; PortWrite($81,Adress); PortWrite($0C,Adress+2); PortWrite($0C,Adress+2); PortWrite($0D,Adress+2); PortWrite($0D,Adress+2); i:=0; repeat Inc(i); until ((PortRead(Adress+1) and $40)=0) or (i>10000); if i>10000 then begin Result:=False; Exit; end; PortWrite($0C,Adress+2); end; function PluginOpen:Boolean; cdecl; // Here you must put the instruction needed to initialise the CCD camera before to use it // This procedure is used only when connecting the CCD camera to TeleAuto begin // Nothing to do Result:=True; end; procedure PluginClose; cdecl; // Here you must put the instruction needed to close the CCD camera after using it // This procedure is used only when closing TeleAuto begin // Nothing to do end; function PluginStartPose:Boolean; cdecl; // Here you must put the instruction needed to start the pose // The variables to use here are // Adress:Word; // x1,y1,x2,y2:Integer; // Sx,Sy:Integer; // Pose:Double; // Binning:Integer; // Return true if everything is OK var i:Integer; TimeInit:TDateTime; Good:Boolean; LocalAdress:Word; begin LocalAdress:=Adress; Result:=True; Sx:=(x2-x1+1) div Binning; Sy:=(y2-y1+1) div Binning; PortWrite($ff,Adress); PoseI:=Round(Pose*1000/3); PoseHi:=PoseI shr 16; PortWrite($81,Adress); PortWrite($0C,Adress+2); PortWrite($0C,Adress+2); PortWrite($0D,Adress+2); PortWrite($0D,Adress+2); i:=0; Good:=True; repeat Inc(i) until ((PortRead(Adress+1) and $40)=0) or (i>10000); if i>10000 then begin Result:=False; Exit; end; PortWrite($0C,Adress+2); if Good then Good:=WritePar(Adress,$96); if Good then Good:=WritePar(Adress,PoseHi); if Good then Good:=WritePar(Adress,Hi(PoseLo)); if Good then Good:=WritePar(Adress,Lo(PoseLo)); if Good then Good:=WritePar(Adress,Hi(x1)); if Good then Good:=WritePar(Adress,Lo(x1)); if Good then Good:=WritePar(Adress,Hi(y1)); if Good then Good:=WritePar(Adress,Lo(y1)); if Good then Good:=WritePar(Adress,Hi(x2)); if Good then Good:=WritePar(Adress,Lo(x2)); if Good then Good:=WritePar(Adress,Hi(y2)); if Good then Good:=WritePar(Adress,Lo(y2)); if Good then Good:=WritePar(Adress,(Binning shl 4)+Binning); if Good then Good:=WritePar(Adress,1); if not(Good) then begin Result:=False; Exit; end; asm push edx push eax mov dx,LocalAdress inc dx inc dx mov al,00000100b out dx,al out dx,al pop eax pop edx end; // For Hisis 22 the begin of the exposure is after the emptying delay ! TimeInit:=Time; while Time