Home

Portfolio_header

leftarrow_icon
Portfolio - Railstutorial

Railstutorial

HTML/CSS - Photoshop - Fireworks
Details

Portfolio - Programmieren Praktikum

Programmieren Praktikum

HTML/CSS - Photoshop
Details

Portfolio - GregorPanek

GregorPanek

Ruby on Rails - HTML/CSS - MYSQL - Javascript - Photoshop
Details

Portfolio - WBT

WBT

HTML/CSS - PHP - Flash - Mysql - Photoshop
Details

Portfolio - Sunlight

Sunlight

Illustrator
Details

Portfolio-Newsticker

Newsticker (Praxissemester)

Javascript - Photoshop - PHP - MYSQL - CMS - Flash - SEO
Details

Portfolio-Rizo

Rizo (Projektstudium)

Java - XML - Flex - Photoshop
Details

Portfolio-Black-Media-Solutions

Black Media Solutions

HTML/CSS - Photoshop
Details

rightarrow_icon

Twitter_header

Follow_me

Rizo – Morath Systems – Projektstudium

Im vierten und fünften Semester fand in unserem Studiengang das sogenannte Projektstudium statt. In dieser Zeit realisierten wir in einer 6er Gruppen ein Projekt für eine externe Firma namens Morath Systems. Dies ist ein Mittelständisches Unternehmen mit Sitz in VS-Schwenningen.

Ziel des Projekts

Die Firma stellt Arbeitsplätze zur Montage von Bauteilen her. Die Montage von Baugruppen und Bautteilen umfasst immer viele Arbeitsschritte. Neue Mitarbeiter müssen immer von einem weiteren Mitarbeiter, meistens einen ganzen Tag lang geschult werden. Mithilfe eines Touchscreens sollte dagegen Abhilfe geschaffen werden. Der Touchscreen hängt am Arbeitsplatz, über den die neuen Mitarbeiter durch die verschiedenen Arbeitsschritte visuell, auditiv und textbasiert geleitet werden.

Unsere Aufgabe bestand darin die Software für den Touchscreen herzustellen. Wir entschieden uns das Programm Server-Client basiert aufzubauen. Auf dem Zentralen Server läuft eine Java Anwendung, die eine Verbindung zur Datenbank herstellt und den Client mit den benötigten Inhalten versorgt. Der Client basiert auf Adobe Flex, das sich an Flash anlehnt. Dadurch konnten der Client alle möglichen Formate in einem .swf Container darstellen.

Umsetzung

Im ersten Semester haben wir uns Hauptsächlich damit beschäftigt die Logik hinter dem Programm auf Papier festzuhalten und ein Datenbankschema zu erstellen (siehe Bild). Im zweiten Semester begann dann die Programmierung. Ich war für den Bereich Java zuständig, hab somit das Backend bereitgestellt. Zu meinen Aufgaben gehört es eine Verbindung zwischen der Datenbank und Flex herstellen. Die Kommunikation zwischen Flex und Java wurde mittels eines XML Protokolls realisiert. Die Datenbank würde über eine Java interne Schnittstelle angesprochen. Eine weitere Aufgabe bestand darin, mithilfe von Java Native eine Comm Port Schnittstelle anzusprechen und daraufhin eine rote Kontrollleuchte bei einem Fehler aufblinken zu lassen.

Folgend ein Auszug aus den wichtigsten Java Klassen:

//SimpleServer.java

package rizo;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class SimpleServer {

    public static final int SOCKET_PORT = 5974;
    public static boolean runServer = true;
    public static ServerSocket socket;

    public static void main(String[] args) {
        Socket clientSocket;
        int nextAvailableClientId = 0;

        try {
            socket = new ServerSocket(SOCKET_PORT);

            while (runServer) {
                clientSocket = socket.accept();
                nextAvailableClientId++;
                new ClientThread(clientSocket, nextAvailableClientId).start();
                
            }
        } catch (IOException ioe) {
            if (runServer) {
                System.err.println(ioe.getMessage());
                ioe.printStackTrace();
                System.exit(1);
            } else {
            }
        }
    }
}

//ClientThread.java

package rizo;

import java.io.*;
import java.net.Socket;
import org.xml.sax.InputSource;

/*
 * This Class starts on a Connection from Flash a new Thread and waits
 * for Incoming ByteStreams from Flash
 *
 */
