Commit 5eda64b9 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add testcase, and fix C generator

the Test case DemoDeviceDSAP is a project with no CIF comments
the C generator was fixed to include properly the h files of the data
views and not "dataview-uniq.h"
parent 95a42b1e
......@@ -14,6 +14,7 @@
"""
import logging
import os
from singledispatch import singledispatch
import Helper
......@@ -839,7 +840,9 @@ LD_LIBRARY_PATH=. taste-gui -l
if string_include == True:
c_source_code.extend(['#include <string.h>'])
c_source_code.extend(['#include \"dataview-uniq.h\"'])
for each in process.DV.asn1Files:
hname = os.extsep.join(each.split(os.extsep)[:-1]) + os.extsep + 'h'
c_source_code.extend(['#include "{}"'.format(hname)])
c_source_code.append('#include \"{pn}.h\"'.format(pn=process_name))
c_source_code.extend(global_decls)
......
......@@ -811,6 +811,8 @@ class Process(object):
# dataview: complete AST of the ASN.1 types
self.asn1Modules = None
self.dataview = None
# Reference to the Python module containing the ASN.1 AST
self.DV = None
# input and output signal lists:
# [{'name': str, 'type': str, 'direction':'in'/'out'}]
......
......@@ -2716,6 +2716,7 @@ def process_definition(root, parent=None, context=None):
LOG.error('Internal error - please report "{}" - "{}"'.format(
str(each), str(err)))
errors.extend(perr)
process.DV = DV
return process, errors, warnings
......
SYSTEM Mysystem;
/* CIF TEXT (178, 209), (356, 140) */
-- Text area for declarations and comments
signal a;
signal b;
use datamodel comment 'dv.asn';
/* CIF ENDTEXT */
CHANNEL c
FROM ENV TO DemoDemoDeviceDSAP WITH a;
FROM DemoDemoDeviceDSAP TO ENV WITH b;
ENDCHANNEL;
BLOCK DemoDemoDeviceDSAP;
SIGNALROUTE r
FROM ENV TO DemoDemoDeviceDSAP WITH a;
FROM DemoDemoDeviceDSAP TO ENV WITH b;
CONNECT c AND r;
PROCESS DemoDemoDeviceDSAP;
/* CIF TEXT (55, 105), (356, 140) */
DCL CommandAddress CcsdsSoisSubnetworkMemoryAddressType := 100;
DCL ExtendedStatusModeAddress CcsdsSoisSubnetworkMemoryAddressType := 102;
DCL MemoryID CcsdsSoisSubnetworkMemoryIDType := 0;
DCL StatusAddress CcsdsSoisSubnetworkMemoryAddressType := 101;
DCL ack DemoTelemetryAckType;
DCL event DemoEventType;
DCL eventTM DemoTelemetryEventType;
DCL extendedMode DemoExtendedModeUnionType;
DCL extendedStatus DemoExtendedStatusUnionType;
DCL status DemoStatusType;
DCL telecommandMode DemoTelecommandModeType;
DCL telecommandType DemoTelecommandTypeEnumType;
DCL telecommandUserData DemoTelecommandUserDataType;
DCL telemetry1 DemoTelemetry1Type;
DCL telemetry2 DemoTelemetry2Type;
/* CIF ENDTEXT */
PROCEDURE EventParam;
START;
TASK event!fldType := eventTM!fldEventType;
TASK event!fldData := eventTM!fldEventData;
-- todo - read deviceEvent from DeviceInterface
RETURN;
ENDPROCEDURE;
PROCEDURE GetExtendedMode;
START;
-- todo - call interface write
RETURN;
ENDPROCEDURE;
PROCEDURE GetExtendedStatus;
START;
-- todo - call interface write
RETURN;
ENDPROCEDURE;
PROCEDURE GetExtendedStatusMode;
START;
-- todo - call interface read
RETURN;
ENDPROCEDURE;
PROCEDURE ReadStatus;
START;
-- todo - call interface read
RETURN;
ENDPROCEDURE;
PROCEDURE ReturnExtendedMode;
START;
-- todo - read extendedMode from DeviceInterface
RETURN;
ENDPROCEDURE;
PROCEDURE ReturnExtendedStatus;
START;
-- todo - read extendedStatus from DeviceInterface
RETURN;
ENDPROCEDURE;
PROCEDURE ReturnStatus;
START;
-- todo - read status from DeviceInterface
RETURN;
ENDPROCEDURE;
PROCEDURE TCReceive;
START;
DECISION (telecommandType=mode);
(true):
-- todo - call interface setMode
(false):
-- todo - call interface setUserData
ENDDECISION;
RETURN;
ENDPROCEDURE;
PROCEDURE TCSendMode;
START;
TASK telecommandType := mode;
-- todo - call interface send
RETURN;
ENDPROCEDURE;
PROCEDURE TCSendUserData;
START;
TASK telecommandType := USER_DATA;
-- todo - call interface send
RETURN;
ENDPROCEDURE;
PROCEDURE TM1Param;
START;
-- todo - read telemetrySet1 from DeviceInterface
RETURN;
ENDPROCEDURE;
PROCEDURE TM2Param;
START;
-- todo - read telemetrySet2 from DeviceInterface
RETURN;
ENDPROCEDURE;
ENDPROCESS DemoDemoDeviceDSAP;
ENDBLOCK;
ENDSYSTEM;
include ../shared.mk
all: test-ada test-llvm
edit:
$(OPENGEODE) DemoDeviceDSAP_fixed.pr
test-parse:
$(OPENGEODE) DemoDeviceDSAP_fixed.pr --check
test-ada:
$(OPENGEODE) DemoDeviceDSAP_fixed.pr --toAda
$(ASN1SCC) -Ada dv.asn -typePrefix asn1Scc -equal
$(GNATMAKE) -O$(O) -c *.adb
$(GNATBIND) -n DemoDeviceDSAP_fixed.ali
test-c:
$(OPENGEODE) DemoDeviceDSAP_fixed.pr --toC
$(ASN1SCC) -c dv.asn -typePrefix asn1Scc -equal
$(CC) -O$(O) -c *.c
test-llvm:
$(OPENGEODE) DemoDeviceDSAP_fixed.pr --llvm -O$(O)
$(LLC) *.ll
$(CC) -O$(O) -c *.s
coverage:
coverage run -p $(OPENGEODE) DemoDeviceDSAP_fixed.pr --toAda
.PHONY: all edit test-parse test-ada test-llvm coverage
--
-- Copyright (c) 2015 European Space Agency
-- All Rights Reserved
--
-- Project: SOIS Electronic Data Sheets
--
-- Module: CCSDS_SOIS_Subnetwork.asn1
--
-- Author: SOIS EDS Tooling (internal unreleased version)
--
--
CcsdsSoisSubnetwork DEFINITIONS AUTOMATIC TAGS ::= BEGIN
X ::= NULL
CcsdsSoisSubnetworkOctet ::= INTEGER (0..255)
CcsdsSoisSubnetworkMemoryIDType ::= INTEGER (0..65535)
CcsdsSoisSubnetworkMemoryAddressType ::= INTEGER (0..4294967295)
END
--
-- Copyright (c) 2015 European Space Agency
-- All Rights Reserved
--
-- Project: SOIS Electronic Data Sheets
--
-- Module: Demo.asn1
--
-- Author: SOIS EDS Tooling (internal unreleased version)
--
--
Demo DEFINITIONS AUTOMATIC TAGS ::= BEGIN
IMPORTS CcsdsSoisSubnetworkOctet FROM CcsdsSoisSubnetwork;
DemoStatusFlag1Type ::= BOOLEAN
DemoStatusFlag2Type ::= BOOLEAN
DemoCalibratedHK1Type ::= INTEGER (0..255)
DemoCalibratedHK2Type ::= INTEGER (0..255)
DemoQueryCountType ::= INTEGER (0..255)
DemoExtendedModeType ::= INTEGER (0..255)
DemoExtendedStatusType ::= INTEGER (0..255)
DemoHK1Type ::= INTEGER (0..255)
DemoHK2Type ::= INTEGER (0..255)
DemoHK3Type ::= INTEGER (0..255)
DemoHK4Type ::= INTEGER (0..255)
DemoCommandStatusType ::= INTEGER (0..65535)
DemoEventDataType ::= INTEGER (0..255)
DemoUserDataLengthType ::= INTEGER (0..65535)
DemoModeType ::= ENUMERATED
{
reset(0),
do-a-little-bit-of-stuff(1),
do-lots-of-stuff(4),
do-tonnes-of-stuff-badly(6),
reveal-a-bug-and-malfunction(9)
}
DemoEventTypeType ::= ENUMERATED
{
event1(0),
event2(1),
event3(2)
}
DemoReadStatusModeCommandType ::= ENUMERATED
{
read-status(1),
read-mode(2)
}
DemoExtendedStatusModeEnumType ::= ENUMERATED
{
mode(0),
status(1)
}
DemoTelecommandTypeEnumType ::= ENUMERATED
{
mode(0),
user-data(1)
}
DemoTelemetryTypeEnumType ::= ENUMERATED
{
ack(0),
type1(1),
type2(2),
event(3)
}
DemoOpCountType ::= INTEGER (0..39)
DemoStatusType ::=
SEQUENCE
{
fldStatusFlag1 DemoStatusFlag1Type,
fldStatusFlag2 DemoStatusFlag2Type,
fldOpCount DemoOpCountType
}
DemoTelemetrySet1Type ::=
SEQUENCE
{
fldHk1 DemoHK1Type,
fldHk2 DemoHK2Type
}
DemoTelemetrySet2Type ::=
SEQUENCE
{
fldHk3 DemoHK3Type,
fldHk4 DemoHK4Type
}
DemoEventType ::=
SEQUENCE
{
fldType DemoEventTypeType,
fldData DemoEventDataType
}
DemoExtendedStatusOrModeType ::=
SEQUENCE
{
fldQueryCount DemoQueryCountType,
fldType DemoExtendedStatusModeEnumType,
body-choice DemoExtendedstatusormodetype-BODY-CHOICE
}
DemoExtendedstatusormodetype-BODY-CHOICE ::= CHOICE
{
fldExtendedModeUnionType DemoExtendedModeUnionType,
fldExtendedStatusUnionType DemoExtendedStatusUnionType
}
DemoExtendedStatusUnionType ::=
SEQUENCE
{
fldStatus DemoExtendedStatusType
}
DemoExtendedModeUnionType ::=
SEQUENCE
{
fldMode DemoExtendedModeType
}
DemoTelecommandType ::=
SEQUENCE
{
fldType DemoTelecommandTypeEnumType,
body-choice DemoTelecommandtype-BODY-CHOICE
}
DemoTelecommandtype-BODY-CHOICE ::= CHOICE
{
fldTelecommandModeType DemoTelecommandModeType,
fldTelecommandUserDataType DemoTelecommandUserDataType
}
DemoTelecommandModeType ::=
SEQUENCE
{
fldMode DemoModeType
}
DemoTelecommandUserDataType ::=
SEQUENCE
{
fldUserDataLength CcsdsSoisSubnetworkOctet,
fldUserData SEQUENCE SIZE(0..255) OF CcsdsSoisSubnetworkOctet
}
DemoTelemetryType ::=
SEQUENCE
{
fldType DemoTelemetryTypeEnumType,
body-choice DemoTelemetrytype-BODY-CHOICE
}
DemoTelemetrytype-BODY-CHOICE ::= CHOICE
{
fldTelemetry1Type DemoTelemetry1Type,
fldTelemetry2Type DemoTelemetry2Type,
fldTelemetryAckType DemoTelemetryAckType,
fldTelemetryEventType DemoTelemetryEventType
}
DemoTelemetryAckType ::=
SEQUENCE
{
fldStatus DemoCommandStatusType
}
DemoTelemetry1Type ::=
SEQUENCE
{
fldTelemetrySet DemoTelemetrySet1Type
}
DemoTelemetry2Type ::=
SEQUENCE
{
fldTelemetrySet DemoTelemetrySet2Type
}
DemoTelemetryEventType ::=
SEQUENCE
{
fldEventType DemoEventTypeType,
fldEventData DemoEventDataType
}
END
--
-- Copyright (c) 2015 European Space Agency
-- All Rights Reserved
--
-- Project: SOIS Electronic Data Sheets
--
-- Module: DEMO_PRES.asn1
--
-- Author: SOIS EDS Tooling (internal unreleased version)
--
--
DemoPres DEFINITIONS AUTOMATIC TAGS ::= BEGIN
IMPORTS SedsSecondsSinceTAI FROM Seds;
DemoPresUInt12 ::= INTEGER (0..4095)
DemoPresTeamType ::= ENUMERATED
{
home-team(0),
away-team(1)
}
DemoPresScoreType ::=
SEQUENCE
{
fldScoreTeamHome DemoPresUInt12,
fldScoreTeamAway DemoPresUInt12
}
DemoPresGameInfoType ::=
SEQUENCE
{
fldTime SedsSecondsSinceTAI,
fldScore DemoPresScoreType
}
END
--
-- Copyright (c) 2015 European Space Agency
-- All Rights Reserved
--
-- Project: SOIS Electronic Data Sheets
--
-- Module: GENERIC.asn1
--
-- Author: SOIS EDS Tooling (internal unreleased version)
--
--
SEDS-Generic DEFINITIONS AUTOMATIC TAGS ::= BEGIN
IMPORTS SedsUint8 FROM Seds;
GenericArray ::= SEQUENCE (SIZE(1)) OF SedsUint8
END
--
-- Copyright (c) 2015 European Space Agency
-- All Rights Reserved
--
-- Project: SOIS Electronic Data Sheets
--
-- Module: MISSION.asn1
--
-- Author: SOIS EDS Tooling (internal unreleased version)
--
--
Mission DEFINITIONS AUTOMATIC TAGS ::= BEGIN
IMPORTS SedsUint8 FROM Seds;
MissionArray ::= SEQUENCE (SIZE(22)) OF SedsUint8
END
--
-- Copyright (c) 2015 European Space Agency
-- All Rights Reserved
--
-- Project: SOIS Electronic Data Sheets
--
-- Module: NPAL.asn1
--
-- Author: SOIS EDS Tooling (internal unreleased version)
--
--
Npal DEFINITIONS AUTOMATIC TAGS ::= BEGIN
IMPORTS SedsBoolean,SedsBitRate,SedsCommandStatus,SedsFloat64,SedsNumberOfKelvin,
SedsNumberOfSeconds,SedsUint16,SedsUint32,SedsUint8,SedsValidityFlag FROM Seds;
NpalPixel ::= INTEGER (0..255)
NpalEventCode ::= ENUMERATED
{
mode-transition(0),
error-occurrence(1),
tc-received(2),
download-event(3),
deleted(4),
calibration-event(5)
}
NpalFrameSize ::= ENUMERATED
{
half-frame(0),
full-frame(1)
}
NpalResetLevel ::= ENUMERATED
{
level-0(0),
level-1(1)
}
NpalProgressStatus ::= ENUMERATED
{
started(0),
completed(1),
aborted(2)
}
NpalTcReceived ::= ENUMERATED
{
accepted(0),
not-accepted(1)
}
NpalCalibrationType ::= ENUMERATED
{
cold-pixel-calibration(0),
hot-pixel-calibration(1),
save-calibration-data(2)
}
NpalWindowSize ::= ENUMERATED