summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Shetye2020-09-13 20:53:11 +0530
committerSunil Shetye2021-04-11 21:23:03 +0530
commit021fc86be129b77f5f657620d536dae74ade288c (patch)
treeceb1df78fc844ca2e0f7982cb34a532a2cb774de
parent289ccfa00294a5c2741d92c39ee45ea059b5d61d (diff)
downloadCommon-Interface-Project-021fc86be129b77f5f657620d536dae74ade288c.tar.gz
Common-Interface-Project-021fc86be129b77f5f657620d536dae74ade288c.tar.bz2
Common-Interface-Project-021fc86be129b77f5f657620d536dae74ade288c.zip
set errors
-rw-r--r--Xcos Categories - Xcos Blocks.csv2
-rw-r--r--blocks/blocks/xcosblocks/serializers.py6
-rw-r--r--blocks/blocks/xcosblocks/views.py13
-rw-r--r--docs/api.txt2
4 files changed, 17 insertions, 6 deletions
diff --git a/Xcos Categories - Xcos Blocks.csv b/Xcos Categories - Xcos Blocks.csv
index 3a94400e..383017fb 100644
--- a/Xcos Categories - Xcos Blocks.csv
+++ b/Xcos Categories - Xcos Blocks.csv
@@ -4,7 +4,7 @@ id,Block names,Initial Input Ports Explicit,Initial Input Ports Implicit,Initial
34,ANDBLK,0,0,0,0,2,1,,0,0,0,0,2,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
35,ANDLOG_f,0,0,1,0,2,0,,0,0,1,0,2,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
20,AUTOMAT,2,0,2,0,0,1,"Automaton nM=2, nX=1",2,0,2,0,0,1,"Automaton nM=2, nX=1",Number(finite state) Mode,integer,Initial Mode,integer,Number of continuous timestates,integer,Continuous time states initial value,integer,Xproperties of continuous time states in each mode,vector of integers,Jump from Mode 1:[..;M_final(Guard=In(1).i);..],integer,Jump from Mode 2:[..;M_final(Guard=In(1).i);..],integer,,,,,,,,,,,,,,,,,,,,,,,,,,
-209,Bache,0,2,1,2,0,0,,2,2,3,2,0,0,,Pressure in the sky of the cover: Patm (pa),double,Sheet section: A (m2),double,Altitude of the inlet 1 nozzle: ze1 (m),double,Altitude of the inlet 2 nozzle: ze2 (m),double,Altitude of the outlet 1 nozzle: zs1 (m),double,Altitude of the outlet 2 nozzle: zs2 (m),double,Initial altitude of the fluid: z0 (m),double,Initial fluid temperature: T0 (K),double,"If>0, imposed fluid density: p_rho (kg/m3)",double,,,,,,,,,,,,,,,,,,,,,,
+209,Bache,0,2,1,2,0,0,,0,2,1,2,0,0,,Pressure in the sky of the cover: Patm (pa),double,Sheet section: A (m2),double,Altitude of the inlet 1 nozzle: ze1 (m),double,Altitude of the inlet 2 nozzle: ze2 (m),double,Altitude of the outlet 1 nozzle: zs1 (m),double,Altitude of the outlet 2 nozzle: zs2 (m),double,Initial altitude of the fluid: z0 (m),double,Initial fluid temperature: T0 (K),double,"If>0, imposed fluid density: p_rho (kg/m3)",double,,,,,,,,,,,,,,,,,,,,,,
14,BACKLASH,1,0,1,0,0,0,Backlash,1,0,1,0,0,0,Backlash,initial output,double,gap,double,"use zero crossing(0:no, 1:yes)",boolean,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
167,BARXY,2,0,0,0,1,0,,2,0,0,0,1,0,,Xmin,double,Xmax,double,Ymin,double,Ymax,double,Segs Thickness,double,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
55,BIGSOM_f,2,0,1,0,0,0,,n,0,1,0,0,0,,Inputs port sign/gain,vector of doubles,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
diff --git a/blocks/blocks/xcosblocks/serializers.py b/blocks/blocks/xcosblocks/serializers.py
index 6749dd02..cc507a45 100644
--- a/blocks/blocks/xcosblocks/serializers.py
+++ b/blocks/blocks/xcosblocks/serializers.py
@@ -182,6 +182,12 @@ class BlockParameterSerializer(serializers.ModelSerializer):
]
+class ErrorSerializer(serializers.Serializer):
+ code = serializers.IntegerField()
+ error = serializers.CharField(
+ max_length=200, allow_blank=False, trim_whitespace=True)
+
+
class SetBlockParameterSerializer(serializers.Serializer):
block_id = serializers.IntegerField()
p000_value = serializers.CharField(max_length=100,
diff --git a/blocks/blocks/xcosblocks/views.py b/blocks/blocks/xcosblocks/views.py
index 04beb25e..eec19ef8 100644
--- a/blocks/blocks/xcosblocks/views.py
+++ b/blocks/blocks/xcosblocks/views.py
@@ -5,7 +5,7 @@ from rest_framework.viewsets import ReadOnlyModelViewSet
from .models import Category, Block, BlockParameter
from .serializers import CategorySerializer, BlockSerializer, \
- BlockParameterSerializer, SetBlockParameterSerializer
+ BlockParameterSerializer, ErrorSerializer, SetBlockParameterSerializer
class CategoryFilterSet(FilterSet):
@@ -75,9 +75,14 @@ def set_block_parameter(request):
serializer = SetBlockParameterSerializer(data=request.POST)
if serializer.is_valid():
# process the data to get port
- port = serializer.getblockportserializer()
- if port.is_valid():
- return JsonResponse(port.data)
+ try:
+ port = serializer.getblockportserializer()
+ return JsonResponse(port.initial_data)
+ except Exception as e:
+ error = 'getblockportserializer error: %s' % str(e)
+ errorserializer = ErrorSerializer(data={
+ 'code': 500, 'error': error})
+ return JsonResponse(errorserializer.initial_data)
else:
serializer = SetBlockParameterSerializer()
diff --git a/docs/api.txt b/docs/api.txt
index 2319e680..c4595443 100644
--- a/docs/api.txt
+++ b/docs/api.txt
@@ -67,7 +67,7 @@ p039_type
-POST /set_block_parameters/
+POST /setblockparameter
Input JSON - Map of