AC_JAVA_CHECK_VERSION_PACKAGE(NAME, IMPORTS, JAR, MIN_VERSION, CURRENT_VERSION)
[scilab.git] / scilab / modules / xcos / src / java / org / scilab / modules / xcos / block / io / ImplicitInBlock.java
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2009 - DIGITEO - Antoine ELIAS
4  *
5  * This file must be used under the terms of the CeCILL.
6  * This source file is licensed as described in the file COPYING, which
7  * you should have received as part of this distribution.  The terms
8  * are also available at
9  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10  *
11  */
12
13 package org.scilab.modules.xcos.block.io;
14
15 import org.scilab.modules.hdf5.scilabTypes.ScilabDouble;
16 import org.scilab.modules.hdf5.scilabTypes.ScilabType;
17
18 import org.scilab.modules.xcos.block.BasicBlock;
19 import org.scilab.modules.xcos.utils.XcosEvent;
20
21 import com.mxgraph.util.mxEventObject;
22
23 public final class ImplicitInBlock extends ContextUpdate {
24
25     private static final long serialVersionUID = 4280002965735451155L;
26
27         public ImplicitInBlock() {
28                 super();
29         }
30
31         protected ImplicitInBlock(String label) {
32                 this();
33                 setDefaultValues();
34                 setValue(label);
35         }
36
37         /**
38          * Initialize the block with the default values
39          */
40         @Override
41         protected void setDefaultValues() {
42                 super.setDefaultValues();
43                 setInterfaceFunctionName("INIMPL_f");
44                 setSimulationFunctionName("inimpl");
45         }
46
47             public void setExprs(ScilabType exprs) {
48                 super.setExprs(exprs);
49                 //setValue(((ScilabString) getExprs()).getData()[0][0]);
50             }
51
52             public void updateBlockSettings(BasicBlock modifiedBlock) {
53
54                 double oldValue = ((ScilabDouble)getIntegerParameters()).getRealPart()[0][0];
55                 super.updateBlockSettings(modifiedBlock);
56                 double newValue = ((ScilabDouble)getIntegerParameters()).getRealPart()[0][0];
57
58                 if(oldValue != newValue){
59                     getParentDiagram().fireEvent(XcosEvent.IN_IMPLICIT_VALUE_UPDATED, new mxEventObject(new Object[]{oldValue,newValue}));
60                 }
61             }
62
63             public void setIntegerParameters(ScilabType integerParameters) {
64                 super.setIntegerParameters(integerParameters);
65                 setValue((int)((ScilabDouble)getIntegerParameters()).getRealPart()[0][0]);
66             }
67 }