public class ClientThread extends Thread {

    private boolean runThread = true;
    private Socket socket;
    private int clientId;
    private BufferedReader in = null;
    private PrintWriter out = null;

    public ClientThread(Socket socket, int clientId) {
        this.socket = socket;
        this.clientId = clientId;
    }

    public void run() {
        System.out.println("Client " + clientId + " verbunden...");

        try {
            in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
            out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF-8"));

            while (this.runThread) {
                StringBuffer pro = new StringBuffer();
                int c;


                /*
                 * Deletes all whitespaces and zero bytes from the Incoming
                 * Stream
                 */
                while ((c = in.read()) != 0x00 && c != -1) {
                    if (c != 0x0D && c != 0x0A) {
                        pro.append((char) c);
                    }
                }

                if (c == -1) {
                    this.runThread = false;
                }

                System.out.println(pro.toString());



                StringReader inStream = new StringReader(pro.toString());
                InputSource inSource = new InputSource(inStream);

                /*
                 * When the InputStream is Complete and Clean then here we
                 * Start a new Thread which begins to parse the XML Stream
                 */
                if (this.runThread) {

                    new parsThread(out, inSource, this.socket).start();

                }



            }


        } catch (IOException e) {
            this.runThread = false;
            System.out.println("Thread killed");
        }
    }
}

//ParsThread.java

package rizo;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.jdom.Document;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

/*
 * Class which starts a new Thread and parses the InputStream which comes from
 * Flash and send the data to a handler
 */

public class parsThread extends Thread {
	private PrintWriter out;
	private InputSource inSource;
    private Socket socket;


    public parsThread(){}

	public parsThread(PrintWriter out, InputSource in, Socket socket){
		this.out = out;
		this.inSource = in;
        this.socket = socket;
	}



    /*
     * here begins the Thread where the SAX parser starts to parse the Inputstream
     */
	public void run(){
		SAXParserFactory factory = SAXParserFactory.newInstance();
		try {
			SAXParser saxParser = factory.newSAXParser();
			Document doc = new SAXBuilder().build(inSource);

             Class clazz = Class.forName("rizo.xmlfunctions");

             Class[] parameterTypes = new Class[]{ PrintWriter.class,Document.class,Socket.class };
              Method method = clazz.getMethod( doc.getRootElement().getChild("method").getAttribute("name").getValue(), parameterTypes );
              Object[] arguments = new Object[]{ this.out, doc, this.socket};
              Object instance = clazz.newInstance();
              method.invoke( instance, arguments );

             

        }catch (Exception e){
            e.printStackTrace();
        }
           }
}

//SwitchLightsServerSide.java

package rizo;

import java.io.OutputStreamWriter;
import javax.comm.CommPortIdentifier;
import javax.comm.SerialPort;


public class switchLightsServerSide{
    private CommPortIdentifier cpi;
    private SerialPort com3;
    private OutputStreamWriter out;


    public switchLightsServerSide()throws Exception{
    this.cpi = CommPortIdentifier.getPortIdentifier("COM3");
    this.com3 = (SerialPort)cpi.open("COM3",9600);
    this.out = new OutputStreamWriter(com3.getOutputStream());

    }


public void switchredon()throws Exception{
    this.out.write("WR 00 50 01 01\r");
    this.out.flush();
    this.out.close();
   

}

public void turnoffred()throws Exception{
    this.out.write("WR 00 01 01 01\r");
    this.out.flush();
    this.out.close();
}
    

}

//Messages.java

package rizo;

import java.sql.PreparedStatement;
import java.sql.ResultSet;


/*
 *class to handle messages and product information data
 */

public class messages {

    private database da = new database();


    public messages() {
    }

    /*
     * with this function we get all complaints, if you wish to get only the headlines
     * then you have to set the Boolean attribute "all" to false, else if you want to have
     * all complaints with full content then set the Boolean attribute "all" to true
     */
    public String getcomplaints(String pid) throws Exception {

        String ret = ""; // return variable lokal
        PreparedStatement ps = da.open().prepareStatement("SELECT * FROM products_workingsteps_parts_led pwpl LEFT JOIN parts p ON (p.id = pwpl.parts_id) LEFT JOIN complaints c ON (c.part_id = p.id) WHERE pwpl.products_id = ?");
        ps.setString(1, pid);
        ResultSet rs = da.getdata(ps);
        while (rs.next()) {
      
                ret += "<complaint title=\"" + rs.getString("c.title") + "\" id=\"" + rs.getInt("c.id") + "\" />";
          
        }
        da.close();
        return ret;

    }


