Einzelnen Beitrag anzeigen

MadMax

Registriert seit: 24. Mär 2003
46 Beiträge
 
#1

EinvalidPointer nach 41 Minuten

  Alt 21. Okt 2003, 14:07
Dieses Programm erstellt eine Diagramm aus Betriebsdaten einer SPS.

Das Programm läuft eigentlich ganz gut, leider tritt nach ca. 41 Minuten Laufzeit ein EinvalidPointer ‚Ungültige Zeigeroperation’ Fehler auf.

Finde leider keine Lösung für dieses Problem. Vielleicht habt ihr eine Idee wo der Fehler auftritt.

Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
 dOPCServer1.Active := true;
 dOPCServer1.OPCGroups[0].OPCItems.AddItem('Siemens S7 CP1.Wert.Nummer1');
 dOPCServer1.OPCGroups[0].OPCItems.AddItem('Siemens S7 CP1.Wert.Nummer2');
 dOPCServer1.OPCGroups[0].OPCItems.AddItem('Siemens S7 CP1.Wert.Nummer3');
 dOPCServer1.OPCGroups[0].OPCItems.AddItem('Siemens S7 CP1.Wert.Nummer4');
 dOPCServer1.OPCGroups[0].OPCItems.AddItem('Siemens S7 CP1.Wert.Nummer5');
 dOPCServer1.OPCGroups[0].OPCItems.AddItem('Siemens S7 CP1.Wert.Nummer6');
 dOPCSERVER1.OPCGroups[0].IsSubscribed := true;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
 ReadSPS;
end;

procedure TForm1.ConfigClick(Sender: TObject);
begin
 if Sender = Strungenhinzufrgen1 then begin
    AddTroublePanel.Visible := true;
 end else
 if Sender = Strungenlschen1 then begin
    DelTroublePanel.Visible := true;
 end else
 if Sender = Optionen1 then begin
    OptionPanel.Visible := true;
 end else
 if Sender = BtnCloseAddTrouble then begin
    AddTroublePanel.Visible := false;
 end else
 if Sender = BtnOptionClose then begin
    OptionPanel.Visible := false;
 end else
 if Sender = BtnCloseDelTrouble then begin
    DelTroublePanel.Visible := false;
 end else
  if Sender = BtnCloseChat then begin
    Panel4.Visible := false;
 end else
  if Sender = ffnen1 then begin
    Panel4.Visible := true;
 end else
 if Sender = BtnOpenChart then begin
    RvProject1.Close;
    RvProject1.Open;
    RvProject1.Execute;
 end else
  if Sender = BtnStop then begin
    Timer1.Enabled := false;
 end else
 if Sender = BtnAddTrouble then begin
    form2.SQLcreateNewTrouble(EdTrouble.Text,strtoint(EdTrNumber.Text));
    form2.AllTroubles.Refresh;
 end else
 if Sender = BtnDelTrouble then begin
    if MessageDlg('Wollen Sie die Störung wirklich löschne?',mtWarning,[mbYes,mbNo],0) =mrYes then begin
       Sql.Form2.AllTroubles.Delete;
    end;
 end else
 if Sender = Drucken2 then begin
    //Print Rave
 end;
end;


procedure TForm1.dOPCServer1Datachange(Sender: TObject; ItemList: TdOPCItemList);
begin
  SassionStartandStop;
  TroubleOut;
end;

procedure Tform1.ReadSPS;
begin
  Series1.Add(dOPCServer1.OPCGroups[0].OPCItems[2].value);
  Series2.Add(dOPCServer1.OPCGroups[0].OPCItems[3].value);
  Series3.Add(dOPCServer1.OPCGroups[0].OPCItems[4].value);
  Series4.Add(dOPCServer1.OPCGroups[0].OPCItems[5].value);
end;

procedure TForm1.SassionStartandStop;
begin
  if (dOPCServer1.OPCGroups[0].OPCItems[0].value = 1) then begin
      Timer1.Interval := strtoint(edit3.Text)*1000;
      Timer1.Enabled := true;
      starttime := Time;
      Label14.Caption := FormatDateTime('hh:mm:ss', starttime);
      dOPCServer1.OPCGroups[0].OPCItems[0].WriteSync(0);
    end else
        if (dOPCServer1.OPCGroups[0].OPCItems[0].value = 2) then begin
            Timer1.Enabled := false;
            chart1.SaveToMetafile('diagramm_save\'+FormatDateTime('hh-mm-ss',starttime)+'bis'+FormatDateTime('hh-mm-ss',Time)+'am'+DatetoStr(Date)+'.wmf');
            chart1.SaveToBitmapFile('diagramm_save\'+FormatDateTime('hh-mm-ss',starttime)+'bis'+FormatDateTime('hh-mm-ss',Time)+'am'+DatetoStr(Date)+'.bmp');
            form2.SQLsaveChart(FormatDateTime('yyyy-mm-dd', Date), FormatDateTime('hh:mm:ss', starttime), FormatDateTime('hh:mm:ss', Time));
            Label15.Caption := FormatDateTime('hh:mm:ss', Time);
            dOPCServer1.OPCGroups[0].OPCItems[0].WriteSync(0);
        end;
end;

procedure TForm1.TroubleOut;
begin
 if not(dOPCServer1.OPCGroups[0].OPCItems[1].value = TroubleTemp) then begin
        TroubleTemp := dOPCServer1.OPCGroups[0].OPCItems[1].value;
    if not (dOPCServer1.OPCGroups[0].OPCItems[1].value = 0) then begin
            form2.SQLsaveTroubles(form2.SQLgetTroublebyOPC(dOPCServer1.OPCGroups[0].OPCItems[1].value), FormatDateTime('yyyy-mm-dd', Date), FormatDateTime('hh:mm:ss', Time));
            ListItem := ListView1.Items.Add;
            ListItem.Caption := DbEdit1.Text;
            ListItem.SubItems.Add(FormatDateTime('dd.mm.yyyy', Date));
            ListItem.SubItems.Add(FormatDateTime('hh:mm:ss', Time));
    end;
  end;
end;

procedure TForm1.BtnCleatChartClick(Sender: TObject);
begin
 Chart1.Series[0].Clear;
 Chart1.Series[1].Clear;
 Chart1.Series[2].Clear;
 Chart1.Series[3].Clear;
 ListView1.Clear;
 starttime := 0;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 dOPCServer1.OPCGroups[0].OPCItems.RemoveAll;
 dOPCServer1.Active := false;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 form2.SQLgetStarttime(edit1.Text);
end;

procedure TForm1.Edit1Change(Sender: TObject);
begin
 ComboBox1.Clear;
 edit4.Clear;
 BtnOpenChart.Enabled := false;
 form2.SQLgetStarttime(edit1.Text);
end;

procedure TForm1.ComboBox1Click(Sender: TObject);
begin
 Edit4.Text := form2.SQLgetEndtime(edit1.Text, ComboBox1.Items[ComboBox1.ItemIndex]);
 if not (Edit4.Text = '') then begin
    BtnOpenChart.Enabled := true;
 end;
end;
  Mit Zitat antworten Zitat