|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
|
Опции темы | Поиск в этой теме | Опции просмотра |
#1
|
|||
|
|||
Помогите перевести текст программы из delphi в с# я красивая блондинка!
Начало проги
Код:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids, ComObj, Math; type TGA = array of array of real; TForm1 = class(TForm) SG: TStringGrid; missCountEdit: TEdit; h1Edit: TEdit; m1Edit: TEdit; h2Edit: TEdit; PeriodEdit: TEdit; m2Edit: TEdit; CalcButton: TButton; kgEdit: TEdit; missCountExpEdit: TEdit; m2pEdit: TEdit; switchTimeEdit: TEdit; procentpEdit: TEdit; Button1: TButton; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; procedure FormCreate(Sender: TObject); procedure CalcButtonClick(Sender: TObject); procedure missCountExpEditEnter(Sender: TObject); procedure missCountEditEnter(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; missCount, AorB, switch, Astate, Bstate, partB, partBperiod, i : integer; h1, m1, h2, m2, m2p, tp, switchTime, procentp, tCont, period, pastPeriod, t, ti, tPrev, kg, tNext, tNextA, tNextB, tRepA, tRepB : real; exp10, fail : boolean; oldEdit : string; A : TGA; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin SG.Cells[0,0] := 'Действие'; SG.Cells[1,0] := 'Текущее время'; SG.Cells[2,0] := 'Переключатель'; SG.Cells[3,0] := 'Состояние А'; SG.Cells[4,0] := 'Состояние В'; SG.Cells[5,0] := 'Время ремонта А'; SG.Cells[6,0] := 'Время ремонта В'; SG.Cells[7,0] := 'Полный отказ'; exp10 := true; end; procedure TForm1.missCountExpEditEnter(Sender: TObject); begin missCountEdit.Text := ''; exp10 := true; end; procedure TForm1.missCountEditEnter(Sender: TObject); begin missCountExpEdit.Text := ''; exp10 := false; end; procedure fillSG (switch, Astate, Bstate : integer; t, tRepA, tRepB : real; var cell0 : string; var SG : TStringGrid; var A : TGA); begin SG.Cells[0, SG.RowCount - 1] := cell0; SG.Cells[1, SG.RowCount - 1] := FloatToStr(t); if switch = 0 then SG.Cells[2, SG.RowCount - 1] := 'A -> B'; if switch = 1 then SG.Cells[2, SG.RowCount - 1] := 'A <- B'; if switch = 2 then SG.Cells[2, SG.RowCount - 1] := 'A'; if switch = 3 then SG.Cells[2, SG.RowCount - 1] := 'B'; if Astate = 0 then SG.Cells[3, SG.RowCount - 1] := 'Отказ'; if Astate = 1 then SG.Cells[3, SG.RowCount - 1] := 'Готов к работе'; if Astate = 2 then SG.Cells[3, SG.RowCount - 1] := 'Задействован'; if Bstate = 0 then SG.Cells[4, SG.RowCount - 1] := 'Отказ'; if Bstate = 1 then SG.Cells[4, SG.RowCount - 1] := 'Готов к работе'; if Bstate = 2 then SG.Cells[4, SG.RowCount - 1] := 'Задействован'; SG.Cells[5, SG.RowCount - 1] := FloatToStr(tRepA); SG.Cells[6, SG.RowCount - 1] := FloatToStr(tRepB); if ((Astate = Bstate) and (Astate = 0)) then SG.Cells[7, SG.RowCount - 1] := 'Полный отказ' else SG.Cells[7, SG.RowCount - 1] := ''; A[0, SG.RowCount - 1] := t; A[1, SG.RowCount - 1] := tRepA; A[2, SG.RowCount - 1] := tRepB; end; function NextPeriod(t, period, pastPeriod : real) : real; begin while t > PastPeriod do PastPeriod := PastPeriod + period; NextPeriod := PastPeriod; end; function NextEvent(var h1, m1, h2, m2, m2p, switchTime, procentp, tCont, period, pastPeriod, t, ti, tPrev, kg, tNext, tRepA, tRepB, tp : real; var AorB, switch, Astate, Bstate, partB, partBperiod, i : integer) : string; begin if switch = 2 then // Переключатель на А --------------------------------------------------------------------------- begin if Astate = 2 then //А задействован begin if Bstate = 1 then //А задействован, В готов begin if AorB = 0 then //Ломается А (1.1) begin tPrev := t; t := t + tNext; Astate := 0; switch := 0; tp := switchTime; tRepA := (1 / m1) * ln(Random(100) + 1); tRepB := 0; tNext :=0; NextEvent := 'Отказ А'; ti := ti + (t - tPrev); i := i + 1; end else begin if AorB = 1 then //ломается В (1.3) begin tPrev := t; t := t + tNext; Bstate := 0; if partB <= partBperiod then tRepB := ((1 / m2p) * ln(Random(100) + 1)) + (NextPeriod(t, period, pastPeriod) - t) else tRepB := (1 / m2) * ln(Random(100) + 1); tNext := 0; NextEvent := 'Отказ В'; ti := ti + (t - tPrev); i := i + 1; end else //Ломаются оба (1.2) begin tPrev := t; t := t + tNext; Astate := 0; Bstate := 0; tRepA := (1 / m1) * ln(Random(100) + 1); if partB <= partBperiod then tRepB := ((1 / m2p) * ln(Random(100) + 1)) + (NextPeriod(t, period, pastPeriod) - tPrev) else tRepB := (1 / m2) * ln(Random(100) + 1); tNext := 0; NextEvent := 'Отказ А и В'; ti := ti + (t - tPrev); i := i + 1; end; end; end else //А задействован, В отказал begin if tNext < tRepB then // Полный отказ (2.1) begin tPrev := t; t := t + tNext; Astate := 0; tRepA := (1 / m1) * ln(Random(100) + 1); tRepB := tRepB - tNext; tNext := 0; NextEvent := 'Отказ А'; ti := ti + (t - tPrev); i := i + 1; end else begin if tNext > tRepB then //А задействован, В готов (2.2) begin tPrev := t; t := t + tRepB; Bstate := 1; tNext := tNext - tRepB; tRepB := 0; NextEvent := 'Восстановление В'; ti := ti + (t - tPrev); end else //А отказал, В готов begin tPrev := t; t := t + tRepB; Astate := 0; Bstate := 1; switch := 1; tRepA := (1 / m1) * ln(Random(100) + 1); tRepB := 0; tNext := 0; NextEvent := 'Отказ А, Восстановление В'; ti := ti + (t - tPrev); i := i + 1; end; end; end; end else //Полный отказ begin if tRepA < tRepB then //А задействован, Б сломан (3.1) begin tPrev := t; t := t + tRepA; Astate := 2; tRepB := tRepB - tRepA; tRepA := 0; NextEvent := 'Восстановление А'; end else begin if tRepA > tRepB then //А сломан, Б готов (3.2) begin tPrev := t; t := t + tRepB; Bstate := 1; switch := 0; tp := switchTime; tRepA := tRepA - tRepB; tRepB := 0; NextEvent := 'Восстановление В'; end else //А задействован, Б готов begin tPrev := t; t := t + tRepB; Astate := 2; Bstate := 1; tRepA := 0; tRepB := 0; NextEvent := 'Восстановление А и В'; end; end; end; end else begin if switch = 3 then // Переключатель на В----------------------------------------------------------------------------- if Bstate = 2 then begin //tRepA (4.2) if tRepA < tNext then begin tPrev := t; t := t + tRepA; Astate := 1; Bstate := 1; switch := 1; tp := switchTime; tNext := tNext - tRepA; tRepA := 0; NextEvent := 'Восстановление А'; ti := ti + (t - tPrev); end Последний раз редактировалось Admin, 04.05.2012 в 20:35. |
#2
|
|||
|
|||
Программа в 7 раз длиннее((( Горит диплом!!
|
#3
|
||||
|
||||
Индусокод детектед...
Думаю, такое согласятся переводить только в разделе работа и за немалые деньги, если вообще согласятся. jmp $ ; Happy End! The Cake Is A Lie. |
#4
|
|||
|
|||
а немалые это сколько? может есть знакомые?
|
#5
|
||||
|
||||
Цитата:
Некоторые программисты настолько ленивы, что сразу пишут рабочий код. Если вас наказали ни за что - радуйтесь: вы ни в чем не виноваты. |
#6
|
|||
|
|||
Цитата:
|
#7
|
||||
|
||||
Цитата:
|