Commit 44fce36f authored by Xavier de Blas's avatar Xavier de Blas

Initial revision

parents
# **************************************************************************
# Fichero makefile.
# --------------------------------------------------------------------------
# Licencia GPL. Juan Gonzalez Gomez
# --------------------------------------------------------------------------
#
#***************************************************************************
#---- Compilador de C
CC = gcc
CFLAGS = -Wall
#-- Compilador de C#
MCS = mcs
#-------- Nombres y dependencias de los programas a construir
TEST1= test-platform
LIBSERIAL = libserial.so
LIBSERIAL_DEP = sg-serial.o
DLL_SERIAL = serial
CHRONOJUMP = chronojump
CHRONOJUMP_DEP = chronojump.cs stat.cs someWindows.cs sqlite.cs person.cs jump.cs session.cs
RESOURCES = -resource:glade/chronojump.glade,chronojump.glade
CHRONOJUMP_LIB = -pkg:gtk-sharp -pkg:gnome-sharp -pkg:glade-sharp -r System.Data -r Mono.Data.SqliteClient
#CHRONOJUMP_LIB = -pkg:gtk-sharp -pkg:gnome-sharp -pkg:glade-sharp -r System.Data -r Mono.Data.SqliteClient -r GNU.Gettext
all: $(CHRONOJUMP).exe $(TEST1).exe
#--------------------------
# Reglas
#--------------------------
# ---- Generacion de la libreria libserial
$(LIBSERIAL): $(LIBSERIAL_DEP)
$(CC) -shared -W1,-soname,libserial.so -o $(LIBSERIAL) $(LIBSERIAL_DEP)
clean::
rm -f $(LIBSERIAL) $(LIBSERIAL_DEP)
#----- Crear la libserial.dll
$(DLL_SERIAL).dll: $(LIBSERIAL) $(DLL_SERIAL).cs
$(MCS) -target:library $(DLL_SERIAL).cs -o $(DLL_SERIAL).dll
clean::
rm -f $(DLL_SERIAL).dll
#----- Crear test plaform
$(TEST1).exe: $(TEST1).cs $(DLL_SERIAL).dll
$(MCS) $(TEST1).cs -unsafe -r $(DLL_SERIAL).dll -o $(TEST1).exe
clean::
rm -f $(TEST1).exe
#-------------------------------
# Regla para compilar CHRONOJUMP (C#)
#-------------------------------
$(CHRONOJUMP).exe: $(DLL_SERIAL).dll $(CHRONOJUMP_DEP)
$(MCS) $(CHRONOJUMP_DEP) $(RESOURCES) -unsafe -r $(DLL_SERIAL).dll $(CHRONOJUMP_LIB) -o $(CHRONOJUMP).exe
clean::
rm -f $(CHRONOJUMP).exe
#---------------------------------
#--- Dependencias con ficheros .h
#---------------------------------
sg-serial.o : sg-serial.h
#--------------------------
# REGLAS GENERICAS
#--------------------------
.c.o:
$(CC) $(CFLAGS) -c $<
This diff is collapsed.
This diff is collapsed.
/*
*
* gsalta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* gsalta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using System;
using System.Data;
using Mono.Data.SqliteClient;
public class Jump {
int personID;
int sessionID;
int uniqueID;
string type;
double tv;
double tc;
int fall;
string weight;
string description;
string tvString;
string tcString;
int jumps; //total number of jumps
double time; //time elapsed
string limited; //the teorically values, eleven jumps: "11=J" (time recorded in "time"), 10 seconds: "10=T" (jumps recorded in jumps)
public Jump() {
}
public Jump(int uniqueID, int personID, int sessionID, string type, double tv, double tc, int fall, string weight, string description)
{
this.uniqueID = uniqueID;
this.personID = personID;
this.sessionID = sessionID;
this.type = type;
this.tv = tv;
this.tc = tc;
this.fall = fall;
this.weight = weight;
this.description = description;
}
//RJ
public Jump(int uniqueID, int personID, int sessionID, string type, string tvString, string tcString, int fall, string weight, string description, int jumps, double time, string limited)
{
this.uniqueID = uniqueID;
this.personID = personID;
this.sessionID = sessionID;
this.type = type;
this.tvString = tvString;
this.tcString = tcString;
this.fall = fall;
this.weight = weight;
this.description = description;
this.jumps = jumps;
this.time = time;
this.limited = limited;
}
private double getMax (string values)
{
string [] myStringFull = values.Split(new char[] {'='});
double max = 0;
foreach (string jump in myStringFull) {
if ( Convert.ToDouble(jump) > max ) {
max = Convert.ToDouble(jump);
}
}
return max ;
}
private double getAverage (string jumps)
{
string [] myStringFull = jumps.Split(new char[] {'='});
double myAverage = 0;
double myCount = 0;
foreach (string jump in myStringFull) {
myAverage = myAverage + Convert.ToDouble(jump);
myCount ++;
}
return myAverage / myCount ;
}
public string Type
{
get
{
return type;
}
set
{
type = value;
}
}
public double Tv
{
get
{
return tv;
}
set
{
tv = value;
}
}
public double Tc
{
get
{
return tc;
}
set
{
tc = value;
}
}
public int Fall
{
get
{
return fall;
}
set
{
fall = value;
}
}
public string Weight
{
get
{
return weight;
}
set
{
weight = value;
}
}
public string Description
{
get
{
return description;
}
set
{
description = value;
}
}
public string Limited
{
get {
return limited;
}
}
public int UniqueID
{
get
{
return uniqueID;
}
set
{
uniqueID = value;
}
}
public int SessionID
{
get
{
return sessionID;
}
}
public int PersonID
{
get
{
return personID;
}
}
public string JumperName
{
get
{
return Sqlite.SelectJumperName(personID);
}
}
public double TvMax
{
get
{
return getMax (tvString);
}
}
public double TcMax
{
get
{
return getMax (tcString);
}
}
public double TvAvg
{
get
{
return getAverage (tvString);
}
}
public double TcAvg
{
get
{
return getAverage (tcString);
}
}
~Jump() {}
}
/*
*
* gsalta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* gsalta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using System;
using System.Data;
using System.Text; //StringBuilder
using Mono.Data.SqliteClient;
public class Person {
private int uniqueID;
private string name;
private string dateBorn;
private int height;
private int weight;
//int level; // 0,1 o 2
private string sex; // "M" (male) , "F" (female)
private string description;
private int sessionID;
//suitable when we load a person from the database for being the current Person
public Person(int uniqueID, string name, string sex, string dateBorn, int height, int weight, string description)
{
this.uniqueID = uniqueID;
this.sex = sex;
this.name = name;
this.dateBorn = dateBorn;
this.height = height;
this.weight = weight;
this.description = description;
}
//typical constructor
//public Person(string name, string sex, string dateBorn, string description, int sessionID)
public Person(string name, string sex, string dateBorn, int height, int weight, string description, int sessionID)
{
this.name = name;
this.sex = sex;
this.dateBorn = dateBorn;
this.height = height;
this.weight = weight;
this.description = description;
this.sessionID = sessionID;
name = removeTildeAndColon(name);
description = removeTildeAndColon(description);
//insert in the person table
uniqueID = Sqlite.PersonInsert (name, sex, dateBorn, height, weight, description);
Console.WriteLine(this.ToString());
//insert in the personSession table (fast way of knowing who was in each session)
Sqlite.PersonSessionInsert (uniqueID, sessionID);
}
private string removeTildeAndColon(string myString)
{
StringBuilder myStringBuilder = new StringBuilder(myString);
myStringBuilder.Replace("'", "");
myStringBuilder.Replace(":", "");
return myStringBuilder.ToString();
}
public override string ToString()
{
return "[uniqueID: " + uniqueID + "]" + name + ", " + ", " + sex + ", " + dateBorn + ", " + description;
}
public override bool Equals(object evalString)
{
return this.ToString() == evalString.ToString();
}
public override int GetHashCode()
{
return this.ToString().GetHashCode();
}
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public string Sex
{
get
{
return sex;
}
set
{
sex = value;
}
}
public string DateBorn
{
get
{
return dateBorn;
}
set
{
dateBorn = value;
}
}
public int Height
{
get {
return height;
}
}
public int Weight
{
get {
return weight;
}
}
public string Description
{
get
{
return description;
}
set
{
description = value;
}
}
public int UniqueID
{
get
{
return uniqueID;
}
set
{
uniqueID = value;
}
}
~Person() {}
}
/*
*
* gsalta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* gsalta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using System;
using System.Data;
//using System.Text; //StringBuilder
/// <summary>
/// </summary>
public class Platform {
private bool state; // false (out the platform) , true (inside the platform)
private string lastChange;
private string stream;
public Platform()
{
}
public Initialize()
{
}
public Close()
{
}
public ReadStream()
{
if(stream[1] == "0") { state = false; }
else if (stream[1] == "1") { state = true; }
else {
Console.WriteLine("Erro, state '{0}' non valid", stream[1]);
}
}
public override string ToString()
{
return "State: {0}, lastChange {1}", state.ToString(), lastChange);
}
public bool State
{
get
{
return platform;
}
}
}
/**********************************************/
/* serial.cs Juan Gonzalez Gomez. */
/*--------------------------------------------*/
/* Licencia GPL */
/**********************************************/
/*------------------------------------------------------------------------
$Id$
$Revision$
$Source$
--------------------------------------------------------------------------*/
using System.Runtime.InteropServices;
public class Serial {
//-------------- Importado del modulo serial---------------------
[DllImport("libserial.so",EntryPoint="sg_serial_open")]
public static extern int Open(string disp);
[DllImport("libserial.so",EntryPoint="sg_serial_close")]
public static extern int Close(int fd);
[DllImport("libserial.so",EntryPoint="sg_serial_read")]
public static extern int Read(int serial_fd,out int trama0, out int trama1,
out int trama2, out int trama3);
[DllImport("libserial.so",EntryPoint="sg_serial_flush")]
public static extern int Flush(int fd);
[DllImport("libserial.so",EntryPoint="sg_serial_estado")]
public static extern int Estado(int fd, out int estado);
}
File added
/*
*
* gsalta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* gsalta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
using System;
using System.Data;
using System.Text; //StringBuilder
using Mono.Data.SqliteClient;
using Gtk;
using Glade;
using Gnome;
public class Session {
int uniqueID;
string name;
string place;
string date;
string comments;
//suitable when we load a session from the database for being the current session
public Session(string newUniqueID, string newName, string newPlace, string newDate, string newComments)
{
uniqueID = Convert.ToInt32(newUniqueID);
name = newName;
place = newPlace;
date = newDate;
comments = newComments;
}
//typical constructor
public Session(string newName, string newPlace, string newDate, string newComments)
{
name = newName;
place = newPlace;
date = newDate;
comments = newComments;
name = removeTildeAndColon(name);
place = removeTildeAndColon(place);
comments = removeTildeAndColon(comments);
uniqueID = Sqlite.SessionInsert (name, place, date, comments);
Console.WriteLine(this.ToString());
}
private string removeTildeAndColon(string myString)
{
StringBuilder myStringBuilder = new StringBuilder(myString);
myStringBuilder.Replace("'", "");
myStringBuilder.Replace(":", "");
return myStringBuilder.ToString();
}
public override string ToString()
{
return "[uniqueID: " + uniqueID + "]" + name + ", " + place + ", " + date + ", " + comments;
}
public override bool Equals(object evalString)
{
return this.ToString() == evalString.ToString();
}
public override int GetHashCode()
{
return this.ToString().GetHashCode();
}
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public string Place
{
get
{
return place;
}
set
{
place = value;
}
}
public string Date
{
get
{
return date;
}
set
{
date = value;
}
}
public string Comments
{
get
{
return comments;
}
set
{
comments = value;
}
}
public int UniqueID
{
get
{
return uniqueID;
}
set
{
uniqueID = value;
}
}
~Session() {}
}
/***********************************************/
/* sg-serial.c Juan Gonzalez Gomez. */
/*---------------------------------------------*/
/* Comunicaciones serie para clientes StarGate */
/* Licencia GPL */
/***********************************************/
/*------------------------------------------------------------------------
$Id$
$Revision$
$Source$
--------------------------------------------------------------------------*/
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include "sg-serial.h"
/********************************************/
/* Enviar una cadena por el puerto serie */
/********************************************/
void sg_serial_enviar<