public void repaint() { motor.paint(g, 299, 82); if (speedup) { motor.paint(g, 299, 82); } ileft.check(xPos, width); iright.check(xPos, width); ileft.paint(g); iright.paint(g); if (ios != null) { //Console.WriteLine("ios!=null!"); if (ileft.getState()) { ios.setBoolean(4, 4, true); } else { ios.setBoolean(4, 4, false); } if (iright.getState()) { ios.setBoolean(4, 5, true); } else { ios.setBoolean(4, 5, false); } if (tig) { ios.setBoolean(4, 6, true); } else { ios.setBoolean(4, 6, false); } } if (motor.isMoving() && motor.isok()) { tigCounter--; if (tigCounter < 0) { tig = !tig; if (speedup) { tigCounter = 1; } else { tigCounter = 2; } } } imove.setState(tig); imove.paint(g); }
private void verbinden_Click(object sender, EventArgs e) { if (ios != null && ios.isConnected()) { ios.disconnect(); verbinden.Text = "Verbinden"; status.Text = "Verbindung getrennt"; this.statusStrip1.BackColor = Color.White; verbinden.BackColor = Color.PaleGreen; modell.stop(); ghost(true); } else { if (modbus.Checked) { verbinden.Enabled = false; this.statusStrip1.BackColor = Color.Yellow; status.Text = "Try to connect to Modbus Server!"; this.Update(); ios = new IOServerModbus(ipadr.Text, Int32.Parse(ipPort.Text)); ios.setListener(this); bool res = ios.connect(); verbinden.Enabled = true; if (res) { ios.add(plc_h1); ios.add(plc_h2); ios.add(plc_h3); ios.add(plc_h4); ios.setBoolean(4, 0, s0Pressed); ios.setBoolean(4, 3, handSteuerung); modell.setIOServer(ios); verbinden.Text = "Trennen"; status.Text = "Verbunden!"; this.statusStrip1.BackColor = Color.Green; verbinden.BackColor = Color.Red; ghost(false); modell.cont(); tabControl1.SelectedIndex = 0; } else { status.Text = "Verbindung fehlgeschlagen!"; this.statusStrip1.BackColor = Color.Red; } } else if (codesys.Checked) { verbinden.Enabled = false; this.statusStrip1.BackColor = Color.Yellow; status.Text = "Try to connect to CoDeSys DDE Server!"; this.Update(); ios = new IOServerDDECodeSys(new DdeClient("CODESYS", codesysPfad.Text)); ios.setListener(this); bool res = ios.connect(); verbinden.Enabled = true; if (res) { ios.add(plc_h1); ios.add(plc_h2); ios.add(plc_h3); ios.add(plc_h4); ios.setBoolean(4, 2, s0Pressed); ios.setBoolean(4, 5, handSteuerung); modell.setIOServer(ios); verbinden.Text = "Trennen"; status.Text = "Verbunden!"; this.statusStrip1.BackColor = Color.Green; verbinden.BackColor = Color.Red; ghost(false); //modell.cont(); tabControl1.SelectedIndex = 0; } else { status.Text = "Verbindung fehlgeschlagen!"; this.statusStrip1.BackColor = Color.Red; } } else if (fluidsim.Checked) { verbinden.Enabled = false; this.statusStrip1.BackColor = Color.Yellow; status.Text = "Try to connect to FluidSim DDE Server!"; this.Update(); ios = new IOServerDDEFluidSim(new DdeClient(fluidsimServer.Text, fluidsimTopic.Text), fludsimOutMarke.Text, fluidsimInMarke.Text); ios.setListener(this); bool res = ios.connect(); verbinden.Enabled = true; if (res) { ios.add(plc_h1); ios.add(plc_h2); ios.add(plc_h3); ios.add(plc_h4); ios.setBoolean(4, 2, s0Pressed); ios.setBoolean(4, 5, handSteuerung); modell.setIOServer(ios); verbinden.Text = "Trennen"; status.Text = "Verbunden!"; this.statusStrip1.BackColor = Color.Green; verbinden.BackColor = Color.Red; ghost(false); //modell.cont(); tabControl1.SelectedIndex = 0; } else { status.Text = "Verbindung fehlgeschlagen!"; this.statusStrip1.BackColor = Color.Red; } } else { /* * status.Text = "Try to connect to S7 via Profinet"; * verbinden.Enabled = false; * this.statusStrip1.BackColor = Color.Yellow; * * axS7TCP1.CP_IP = ipadr.Text; * axS7TCP1.Tzeit = 80000; * axS7TCP1.TsapE = "1.0"; * if (comboBox1.Text == "S7-300") * { * axS7TCP1.TsapF = "3.2"; * } * else * { * axS7TCP1.TsapF = "3.3"; * } * status.Text = "verbinde..."; * ios = new IOServerS7TCP(axS7TCP1); * ios.setListener(this); * ios.add(plc_h1); * ios.add(plc_h2); * ios.add(plc_h3); * ios.add(plc_h4); * ios.setBoolean(4, 2, s0Pressed); * ios.setBoolean(4, 5, handSteuerung); * * res = ios.connect(); * verbinden.Enabled = true; * if (res) * { * modell.setIOServer(ios); * verbinden.Text = "Trennen"; * status.Text = "Verbunden!"; * this.statusStrip1.BackColor = Color.Green; * * verbinden.BackColor = Color.Red; * modell.cont(); * ghost(false); * tabControl1.SelectedIndex = 0; * } * else * { * status.Text = "Verbindung fehlgeschlagen!"; * verbinden.BackColor = Color.PaleGreen; * this.statusStrip1.BackColor = Color.Red; * * } */ } } }
private void s0_MouseDown(object sender, MouseEventArgs e) { if (ios != null) { ios.setBoolean(4, 0, true); } s0Pressed = true; }