    public String getcomplaint(String cid) throws Exception {

        String ret = ""; // return variable lokal
        PreparedStatement ps = da.open().prepareStatement("SELECT * FROM complaints WHERE id = ?");
        ps.setString(1, cid);
        ResultSet rs = da.getdata(ps);
        while (rs.next()) {
           
                ret += "<complaint title=\"" + rs.getString("title") + "\" id=\"" + rs.getInt("id") + "\" description=\"" + rs.getString("description") + "\" picture=\"" + rs.getString("picture") + "\" />";

        }
        da.close();
        return ret;

    }



    /*
     * function to get all worker specifications for the dashboard but only the headlines
     */
    public String getworkspecifications() throws Exception {
        String ret = ""; // return value
        PreparedStatement ps = da.open().prepareStatement("SELECT * FROM workspecifications ORDER BY id DESC");
        ResultSet rs = da.getdata(ps);
        while (rs.next()) {
            ret += "<workspecification title=\"" + rs.getString("title") + "\" id=\"" + rs.getInt("id") + "\" />";
        }
        da.close();
        return ret;
    }


    /*
     * function to get all uvvs for the dashboard, but only the headlines
     */
    public String getuvvs(String pid) throws Exception {

        String ret = ""; // return value;
        PreparedStatement ps = da.open().prepareStatement("SELECT * FROM products p LEFT JOIN products_uvvs pv ON (p.id = pv.product_id) LEFT JOIN uvvs v ON (pv.uvv_id = v.id) WHERE p.id =? ORDER BY v.id DESC;");
        ps.setString(1, pid);
        ResultSet rs = da.getdata(ps);
        while (rs.next()) {
            ret += "<uvv title=\"" + rs.getString("title") + "\" id=\"" + rs.getInt("v.id") + "\" />";
        }
        da.close();
        return ret;

    }

    /*
     * function to get all headlines for the dashboard
     */
    public String getnews() throws Exception {

        String ret = "";
        PreparedStatement ps = da.open().prepareStatement("SELECT * FROM news ORDER BY post_date DESC");
        ResultSet rs = da.getdata(ps);
        while (rs.next()) {
            ret += "<newsdata title=\"" + rs.getString("title") + "\" id=\"" + rs.getInt("id") + "\" />";
        }
        da.close();
        return ret;

    }

    /*
     *function to get the specific news, not all only once but with all details
     */
    public String getnew(String nid) throws Exception {
        String ret = "";
        PreparedStatement ps = da.open().prepareStatement("SELECT * FROM news WHERE id= ?");
        ps.setString(1, nid);

        ResultSet rs = da.getdata(ps);


        while (rs.next()) {
            ret += "<newsdata id=\"" + rs.getInt("id") + "\" title=\"" + rs.getString("title") + "\" content=\"" + rs.getString("content") + "\" post_date=\"" + rs.getDate("post_date") + " " + rs.getTime("post_date") + "\" />";
        }

        da.close();
        return ret;
    }

    /*
     * function to get only the specific uvv and not all with all details
     */
    public String getuvv(String uid) throws Exception {
        String ret = "";
        PreparedStatement ps = da.open().prepareStatement("SELECT * FROM uvvs WHERE id = ?");
        ps.setString(1, uid);

        ResultSet rs = da.getdata(ps);

        while (rs.next()) {
            ret += "<uvv id=\"" + rs.getInt("id") + "\" title=\""+ rs.getString("title") + "\" content=\"" + rs.getString("content") + "\" />";
        }
        da.close();
        return ret;
    }

    /*
     * function to get all details which are assigned to the workspecifications
     */
    public String getworkspecification(String wsid) throws Exception {

        String ret = "";
        PreparedStatement ps = da.open().prepareStatement("SELECT * FROM workspecifications WHERE id = ?");
        ps.setString(1, wsid);
        ResultSet rs = da.getdata(ps);
        while (rs.next()) {
            ret += "<workspecification id=\"" + rs.getInt("id") + "\" title=\"" + rs.getString("title") + "\" content=\"" + rs.getString("content") + "\" />";
        }
        da.close();
        return ret;


    }

