A problem with calling a method in another method
So here it is:
A method that works well, when i click manually on the button(It opens the door):procedure TForm1.Button3Click(Sender: TObject);
begin
try
Screen.Cursor := crHourGlass;
try
intf.ExecuteControllerCommand(162, 1); //<--- THIS IS THE METHOD IM TALKING ABOUT
finally
Beep();
Screen.Cursor := crDefault;
end;
except
on e: Exception do
HandleException(e);
end;
end;
However, when I want to call the above mentioned method in some procedure event a exception is thrown(its about the possibility of door opening - it doesn't open the door):
procedure TForm1.HandlerOnMonitoringEvent(ASender: TObject;
date: TDateTime; time: TDateTime; networkID: Integer;
readerID: Integer; userID: Integer; groupID: Integer;
eventCode: Integer; zoneID: Integer; TandAID: Integer;
const strEvent: WideString; const strAccessPoint: WideString;
const strUserSource: WideString; const strGroup: WideString;
const strNetwork: WideString; const strZone: WideString;
开发者_StackOverflow中文版 const strTandAMode: WideString);
begin
ListBox1.Items.Add(DateToStr(date) + ' ' + TimeToStr(time) + '; ' + strEvent +
'; ' + strAccessPoint + '; ' + strUserSource + '; ' + strGroup + '; ' + strNetwork +
'; ' + strZone + '; ' + strTandAMode);
try
Screen.Cursor := crHourGlass;
try
intf.ExecuteControllerCommand(162, 1); //<--- THIS IS THE METHOD
finally
Beep();
Screen.Cursor := crDefault;
end;
except
on e: Exception do
HandleException(e);
end;
end;
Moreover, when I try to call the button click from procedure event(in this procedure above):
Form1.Button3Click(Button3);
it throws the same exception! I repeat: with manually clicked button everything is alright. What is the problem?!
intf
is an instance of IPRMasterAutomation
class. Its initialized ALWAYS(100% sure) in another procedure as follows: intf := CoPRMasterAutomation.Create()
.
intf
is connected to prma
. prma
is an instance of TPRMasterAutomation
. The procedure event(after prma initialization is declared like this: prma.OnMonitoringEvent := HandlerOnMonitoringEvent
(event from the first post);
then connnection: prma.ConnectTo(intf)
;
精彩评论