Jump to content
Security Installer Community

Anyone Recognise This Language?


PeterJames

Recommended Posts

Its a language used to write a PIC in our CCTV software. We have some prewritten PIC' s along with standard modules like AND OR XOR Gates and programable calanders etc. I need to write a PIC to maximise the a camera when an input is triggered.

 

I can get it to work with the older software but since they updated the software the first line of the PIC doesnt work (I am guessing they have changed the name in the software but I cant see where)

Link to comment
Share on other sites

I;'m no guru but there is some recognisable code there.  There's a chunk of code missing also, but as you can see it is declaring a bunch of variables initially:

 

 

var
PicEvents: TPicEvents;
PicUID: Int64;
PicName: string;
InputsCount,
OutputsCount: integer;
Inputs: array[0..15] of TPicPin;
Outputs: array[0..15] of TPicPin;
 

 

Declares each variable stating the variable name followed by : followed by type, e.g. string (text) / integer (number) etc... followed by term ;

 

In the case of the inputs and outputs variables the content of those is the result of a previously declared array variable called TPicPin.

 

You should be able to call this up to display current content of each declared variable / previously completed variables like the TPicPin array.

 

 

// system thread
procedure OnPinMessage(Sender: TObject; const User: string; const PinUID: Int64; State: boolean; const DataType: TRCadDataType; const Data: string);
var
idx: integer;
begin
  try

 

Declared the OnPinMessage proc, again notice punctuation - the index variable is then created followed by the usage:

 

   // translate inputs to outputs
   idx:=(PinUID and $1F)-1;
   if (idx>=0) and (idx<InputsCount) and
      (PinUID=Inputs[idx].UID) then
    begin
     Inputs[idx].State:=State;
     Inputs[idx].DataType:=DataType;
     Inputs[idx].Data:=Data;

 

Strange that it is looking for a restriction based on the inputsCount when that wasn't previously declared (must have come before or somewhere else?).

btn_myprofile_160x33.png


 

Link to comment
Share on other sites

I;'m no guru but there is some recognisable code there.  There's a chunk of code missing also, but as you can see it is declaring a bunch of variables initially:

 

 

 

Declares each variable stating the variable name followed by : followed by type, e.g. string (text) / integer (number) etc... followed by term ;

 

In the case of the inputs and outputs variables the content of those is the result of a previously declared array variable called TPicPin.

 

You should be able to call this up to display current content of each declared variable / previously completed variables like the TPicPin array.

 

 

 

Declared the OnPinMessage proc, again notice punctuation - the index variable is then created followed by the usage:

 

 

Strange that it is looking for a restriction based on the inputsCount when that wasn't previously declared (must have come before or somewhere else?).

I probably hadnt posted the complete program

 

program PicFilter;

uses VServer,RCad,Classes;

type

TPicPin=record

  UID: Int64;

  Name: string;

  State: boolean;

  Changed: boolean;

  DataType: TRCadDataType;

  Data: string;

end;

var

PicEvents: TPicEvents;

PicUID: Int64;

PicName: string;

InputsCount,

OutputsCount: integer;

Inputs: array[0..15] of TPicPin;

Outputs: array[0..15] of TPicPin;

// system thread

procedure OnPinMessage(Sender: TObject; const User: string; const PinUID: Int64; State: boolean; const DataType: TRCadDataType; const Data: string);

var

idx: integer;

begin

  try

   // translate inputs to outputs

   idx:=(PinUID and $1F)-1;

   if (idx>=0) and (idx<InputsCount) and

      (PinUID=Inputs[idx].UID) then

    begin

     Inputs[idx].State:=State;

     Inputs[idx].DataType:=DataType;

     Inputs[idx].Data:=Data;

     

// Call Maximize Camera function MaximizeCamera(CameraIndex);

// CameraIndex: Index of Camera to call preset; starting form 0

     if Inputs[idx].State then begin

        DebugOut(Format('%s.%s.pin=%d (State=%d Data="%s").',

        [PicName,Inputs[idx].Name,idx,byte(Inputs[idx].State) and 1,

        Inputs[idx].Data]));

        MaximizeCamera(idx);

//        SelectLayout(idx);

     end;                                             

//     

     if (DataType=rcdStr) and (Inputs[idx].Data<>'') then

      Data:=Format('+ PIC Filter + %s',[inputs[idx].Data]);

     if Outputs[idx].UID<>0 then

      SetPinState('',Outputs[idx].UID,Inputs[idx].State,

       Inputs[idx].DataType, Data);

    end;

  except

   DebugOut(ExceptionToString(ExceptionType,ExceptionParam));

  end;  

end;

// system thread

procedure Initialize;

var

idx: integer;

begin

  GetPicUID(PicUID);

  GetPicName(PicName);

  DebugOut(Format('%s Started.',[PicName]));

  GetInputsCount(InputsCount);

  GetOutputsCount(OutputsCount);

  for idx:=InputsCount-1 downto 0 do

   begin

    GetInputUID(idx,Inputs[idx].UID);

    GetPinName(Inputs[idx].UID,Inputs[idx].Name);

    GetPinState(Inputs[idx].UID,Inputs[idx].State);

   end;

  for idx:=OutputsCount-1 downto 0 do

   begin

    GetOutputUID(idx,Outputs[idx].UID);

    GetPinName(Outputs[idx].UID,Outputs[idx].Name);

    GetPinState(Outputs[idx].UID,Outputs[idx].State);

   end;

  PicEvents:=TPicEvents.Create(Self);

  PicEvents.OnPinMessage:=@OnPinMessage;

  SetTextColor(clLime);

end;

// system thread

procedure Finalize;

var

i: integer;

begin

  PicEvents.Free;

  PicEvents:=nil;

  for i:=0 to OutputsCount-1 do

   SetPinState('',Outputs.UID,false,rcdUnknown,'');

  SetTextColor(clSilver);

  DebugOut(Format('%s Stopped.',[PicName]));

end;

// pic thread

procedure sleep(ms: dword);

var

T: Int64;

tms: dword;

begin

  T:=GetUsCount;

  tms:=0;

  while tms<ms do

   begin

    if waitEvent(ms-tms) then  

     begin

      if terminated then

       begin

        DebugOut(Format('%s terminated',[PicName]));

        Finalize();

        halt;

       end;

     end;

    tms:=(GetUsCount-T) div 1000;

   end;  

end;

// pic thread

begin

  synchronize('Initialize');

  while not terminated do sleep(5000);

  synchronize('Finalize');

end.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.