    /*
     *This method is used to get all the uvvs, which the user, who is currently logged in,
     *has not yet confirmed.
     */
    public String getUncheckedUvvs(String workerId, String productId) throws Exception {
        String ret = "";
        PreparedStatement ps = da.open().prepareStatement("Select uw.uvv_id from workers w left join uvvs_workers uw on (w.id = uw.worker_id) where w.id=?");
        ps.setString(1, workerId);
        ResultSet rs = da.getdata(ps);

        rs.beforeFirst();
        rs.next();
        rs.getString("uvv_id");
        if (rs.wasNull()) {

            PreparedStatement ps0 = da.open().prepareStatement("Select u.id, u.title, u.content from uvvs u left join products_uvvs pu on (u.id = pu.uvv_id) left join products p on (p.id = pu.product_id) where p.id=?");
            ps0.setString(1, productId);
            rs = da.getdata(ps0);
        } else {
            PreparedStatement ps1 = da.open().prepareStatement("Select u.id, u.title, u.content from uvvs u left join products_uvvs pu on (u.id = pu.uvv_id) left join products p on (p.id = pu.product_id) where p.id=? && pu.uvv_id not in (Select uw.uvv_id from workers w left join uvvs_workers uw on (w.id = uw.worker_id) where w.id=?)");
            ps1.setString(1, productId);
            ps1.setString(2, workerId);
            rs = da.getdata(ps1);
        }

        while (rs.next()) {
            ret += "<newsdata type=\"uvv\" title=\"" + rs.getString("title") + "\" content=\"" + rs.getString("content") + "\" id=\"" + rs.getInt("id") + "\"/>";
        }
        da.close();
        return ret;

    }

    /*
     *This method is used to get all the News, which the user, who is currently logged in,
     *has not yet confirmed.
     */
    public String getUncheckedNews(String workerId) throws Exception {

        String ret = "";
        PreparedStatement ps = da.open().prepareStatement("Select * from news where news.id not in (Select n.id from news n left join news_workers nw on (n.id = nw.news_id) where nw.worker_id=?)");
        ps.setString(1, workerId);
        ResultSet rs = da.getdata(ps);
        while (rs.next()) {
            ret += "<newsdata type=\"newsdata\" title=\"" + rs.getString("title") + "\" content=\"" + rs.getString("content") + "\" id=\"" + rs.getInt("id") + "\" post_date=\"" + String.valueOf(rs.getTimestamp("post_date")) + "\"/>";
        }
        da.close();
        return ret;


    }

    /*
     *This method is used to get all the workspecifications, which the user, who is currently logged in,
     *has not yet confirmed.
     */
    public String getUncheckedWorkspecifications(String workerId) throws Exception {

        String ret = "";
        PreparedStatement ps = da.open().prepareStatement("Select * from workspecifications wo where wo.id not in (Select w.id from workspecifications w left join workers_workspecifications ww on (w.id = ww.workspecification_id) where ww.worker_id=?)");
        ps.setString(1, workerId);
        ResultSet rs = da.getdata(ps);
        while (rs.next()) {
            ret += "<newsdata type=\"workspecification\" title=\"" + rs.getString("title") + "\" content=\"" + rs.getString("content") + "\" id=\"" + rs.getInt("id") + "\"/>";
        }
        da.close();
        return ret;

    }

    public void readUvvs(String uvvId, String workerId) throws Exception {
        da.open();
        da.insert("Insert into uvvs_workers(uvv_id,worker_id) values('" + uvvId + "','" + workerId + "');");
        da.close();

    }

    public void readNews(String newsId, String workerId) throws Exception {
        da.open();
        //System.out.println("Insert into news_workers('news_id','worker_id') values('" + newsId + "','" + workerId + "');");
        da.insert("Insert into news_workers(news_id,worker_id) values('" + newsId + "','" + workerId + "');");
        da.close();

    }

    public void readWorkspecifications(String workspId, String workerId) throws Exception {
        da.open();
        da.insert("Insert into workers_workspecifications(workspecification_id,worker_id) values('" + workspId + "','" + workerId + "');");
        da.close();

    }


    public boolean delete_safety(String workerId)throws Exception{
       da.open();
       da.delete("DELETE FROM uvvs_workers WHERE worker_id ="+workerId);
       da.delete("DELETE FROM workers_workspecifications WHERE worker_id="+workerId);
       da.close();
       
       return true;
    }


}