arrows have orientations
This commit is contained in:
parent
349b851f48
commit
8c48856994
3
Makefile
3
Makefile
|
@ -26,7 +26,8 @@ INCDIR=include
|
||||||
SRCDIR=src
|
SRCDIR=src
|
||||||
DEBDIR=debian
|
DEBDIR=debian
|
||||||
SERVEROBJ= $(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localworker.o \
|
SERVEROBJ= $(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localworker.o \
|
||||||
$(BINDIR)/centers.o $(BINDIR)/cmds.o $(BINDIR)/main.o
|
$(BINDIR)/centers.o $(BINDIR)/cmds.o $(BINDIR)/model.o \
|
||||||
|
$(BINDIR)/main.o
|
||||||
CLIOBJ= $(BINDIR)/cli.o
|
CLIOBJ= $(BINDIR)/cli.o
|
||||||
|
|
||||||
.DEFAULT_GOAL:= all
|
.DEFAULT_GOAL:= all
|
||||||
|
|
|
@ -40,7 +40,7 @@ struct {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int z;
|
int z;
|
||||||
int o;
|
int siteId;
|
||||||
} typedef Arrow_t;
|
} typedef Arrow_t;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -51,7 +51,7 @@ struct {
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
char *label;
|
char *label;
|
||||||
int arrowId;
|
int narrow;
|
||||||
} typedef Site_t;
|
} typedef Site_t;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -119,8 +119,20 @@ struct {
|
||||||
//
|
//
|
||||||
// Server
|
// Server
|
||||||
//
|
//
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
pthread_t *id;
|
pthread_t *id;
|
||||||
bool pleaseStop;
|
bool pleaseStop;
|
||||||
} typedef Server_t;
|
} typedef Server_t;
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
//
|
||||||
|
// Model
|
||||||
|
//
|
||||||
|
struct {
|
||||||
|
int id;
|
||||||
|
int space_xmax;
|
||||||
|
int space_ymax;
|
||||||
|
int space_zmax;
|
||||||
|
int siteNumber;
|
||||||
|
} typedef Model_t;
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
//=-------------------------------------------------------------------------=//
|
||||||
|
// Model definitions //
|
||||||
|
// //
|
||||||
|
// Copyright © 2021 The Gem-graph Project //
|
||||||
|
// //
|
||||||
|
// This file is part of gem-graph. //
|
||||||
|
// //
|
||||||
|
// This program is free software: you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU Affero General Public License as //
|
||||||
|
// published by the Free Software Foundation, either version 3 of the //
|
||||||
|
// License, or (at your option) any later version. //
|
||||||
|
// //
|
||||||
|
// This program 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 Affero General Public License for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU Affero General Public License //
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||||
|
//=-------------------------------------------------------------------------=//
|
||||||
|
|
||||||
|
#ifndef BASE_H
|
||||||
|
#include "../include/base.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void ModelPrepareSpace(Space_t *globalDrawingSpace, Model_t *model);
|
20
src/cmds.c
20
src/cmds.c
|
@ -21,8 +21,10 @@
|
||||||
|
|
||||||
#include "../include/base.h"
|
#include "../include/base.h"
|
||||||
#include "../include/scheduler.h"
|
#include "../include/scheduler.h"
|
||||||
|
#include "../include/model.h"
|
||||||
|
|
||||||
#define ARROW_NUMBER 6
|
#define ARROW_NUMBER 6
|
||||||
|
#define SITE_NUMBER 2
|
||||||
#define MAX_CYCLES 10
|
#define MAX_CYCLES 10
|
||||||
#define MAX_THREAD 0
|
#define MAX_THREAD 0
|
||||||
#define XMAX 30
|
#define XMAX 30
|
||||||
|
@ -35,25 +37,21 @@
|
||||||
void *launchScheduler(void *args)
|
void *launchScheduler(void *args)
|
||||||
{
|
{
|
||||||
Scheduler_t *scheduler0;
|
Scheduler_t *scheduler0;
|
||||||
|
Model_t *model0;
|
||||||
|
|
||||||
//
|
|
||||||
// Creating structure for the Scheduler
|
// Creating structure for the Scheduler
|
||||||
//
|
|
||||||
scheduler0 = (Scheduler_t*) calloc(1, sizeof(Scheduler_t));
|
scheduler0 = (Scheduler_t*) calloc(1, sizeof(Scheduler_t));
|
||||||
|
|
||||||
scheduler0->globalDrawingSpace =
|
scheduler0->globalDrawingSpace =
|
||||||
(Space_t*) calloc(1, sizeof(Space_t));
|
(Space_t*) calloc(1, sizeof(Space_t));
|
||||||
scheduler0->globalDrawingSpace->space =
|
|
||||||
(SpaceUnit_t*) calloc(SPACE_SIZE, sizeof(SpaceUnit_t));
|
// Creating structure for the model
|
||||||
scheduler0->globalDrawingSpace->size = SPACE_SIZE;
|
model0 = (Model_t*) calloc(1, sizeof(Model_t));
|
||||||
scheduler0->globalDrawingSpace->xmax = SPACE_SIZE;
|
|
||||||
scheduler0->globalDrawingSpace->ymax = SPACE_SIZE;
|
// Preparing global drawing space
|
||||||
scheduler0->globalDrawingSpace->zmax = SPACE_SIZE;
|
ModelPrepareSpace(scheduler0->globalDrawingSpace, model0);
|
||||||
|
|
||||||
scheduler0->arrowList = (ArrowArray_t*) calloc(1, sizeof(ArrowArray_t));
|
scheduler0->arrowList = (ArrowArray_t*) calloc(1, sizeof(ArrowArray_t));
|
||||||
scheduler0->arrowList->array =
|
|
||||||
(Arrow_t*) calloc(ARROW_NUMBER, sizeof(Arrow_t));
|
|
||||||
scheduler0->arrowList->size = ARROW_NUMBER;
|
|
||||||
|
|
||||||
printLog("Populating a random arrow list...\n");
|
printLog("Populating a random arrow list...\n");
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
//=-------------------------------------------------------------------------=//
|
||||||
|
// Model management module //
|
||||||
|
// //
|
||||||
|
// Copyright © 2021 The Gem-graph Project //
|
||||||
|
// //
|
||||||
|
// This file is part of gem-graph. //
|
||||||
|
// //
|
||||||
|
// This program is free software: you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU Affero General Public License as //
|
||||||
|
// published by the Free Software Foundation, either version 3 of the //
|
||||||
|
// License, or (at your option) any later version. //
|
||||||
|
// //
|
||||||
|
// This program 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 Affero General Public License for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU Affero General Public License //
|
||||||
|
// along with this program. If not, see <https://www.gnu.org/licenses/>. //
|
||||||
|
//=-------------------------------------------------------------------------=//
|
||||||
|
|
||||||
|
#include "../include/base.h"
|
||||||
|
|
||||||
|
void ModelPrepareSpace(Space_t *globalDrawingSpace, Model_t *model)
|
||||||
|
{
|
||||||
|
globalDrawingSpace->size = (model->space_xmax+1) * (model->space_ymax+1) * (model->space_zmax+1);
|
||||||
|
globalDrawingSpace->xmax = model->space_xmax;
|
||||||
|
globalDrawingSpace->ymax = model->space_ymax;
|
||||||
|
globalDrawingSpace->zmax = model->space_zmax;
|
||||||
|
|
||||||
|
globalDrawingSpace->space =
|
||||||
|
(SpaceUnit_t*) calloc(globalDrawingSpace->size, sizeof(SpaceUnit_t));
|
||||||
|
|
||||||
|
for (int i = 0; i < globalDrawingSpace->size; i++) {
|
||||||
|
globalDrawingSpace->space[i].nsite = model->siteNumber;
|
||||||
|
globalDrawingSpace->space[i].sites = (Site_t*) calloc(model->siteNumber, sizeof(Site_t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelPrepareArrows(Space_t *globalDrawingSpace, ArrowArray_t *arrowList,
|
||||||
|
Model_t *model)
|
||||||
|
{
|
||||||
|
#define ARROW_NUMBER 6
|
||||||
|
|
||||||
|
arrowList->array = (Arrow_t*) calloc(ARROW_NUMBER, sizeof(Arrow_t));
|
||||||
|
arrowList->size = ARROW_NUMBER;
|
||||||
|
|
||||||
|
// Creating some arrows
|
||||||
|
globalDrawingSpace->space[3].sites[1].narrow = 1;
|
||||||
|
arrowList->array[0].siteId = 1;
|
||||||
|
arrowList->array[0].x = 3;
|
||||||
|
|
||||||
|
globalDrawingSpace->space[4].sites[0].narrow = 1;
|
||||||
|
arrowList->array[1].siteId = 0;
|
||||||
|
arrowList->array[1].x = 4;
|
||||||
|
}
|
Loading…
Reference in New Issue