Simulation using animation

i am trying to create a applet to simulate the TCP/IP
protocol suite. I want to have two computers on screen with messages going between them. One computer will send a message and the other will send an acknowledgement back, this will have a counter and if the acknowledgement is not received within a certain amount of time the message will be retransmitted. could you please give me some idea as to where to start with this. I'm assuming i use two animation loops and threads.
Many thanks
Deirdre McKenna

The simplest way would be to use one thread. In the run method update the data, increase the animation frames, then render the scene.
Is the question about how to draw animations, or the stucture?

Similar Messages

  • Add 3D Modeling, Simulation, and Animation to LabView

    I am posting to announce the availability of RoboWorks software.
    RoboWorks is an easy to use software tool for 3D modeling, simulation
    and animation of any physical system. It provides an inexpensive
    alternative to hardware (especially robotic) and brings 3D simulation
    to every desktop. When using RoboWorks you will benefit from:
    * Extremely intuitive model development
    * High quality, fully interactive 3D graphics
    * Lightweight files that conserve disk space
    * Full animation, even while building your model
    * Interfacing with popular software packages
    Most analysis and visualization software such as Matlab, MathCad, and
    LabVIEW support graphics limited to charts and graphs. RoboWorks adds
    3D modeling a
    nd animation capabilities to these software packages. Now
    you can do your analysis in the software of your choice and visualize
    and animate your results in RoboWorks.
    RoboWorks supports interactive animation via the keyboard (animate as
    you build your model), through a data file, or through RoboTalk.
    RoboTalk is an Open Source applications programming interface that
    allows programs running on any platform that supports TCP/IP to
    interact with and control RoboWorks models in real time. For example,
    your control program running on Linux can now control your mobile robot
    simulation in RoboWorks in real-time.
    RoboWorks comes with full-featured help and a variety of sample models
    such as those shown at left. Also included are sample RoboTalk
    programs, LabVIEW support, program-interfacing support through DLL's
    and RoboTalk source code for non-supported platforms.
    For more information email us at [email protected] or visit
    www.newtonium.com.
    Platforms: Win 95/98/NT/2000. Any system
    with TCP/IP for RoboTalk.
    Regards
    Chetan Kapoor
    Newtonium
    www.newtonium.com
    Sent via Deja.com http://www.deja.com/
    Before you buy.

    Well, what you mention in your two sentences is somewhat of an Oxymoron. 3D modeling and animation, decent software and simple to use don't belong in the same sentence let alone paragraph. This is a FCP forum but I'll answer with my 2cents as I am a motion graphic artist that does 3D animation. There are about 6 different 3D applications that are worth their salt. Maya, 3ds Max, Softimage, Cinema 4D, Houdini and Blender. All are quite capable. None are what I would call simple to use. If you want to do 3D animation you need skills in modeling, texturing, rendering, lighting, rigging, animation, dynamics, drawing and script programming just to get started. If you are not up to spending the time and effort in having someone train to learn these skills and to spend the $$ for the hardware and software, what I would recommend is outsourcing your initial projects to get you started so you get an appreciation for what is really required to do the job and then once you understand all that is needed, you will have a better understanding of what software would fit for what you are trying to accomplish.
    BTW I do freelance work.

  • Using Animation in your Sequence Settings ... Amazing!

    Well here's the thing ....
    And I'll start off by saying I have so much to learn about FCP but this has made a big difference to how my images look, especially graphics and titles.
    So I'm working away at my project and the graphic images that I import into the timeline from the viewer are just ok and I'm a bit disillusioned like so many people seem to be on these forums about how the image degrades from the viewer to the canvas. And of course it is apparent later on the QT file and then the DVD that's produced at the end.
    So one day, and I can't remember how it came about, I open the sequence settings and change the Compressor in QT Video Settings to Animation! Well what can I say, the image in the canvas was absolutely perfect and in some cases, it's actually a little better than how it looked in the viewer before I brought it across.
    I have to produce a DVD where each week, some of the moving footage and graphic images have to be changed over. A total of about 15 minutes and all of it of course is in this Animation sequence. The downside of using Animation is
    (1) the rendering time is horrendous, (or is that horrenderous?)
    (2) as I'm editing, the playhead disobeys what you ask of it and you get the spinning beach ball quite often (can take 1-4 minutes before you can continue again)
    (3) sometimes when you're playing through the timeline the image on the canvas and the sound quality are poor (processor running out of puff I guess)
    It's a bit of a nightmare but I have no choice but to use Animation now the Marketing Department have seen the difference and expect the higher quality on the images. Cannot get this quality with any other setting I've tried in the Compressor setting. HDV1080 for instance means the rendering problem goes away but the difference in quality is obvious. The project has many different files and formats from HDV to H264s to Pro Res 422s and lots of various jpegs in various forms. But regardless of the project, I have experimented with unrelated sequences in different projects with the same result.
    My questions are..... has anyone else experienced this, is there another setting that would bring about the same results and lastly, would the rendering and the other problems significantly be reduced with say the top-end iMac?
    I have to tell you I almost didn't post this coz I have so little experience with FCP but it would be great to get your feedback. The weekly project I produce may take more time than it should but I have to say I'm happy with the results.
    Thanks for reading.
    Peter L

    Well... the animation codec is primarily used for sneakernetting files from one platform to another, mac to pc for example. It's a bear for a lot of computers to even play out a file without choking. The concept is make animation file, put on disk or drive, carry across the hall to the pc station, convert to something the pc station can use without choking.
    I would suggest you try a little experiment: take your input material and convert it to prores (NOT HQ) before import or WHEN you import (log and transfer) and work with that natively. HDV as HDV is really a cruddy medium. Prores will give you a much better color space and have actual frames all the way through, which hdv does not. Take a one minute section of material, load on some graphics and filters etc, render it out, do your whole production process and see what it looks like. Once you move beyond the artifacts inherent in hdv and h.264 encoding you might be surprised.
    Bad mistake to point out to marketing folks how cool it looks. You must be young!

  • How to make load simulator using labview 2010

    i want to ask how to make load simulator using labview? 
    Solved!
    Go to Solution.

    what have you tried so far? and exactly what is it your tying to do?
    Please remember to accept any solutions and give kudos, Thanks
    LV 8.6.1, LV2010,LV2011SP1, FPGA, Win7

  • Can I use animated emoticons in mail?

    I want to put an animated emoticons in my signature block in emails.  I can put them in my signature block but they do not animate.   How to use animated emoticons in mail?  If so how do I get them to work?

    You said you have a url link to the animated gif.
    Open that link in Safari or Firefox or some other browser so that you are actually looking at the animated gif doing its thing.
    Open Mail and go to Preferences > Signatures
    Select a signature to edit or create a new one.
    Edit the text as desired.
    To add the animated gif drag the actual image from the browser window and drop it in to place in Mail's signature composing frame.  Don't worry if it only displays as a [?] icon.  When you do this, you aren't actually adding the image but are creating an HTML link to the file on the internet server.
    Make sure you have added the signature to the account you will be using it with.  You can drag the signature name (in the middle column) and drop it on the desired account in the left hand column.
    If that is the only signature you have for that account, then when you start a new message it will automatically apear in the message.  If you have multiple signatures you can select the one you want (or none) from the message's toolbar.
    Dan

  • Re-using animation definitions for different characters

    http://www.cartoonsolutions.com/store/catalog/Re-using-Animation-on-Multiple-Characters-Vi deo-Tutorial-p-16569.html
    Cartoon Solutions has this tutorial for re-using animation
    for different characters. Are the plug ins for this available for
    free anywhere, or is cartoonsolutions the only place that offers
    it?

    I think you want the "LibAppend" extension - if so - my
    friend Dave Wolfe has it here:
    http://www.toonmonkey.com/extensions.html
    Chris Georgenes / mudbubble.com / keyframer.com / Adobe
    Community Expert
    bippity wrote:
    >
    http://www.cartoonsolutions.com/store/catalog/Re-using-Animation-on-Multiple-Cha
    > racters-Video-Tutorial-p-16569.html
    >
    > Cartoon Solutions has this tutorial for re-using
    animation for different
    > characters. Are the plug ins for this available for free
    anywhere, or is
    > cartoonsolutions the only place that offers it?
    >
    >

  • Lag when using animated effect

    Hi everyone !
    I have a little problem with my ADOBE AFTER EFFECT CC  Version 13.2.0.49
    When i use animated effect like Rainfall or Twitch from VideoCopilot my After Effect get har lags !
    *Lag when i'm applying the effect
    Here i'm applying RainFall , same lag for twitch or other animated effect
    *Lag when i try to move the layers of the animated effect
    I can post more video of these lag if you need
    Can you help me please ?
    I can't work ....

    I have :   Intel Core i7-4710HQ CPU 2.50GHz
                  32 Go Ram
                  256 Go ssd
                   1 TO HDD raid 0
                   GTX 880M   8Gb
    Footage :   1080p 59.94fps Gopro Video
    Before thos problem in all gopro video i never get lag but now i get these lag and i want to fix this problem thanks 

  • Re-using Animation on Multiple Characters

    Hi I don't know if this is the right place to ask this, please bear with me. So in my game, I got 20 enemies that looked different, but should have the same animations. For example the dying, running, walking animations are all structured the same. But I don't want to do this manually, giving the fact that I'm using frame by frame animations, it will consume a lot of my time. Is there a way I can re-use my main animations to other movieclips/characters? Like reusing armature/animation via bone tool... thanks
    There's an old thread almost the same as mine. Saw this link, and this is the one I'm talking about. But sadly, ain't free.
    http://www.cartoonsolutions.com/store/catalog/Re-using-Animation-on-Multiple-Characters-Vi deo-Tutorial-p-16569.html

    Yes, I'm currently using FbF. But I can't show you any SS right now for the 20 enemies, cause I ain't done with that part. I only got my player's (main character) animations. Here's some of it:
    this is not drawn FbF, rather they are vector parts rotated/tweened each frame.

  • Using animated GIF as JButton icon

    Hi,
    I am trying to use an animated gif as an icon in a JButton.
    Everything works as it should except the animation is static!!
    Screenshots and code are at:
    http://www.beammicrosystems.com/Java/JButton.html
    Anyone got any good ideas?
    Regards,
    Andrew

    well i think you can do this in a label you can watch for a animation like you want a gif so my idea is that you should just make the label as a button and them :
    JLabel label = new JLabel();
    label.setIcon = new ImageIcon("name.gif");
    and put it the setBounds
    label.setBounds(x,y,long,tall);
    and if you want that looks like a button just do this
    label.setBorder(BorderFactory.createRaisedBevelBorder());
    thats all.

  • Using animated gif...

    I've encountered a problem in displaying animated gif using java Swing.
    For my program, I need to display 6 animated gif images. Sometimes I would get all those displayed, but sometimes only 1 or few are displayed.
    This problem troubles me until I found that it is the problem of animated gif I've used, because I have tried to replace the animated gif to static ones then every time the images are all displayed.
    I need a help urgently. Thanks a lot in advance.

    Hi
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    public class Dance extends JFrame 
    public Dance()  
         addWindowListener(new WindowAdapter()
        {     public void windowClosing(WindowEvent ev)
              {     dispose();
                   System.exit(0);}});
         getContentPane().setLayout(null);
         setBounds(10,10,400,300);
         JLabel j1 = new JLabel(new ImageIcon("cut1.gif"));
         j1.setBounds(10,30,40,40);
         getContentPane().add(j1);
         JLabel j2 = new JLabel(new ImageIcon("cut2.gif"));
         j2.setBounds(50,70,40,40);
         getContentPane().add(j2);
         JLabel j3 = new JLabel(new ImageIcon("cut3.gif"));
         j3.setBounds(90,110,40,40);
         getContentPane().add(j3);
         JLabel j4 = new JLabel(new ImageIcon("cut4.gif"));
         j4.setBounds(130,150,40,40);
         getContentPane().add(j4);
         setVisible(true);
    public static void main (String[] args)
         new Dance();
      Noah

  • Using animated gifs  in emails

    I've made an animated gif using flash an am trying to make it
    so the gif appears in my signature at the bottom of every email. I
    can place it in the signature but when I send the email the gif is
    static and doesn't move. Also I'm using a mac and when I recieve an
    animated gif in an email from a PC the gif is also static. I need
    to be able to send animated gifs in emails from PC and Mac using
    Mircosoft Outlook for PC and Entourage for MAC. Any help would be
    much appreciated.
    Cheers,

    this really has nothing to do with flash at all - you have no
    control over this as the recipient of
    your email may not be using an email client that supports
    animated gifs - does your gif work when
    viewed ina web page?
    you must realize there are a myriad ways people check email -
    sometimes via a browser, handheld
    device, email client software, etc...not all support animated
    gifs and the ones that do may have
    that option turned off by user.
    i would consult the support section of the email software
    your recipients use.
    --> **Adobe Certified Expert**
    --> www.mudbubble.com
    --> www.keyframer.com
    Luke H wrote:
    > I've made an animated gif using flash an am trying to
    make it so the gif
    > appears in my signature at the bottom of every email. I
    can place it in the
    > signature but when I send the email the gif is static
    and doesn't move. Also
    > I'm using a mac and when I recieve an animated gif in an
    email from a PC the
    > gif is also static. I need to be able to send animated
    gifs in emails from PC
    > and Mac using Mircosoft Outlook for PC and Entourage for
    MAC. Any help would be
    > much appreciated.
    >
    > Cheers,
    >
    >

  • Using animation as icon for JTree node

    Hi,
    I am using a custom tree cell renderer. I have a label in the renderer, the label have gif Image Icon, but the problem is it is not getting animated. But when I use a JLabel with gif icon some where else it is working fine, but it is not working for tree node.
    package com.gopi.utilities.gui;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.GridBagConstraints;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.TreeCellRenderer;
    import com.gopi.remfilebrowser.gui.GUIUtil;
    import com.gopi.remfilebrowser.util.FileBrowserConstants;
    public class CustomTreeCellRenderer implements TreeCellRenderer
         private JPanel panel;
         private JLabel label;
         private TreeCellRenderer defaultRenderer;
         public CustomTreeCellRenderer()
              super();
              panel = GUIUtil.createGridBagPanel();
              label = new JLabel();
              label.setHorizontalAlignment(JLabel.LEFT);
              System.out.println("New");
              GridBagConstraints gc = new GridBagConstraints();
              GUIUtil.fillComponent(panel,label);
              defaultRenderer = new DefaultTreeCellRenderer();
         public Component getTreeCellRendererComponent(JTree tree, Object value,
                     boolean sel,
                     boolean expanded,
                     boolean leaf, int row,
                     boolean hasFocus)
              if(value instanceof NewAbstractTreeNode)
                   NewAbstractTreeNode node = (NewAbstractTreeNode) value;
                   System.out.println("dr");
                   label.setText(value.toString());
                   label.setIcon(ImageLoader.getInstance().getIcon(node.getIconKey()));
                   if(hasFocus && sel)
                        panel.setBackground(FileBrowserConstants.TREE_NODE_SELECTED_COLOR);
                   else if(sel)
                        panel.setBackground(FileBrowserConstants.TREE_NODE_UNSELECTED_COLOR);
                   else
                        panel.setBackground(Color.white);
                   return panel;
              return defaultRenderer.getTreeCellRendererComponent(tree,value,sel,expanded,leaf,row,hasFocus);
    }

    JLabels using ImageIcons are designed to display the icon as is, including animation and all.
    A CellRenderer only paints the Icon once, when the cell is painted. Much ike a rubber stamp of the JComponent. Hence, its not designed to do the animation and all.
    If you really want it, you can probably use MediaTracker and a Timer to do your animation scheduling. Might not be very pretty code though
    ICE

  • Problems using Animation Presets from Bridge

    Dear all,
    Using the CC range, and recently had a new problem using the animation presets from Adobe Bridge. I'm in After Effects as normal, and then go to the Animations drop down, click browse recent presets to open up Bridge, and then as normal use Bridge to select the preset I want. Double click it whilst highlighting my selected track in AE, and then AE reports this:
    And the same error codes no matter what effect/animation I choose, whether its to an image, video or text.
    If I just go, in AE, to my Recent Animation Presets, and choose one from there it loads up absolutely fine. But this is massively annoying.  Any ideas? This problem appeared out of nowhere.

    This is fixed in the After Effects 2014.2 (13.2) update, which is now available.
    Details here: http://adobe.ly/1IVopxh

  • Problem in using animations in dynamic images

    Hi Friendz,
    I've problem in using effects or animation after calling
    images dynamically from outside the flash.
    If somebody have any solution for this, then please solve my
    problem immediately....

    Little more information about your problem would be helpfull.

  • Simulation using Eclipse plugin for JCOP tools

    Dear All,
    In search for a simulation environment for java card applet development I tried to use Eclipse plugin for JCOP tools.
    The samples which comes with the JCOP tools works fine but when try to debug my applet I receive the error: Wrong Data 6A 80.
    Generic JCOP v2.4.1 is selected for Java Card Simulation.
    Following is the JCOP Shell screen:
    cm- /term "Remote|localhost:8050"
    --Opening terminal
    /card -a a000000003000000 -c com.ibm.jc.CardManagerresetCard with timeout: 0 (ms)
    --Waiting for card...
    ATR=3B F8 13 00 00 81 31 FE 45 4A 43 4F 50 76 32 34 ;.....1.EJCOPv24
    31 B7 1.
    IOCTL().
    ATR: T=1, FI=1/DI=3 (93clk/etu), N=0, IFSC=254, BWI=4/CWI=5, Hist="JCOPv241"
    => 00 A4 04 00 08 A0 00 00 00 03 00 00 00 00 ..............
    (908058 nsec)
    <= 6F 65 84 08 A0 00 00 00 03 00 00 00 A5 59 9F 65 oe...........Y.e
    01 FF 9F 6E 06 47 91 92 18 00 00 73 4A 06 07 2A ...n.G.....sJ..*
    86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B .H..k.`...*.H..k
    02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64 ....c...*.H..k.d
    0B 06 09 2A 86 48 86 FC 6B 04 02 15 65 0B 06 09 ...*.H..k...e...
    2B 85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01 +...Hd...f...+..
    04 01 2A 02 6E 01 02 90 00 ..*.n....
    Status: No Error
    cm> set-key 255/1/DES-ECB/404142434445464748494a4b4c4d4e4f 255/2/DES-ECB/404142434445464748494a4b4c4d4e4f 255/3/DES-ECB/404142434445464748494a4b4c4d4e4f
    cm> init-update 255
    => 80 50 00 00 08 B1 04 15 2B 41 3F 62 AB 00 .P......+A?b..
    (2668 usec)
    <= 00 00 F9 02 71 E3 BB AD BD CD FF 02 00 00 3D 02 ....q.........=.
    9C 31 C7 89 AD 44 8E 13 17 15 2E 5A 90 00 .1...D.....Z..
    Status: No Error
    cm> ext-auth plain
    => 84 82 00 00 10 CE 6C DC D2 8C BE 5E 33 EC 58 D0 ......l....^3.X.
    57 3A 52 D2 24 W:R.$
    (2288 usec)
    <= 90 00 ..
    Status: No Error
    cm> delete -r a00000006203010c04
    => 80 E4 00 80 0B 4F 09 A0 00 00 00 62 03 01 0C 04 .....O.....b....
    00 .
    (1084 usec)
    <= 6A 88 j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Ignoring expected error
    cm> upload -d -b 250 "D:\JCOP\eclipse\projects\DigitalTachograph\bin\digitaltachograph\javacard\digitaltachograph.cap"
    => 80 E6 02 00 16 09 A0 00 00 00 62 03 01 0C 04 08 ..........b.....
    A0 00 00 00 03 00 00 00 00 00 00 00 ............
    (2100 usec)
    <= 00 90 00 ...
    Status: No Error
    => 80 E8 00 00 FA C4 82 84 42 01 00 25 DE CA FF ED ........B..%....
    02 02 04 00 01 09 A0 00 00 00 62 03 01 0C 04 11 ..........b.....
    64 69 67 69 74 61 6C 74 61 63 68 6F 67 72 61 70 digitaltachograp
    68 02 00 21 00 25 00 21 00 0E 00 29 03 3E 00 CD h..!.%.!...).>..
    23 D2 01 BB 04 44 00 00 09 E3 4B E5 00 11 00 05 #....D....K.....
    01 A2 04 01 00 04 00 29 04 00 01 07 A0 00 00 00 .......)........
    62 00 01 02 01 07 A0 00 00 00 62 01 01 02 01 07 b.........b.....
    A0 00 00 00 62 01 02 02 01 07 A0 00 00 00 62 02 ....b.........b.
    01 03 00 0E 01 0A A0 00 00 00 62 03 01 0C 04 01 ..........b.....
    01 DF 06 00 CD 00 00 00 80 00 00 FF 00 01 00 00 ................
    00 01 81 03 13 00 12 07 03 00 00 02 01 03 06 0B ................
    8C 81 00 00 00 80 00 0B 00 0B 01 01 00 00 0B F9 ................
    00 80 00 11 00 0F 01 01 00 10 0E A9 0D D4 0D F7 ................
    0E 07 0E 18 0E 26 0E 35 0E 44 0E 50 0E 72 0E 81 .....&.5.D.P.r..
    0E 90 0E 9B 0E F5 11 05 11 1A 11 50 00 80 00 05 ...........P....
    00 04 01 04 00 01 13 AF 13 B5 13 BA 14 0C 13 00 ................
    (6775 usec)
    <= 6A 80 j.
    Status: Wrong data
    jcshell: Error code: 6a80 (Wrong data)
    jcshell: Wrong response APDU: 6A80
    Unexpected error; aborting execution
    I will be very happy if you can help me. I am desperately in need of a working debugging environment.
    Thanks in advance!
    Kind regards,
    Mehmet

         * Processes incoming READ_BINARY APDUs. Returns data of the currently
         * selected file.
         * @param apdu   where the offset is carried in header bytes p1 and p2.
         * @param le  expected length by terminal
         * @return length of the response APDU
        private short processReadBinary(APDU apdu, boolean protectedApdu,  short leUnprotected) {
            if (!hasFileSelected()) {
                ISOException.throwIt(SW_CONDITIONS_NOT_SATISFIED);
            byte[] buffer = apdu.getBuffer();
            // retrieve p1p2 from apdu buffer
            byte p1 = buffer[OFFSET_P1];
            byte p2 = buffer[OFFSET_P2];
            short offset = Util.makeShort(p1, p2);     // offset encoded in P1/P2, 15 lowest bit
            // offset encoded in P1/P2, 15 lowest bit
            // check if le != 0 <-- no response expected
            if (leUnprotected == 0) {
                ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
            if (selectedFile == null) {
                ISOException.throwIt(ISO7816.SW_FILE_NOT_FOUND);
            if ((selectedFile.getAccessConditions() & READ_REQUIRES_SM) == READ_REQUIRES_SM) {
                if(!protectedApdu)
                   ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
            short fileSize = (short) selectedFile.getFileLength();
            // check offset
            if (offset >= fileSize) {
                ISOException.throwIt(ISO7816.SW_INCORRECT_P1P2);
            // check expected length
            if ((short) (offset + leUnprotected) > fileSize) {
                ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
                //ISOException.throwIt(SW_TAMAM);
            short bufferOffset = 0;
            crypto.setEncryptionStatus(isSelectedFileEncrypted());
            if (protectedApdu) {
                bufferOffset = crypto.getApduBufferOffsetDT(leUnprotected);
                if(isSelectedFileEncrypted())
                   bufferOffset = crypto.getApduBufferOffset(leUnprotected);
                apdu.setOutgoing();
            Util.arrayCopyNonAtomic(selectedFile.getData(), offset, buffer, bufferOffset, leUnprotected);
            return leUnprotected;
         * Processes and UPDATE_BINARY apdu. Writes data in the currently selected
         * file.
         * @param apdu
         *            carries the offset where to write date in header bytes p1 and
         *            p2.
        private void processUpdateBinary(APDU apdu, boolean protectedApdu) {
            if (!hasFileSelected() || isLocked()) {
                ISOException.throwIt(ISO7816.SW_COMMAND_NOT_ALLOWED);
            if ((selectedFile.getAccessConditions() & DigitalTachograph.UPDATE_ALW) != DigitalTachograph.UPDATE_ALW) {
                if ((selectedFile.getAccessConditions() & DigitalTachograph.UPDATE_REQUIRES_SM) != DigitalTachograph.UPDATE_REQUIRES_SM) {
                    ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
                    return;
                }else if(!protectedApdu){
                        ISOException.throwIt(ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED);
            byte[] buffer = apdu.getBuffer();
            byte p1 = buffer[OFFSET_P1];
            byte p2 = buffer[OFFSET_P2];
            short offset = Util.makeShort(p1, p2);
            short readCount = (short) (buffer[ISO7816.OFFSET_LC] & 0xff);
            //if (!protectedApdu){
                readCount = apdu.setIncomingAndReceive();
            while (readCount > 0) {
                selectedFile.writeData(offset, buffer, OFFSET_CDATA, readCount);
                offset += readCount;
                readCount = apdu.receiveBytes(ISO7816.OFFSET_CDATA);
        private short processInternalAuthenticate(APDU apdu , boolean protectedApdu) throws CryptoException {
            byte[] buffer = apdu.getBuffer();
            short lc = (short) (buffer[OFFSET_LC] & 0xFF);
            if (lc != (short) (KID_LENGTH * 2)) {
                ISOException.throwIt(SW_WRONG_LENGTH);
            if (apdu.setIncomingAndReceive() != lc) {
                ISOException.throwIt(ISO7816.SW_WRONG_DATA);
            // Check if VU.CHR maches the one of the selected certificate on the card
            if (Util.arrayCompare(buffer, (short) (OFFSET_CDATA + KID_LENGTH), keyStore.selected_KID, (short) 0, KID_LENGTH) != 0) {
                ISOException.throwIt(SW_REFERENCE_DATA_NOT_FOUND);
            if (Util.arrayCopyNonAtomic(buffer, OFFSET_CDATA, Rnd1, (short) 0, (short) 8) != (short) 8) { // Receive Rnd1
                ISOException.throwIt(ISO7816.SW_WRONG_DATA);
            // Hash(PRnd2||K1||Rnd1||VU.CHR)
            random.generateData(PRnd2, (short) 0, (short) 90);
            random.generateData(K1, (short) 0, (short) 16);
            crypto.shaDigest.update(PRnd2, (short) 0, (short) 90); // PRnd2
            crypto.shaDigest.update(K1, (short) 0, (short) 16); // PRnd2||K1
            crypto.shaDigest.doFinal(buffer, OFFSET_CDATA, lc, digest, (short) 0); //Rnd1||VU.CHR
            BigNumber mod = new BigNumber((short) 128);
            mod.init(keyStore.Card_PubMod, (short) 0, (short) keyStore.Card_PubMod.length, BigNumber.FORMAT_HEX);
            mod.subtract(signed, (short) 0, (short) 128, BigNumber.FORMAT_HEX);
            if (mod.compareTo(signed, (short) 0, (short) 128, BigNumber.FORMAT_HEX) == -1) {
                mod.toBytes(signed, (short) 0, (short) 128, BigNumber.FORMAT_HEX);
            // To be added: if the selected private key is considered corrupted, the processing state returned is '6400' or '6581'.
            signed[0] = (byte) 0x6A;
            Util.arrayCopyNonAtomic(PRnd2, (short) 0, signed, (short) 1, (short) 90);
            Util.arrayCopyNonAtomic(K1, (short) 0, signed, (short) 91, (short) 16);
            Util.arrayCopyNonAtomic(digest, (short) 0, signed, (short) 107, (short) 20);
            signed[127] = (byte) 0xBC;
            if (!keyStore.cardPrivateKey.isInitialized()) {
                CryptoException.throwIt(CryptoException.ILLEGAL_VALUE);
            try {
                crypto.rsaSigner.init(keyStore.cardPrivateKey, Signature.MODE_SIGN);
                crypto.rsaSigner.doFinal(signed, (short) 0, (short) 128, signed, (short) 0);
            } catch (Exception e) {
                ISOException.throwIt(SW_REFERENCE_DATA_NOT_FOUND);
            if (!keyStore.selectedPublicKey.isInitialized()) {
                CryptoException.throwIt(CryptoException.ILLEGAL_VALUE);
            try {
                crypto.rsaCipher.init(keyStore.selectedPublicKey, Cipher.MODE_ENCRYPT);
                crypto.rsaCipher.doFinal(signed, (short) 0, (short) 128, signed, (short) 0);
            } catch (Exception e) {
                ISOException.throwIt(SW_REFERENCE_DATA_NOT_FOUND);
            apdu.setOutgoing();
            Util.arrayCopyNonAtomic(signed, (short) 0, buffer, (short) 0, (short) 128);
            return (short) signed.length;
        private void processExternalAuthenticate(APDU apdu) {
            short equipmentType = 0;
            if (keyStore.Selected_Cert != null) {
                equipmentType = (short) keyStore.Selected_Cert.CHA[6]; // check equipment type
            if (equipmentType != (short) 1 && equipmentType != (short) 2 && equipmentType != (short) 3 && equipmentType != (short) 4 && equipmentType != (short) 6) {
                ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED); // Instead of 6F00 throw a more meaningfull SW in case CHA is not valid.
            if (Util.arrayCompare(keyStore.Selected_Cert.CHA, (short) 0, TACHOGRAPH_AID, (short) 0, (short) 6) != 0) {
                ISOException.throwIt(ISO7816.SW_FUNC_NOT_SUPPORTED);
            byte[] buffer = apdu.getBuffer();
            byte p1 = (byte) (buffer[OFFSET_P1] & 0xff);
            byte p2 = (byte) (buffer[OFFSET_P2] & 0xff);
            if (p1 != 0 || p2 != 0) {
                ISOException.throwIt(SW_WRONG_P1P2);
            short lc = (short) (buffer[OFFSET_LC] & 0xFF);
            if (lc != (short) (128)) {
                ISOException.throwIt(SW_WRONG_LENGTH);
            if (apdu.setIncomingAndReceive() != lc) {
                ISOException.throwIt(ISO7816.SW_WRONG_DATA);
            Util.arrayCopyNonAtomic(buffer, OFFSET_CDATA, signed, (short) 0, (short) 128); // receive the cryptogram from the VU
            // decrypt the encrypted message with the card private key
            try {
                crypto.rsaCipher.init(keyStore.cardPrivateKey, Cipher.MODE_DECRYPT);
                crypto.rsaCipher.doFinal(signed, (short) 0, (short) 128, signed, (short) 0);
            } catch (Exception e) {
                ISOException.throwIt(SW_REFERENCE_DATA_NOT_FOUND);
            // verify the signature with the VU public key
            try {
                crypto.rsaCipher.init(keyStore.selectedPublicKey, Signature.MODE_VERIFY); // Cipher.MODE_ENCRYPT
                crypto.rsaCipher.doFinal(signed, (short) 0, (short) 128, signed, (short) 0);
            } catch (Exception e) {
                ISOException.throwIt(SW_REFERENCE_DATA_NOT_FOUND);
            if (signed[0] != (byte) 0x6A || signed[127] != (byte) 0xBC) {
                ISOException.throwIt(Util.makeShort(signed[0], signed[127]));
            try {
                verifyCardCertificates();
                Util.arrayCopyNonAtomic(signed, (short) 1, preDigest, (short) 0, (short) 106); // accumulate preDigest
                Util.arrayCopyNonAtomic(Rnd3, (short) 0, preDigest, (short) 106, (short) 8); // accumulate preDigest
                Util.arrayCopyNonAtomic(keyStore.Card_Cert.CHR, (short) 0, preDigest, (short) 114, (short) 8); // accumulate preDigest
                Util.arrayCopyNonAtomic(signed, (short) 91, K2, (short) 0, (short) 16); // receive K2 value
                crypto.shaDigest.update(signed, (short) 1, (short) 106); // PRnd4||K2
                crypto.shaDigest.update(Rnd3, (short) 0, (short) 8); // Rnd3
                crypto.shaDigest.doFinal(keyStore.Card_Cert.CHR, (short) 0, (short) 8, digest, (short) 0); //||Card.CHR
            } catch (Exception e) {
                ISOException.throwIt(SW_TAMAM);
            if (Util.arrayCompare(signed, (short) 107, digest, (short) 0, (short) 20) != 0) {
                ISOException.throwIt(SW_TAMAM);
            volatileState[0] |= MUTUAL_AUTHENTICATED;
            try {
                DTUtil.xor(K1, (short) 0, K2, (short) 0, KaKb, (short) 0, (short) 16);
                Util.arrayCopyNonAtomic(Rnd3, (short) 4, SSC, (short) 0, (short) 4); // tail of Rnd3
                Util.arrayCopyNonAtomic(Rnd1, (short) 4, SSC, (short) 4, (short) 4); // tail of Rnd1
            } catch (Exception e) {
                ISOException.throwIt(SW_TAMAM);
            try {
                keyStore.setKey_Ka(KaKb, (short) 0);
                keyStore.setKey_Kb(KaKb, (short) 8);
                keyStore.setSecureMessagingKeys(KaKb, (short) 0, KaKb, (short) 0);
            } catch (Exception e) {
                ISOException.throwIt(SW_TAMAM_DEGIL);
            return;
        private short returnPreDigest(APDU apdu) {
            byte[] buffer = apdu.getBuffer();
            apdu.setOutgoing();
            Util.arrayCopyNonAtomic(preDigest, (short) 0, buffer, (short) 0, (short) 122);
            return (short)preDigest.length;
        private short returnDigest(APDU apdu) {
            byte[] buffer = apdu.getBuffer();
            apdu.setOutgoing();
            Util.arrayCopyNonAtomic(digest, (short) 0, buffer, (short) 0, (short) 20);
            return (short)digest.length;
        private short returnOriginalText(APDU apdu) {
            byte[] buffer = apdu.getBuffer();
            apdu.setOutgoing();
            Util.arrayCopyNonAtomic(signed, (short) 0, buffer, (short) 0, (short) 128);
            return (short)signed.length;
        private void processVerify(APDU apdu) { // Verify_CHV(Pin_Ws)
            byte[] buffer = apdu.getBuffer();
            // retrieve the PIN data for validation.
            byte byteRead = (byte) (apdu.setIncomingAndReceive());
            // the PIN data is read into the APDU buffer
            // at the offset ISO7816.OFFSET_CDATA the PIN data length = byteRead
            if (pin.check(buffer, ISO7816.OFFSET_CDATA, byteRead) == false) {
                ISOException.throwIt(SW_VERIFICATION_FAILED);
            return;
        private void processPSO(APDU apdu) { // verify certificate
            byte[] buffer = apdu.getBuffer();
            byte p1 = (byte) (buffer[OFFSET_P1] & 0xff);
            byte p2 = (byte) (buffer[OFFSET_P2] & 0xff);
            short lc = (short) (buffer[ISO7816.OFFSET_LC] & 0xFF);
            if (p1 == (byte) 0x00 && p2 == P2_VERIFYCERT) {
                if (lc != TACHO_CERT_LENGTH) {
                    ISOException.throwIt(SW_WRONG_LENGTH);
                if (apdu.setIncomingAndReceive() != lc) {
                    ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
                try { // copy the certificate to be verified from APDU buffer to cert object
                    Util.arrayCopyNonAtomic(buffer, OFFSET_CDATA, cert, (short) 0, lc);
                } catch (Exception e) {
                    ISOException.throwIt(SW_TAMAM);
                if (Util.arrayCompare(keyStore.selected_KID, (short) 0, keyStore.ERCA_KID, (short) 0, KID_LENGTH) == 0) {
                    keyStore.VUCA_Cert.verifyCert(cert, keyStore.selectedPublicKey, keyStore.selected_KID);
                } else if (Util.arrayCompare(keyStore.selected_KID, (short) 0, keyStore.VUCA_Cert.CHR, (short) 0, KID_LENGTH) == 0) {
                    keyStore.VU_Cert.verifyCert(cert, keyStore.selectedPublicKey, keyStore.selected_KID);
                } else {
                    ISOException.throwIt(SW_CERT_VERIFICATION_FAILED); // Selected keyId, with MSE, is neither ERCA_KID nor VUCA_KID
            } else {
                ISOException.throwIt(SW_CERT_VERIFICATION_FAILED);
            return;
        private short processGetChallenge(APDU apdu, boolean protectedApdu) {
            byte[] buffer = apdu.getBuffer();
            byte p1 = (byte) (buffer[OFFSET_P1] & 0xff);
            byte p2 = (byte) (buffer[OFFSET_P2] & 0xff);
            if (p1 != 0 || p2 != 0) {
                ISOException.throwIt(SW_WRONG_P1P2);
            random.generateData(Rnd3, (short) 0, (short) 8);
            short Le = apdu.setOutgoing();
            if (Le != (short) 8) {
                ISOException.throwIt(SW_WRONG_LENGTH);
            Util.arrayCopyNonAtomic(Rnd3, (short) 0, buffer, (short) 0, (short) 8);
            return Le;
        private void processMSE(APDU apdu) {
            byte[] buffer = apdu.getBuffer();
            if (buffer[OFFSET_P1] == (byte) 0xC1 && buffer[OFFSET_P2] == P2_DST) {
                short lc = (short) (buffer[OFFSET_LC] & 0xFF);
                if (lc != (short) (KID_LENGTH + 2)) {
                    ISOException.throwIt(SW_WRONG_LENGTH);
                if (apdu.setIncomingAndReceive() != lc) {
                    ISOException.throwIt(ISO7816.SW_WRONG_DATA);
                if (buffer[OFFSET_CDATA] != (byte) 0x83) {//check the tag of the data
                    ISOException.throwIt(SW_SECURE_MESSAGING_DATA_OBJECTS_MISSING);
                } else if (buffer[OFFSET_CDATA + 1] != (byte) 0x08) {
                    ISOException.throwIt(SW_INCORRECT_DATA_OBJECT); // check if the key is already selected one
                } else if (Util.arrayCompare(buffer, (short) (OFFSET_CDATA + 2), keyStore.selected_KID, (short) 0, KID_LENGTH) != 0) {
                    if (Util.arrayCompare(buffer, (short) (OFFSET_CDATA + 2), keyStore.ERCA_KID, (short) 0, KID_LENGTH) == 0) {// KID is EUR_KID
                        keyStore.selected_KID = keyStore.ERCA_KID;
                        keyStore.selectedPublicKey = keyStore.eurPublicKey;
                        keyStore.Selected_Cert = null; // ERCA public key is selected
                        return;
                    } else if (Util.arrayCompare(buffer, (short) (OFFSET_CDATA + 2), keyStore.VUCA_Cert.CHR, (short) 0, KID_LENGTH) == 0) {// KID is MSCA_KID
                        keyStore.Selected_Cert = keyStore.VUCA_Cert;
                    } else if (Util.arrayCompare(buffer, (short) (OFFSET_CDATA + 2), keyStore.VU_Cert.CHR, (short) 0, KID_LENGTH) == 0) { // KID is VU_KID
                        keyStore.Selected_Cert = keyStore.VU_Cert;
                    } else {
                        ISOException.throwIt(SW_REFERENCE_DATA_NOT_FOUND);
                    }// KID not found
                    keyStore.selectedPublicKey = keyStore.Selected_Cert.publicKey;
                    keyStore.selected_KID = keyStore.Selected_Cert.CHR;
                } else { // if the KID is already set, just return
                    return;
            } else {
                ISOException.throwIt(ISO7816.SW_WRONG_P1P2);
        private void processSelectFile(APDU apdu) {
            byte[] buffer = apdu.getBuffer();
            short lc = (short) (buffer[OFFSET_LC] & 0x00FF);
            // retrieve p1p2 from apdu buffer
            byte p1 = buffer[OFFSET_P1];
            byte p2 = buffer[OFFSET_P2];
            short p1p2 = Util.makeShort(p1, p2);
            apdu.setIncomingAndReceive();
            if (p1 == 4) {
                if (lc == (short) TACHO_AID_LENGTH) {
                    if (Util.arrayCompare(buffer, (short) OFFSET_CDATA, TACHOGRAPH_AID, (short) 0, (short) TACHO_AID_LENGTH) == 0) {
                        selectedFile = fileSystem.getDT();
                        fileSystem.selectDT();
                        volatileState[0] |= FILE_SELECTED;
                        return;
                    } else {
                        ISOException.throwIt(ISO7816.SW_WRONG_DATA);
                } else if (lc != 2) {
                    ISOException.throwIt(SW_WRONG_LENGTH);
                short fid = Util.getShort(buffer, OFFSET_CDATA);
                if (fileSystem.getFile(fid) != null) {
                    selectedFile = fileSystem.getDT();
                    fileSystem.selectDT();
                    volatileState[0] |= FILE_SELECTED;
                    return;
            } else if (p1 == 2) {
                if (lc != 2) {
                    ISOException.throwIt(SW_WRONG_LENGTH);
                short fid = Util.getShort(buffer, OFFSET_CDATA);
                if (fileSystem.getFile(fid) != null) {
                    selectedFile = fileSystem.getFile(fid);
                    volatileState[0] |= FILE_SELECTED;
                    return;
            } else {
                ISOException.throwIt(ISO7816.SW_WRONG_P1P2);
            setNoFileSelected();
            ISOException.throwIt(ISO7816.SW_FILE_NOT_FOUND);
        public static void setNoFileSelected() {
            if (hasFileSelected()) {
                volatileState[0] ^= FILE_SELECTED;
        public static boolean hasFileSelected() {
            return (volatileState[0] & FILE_SELECTED) == FILE_SELECTED;
        public static boolean hasMutuallyAuthenticated() {
            return (volatileState[0] & MUTUAL_AUTHENTICATED) == MUTUAL_AUTHENTICATED;
        static boolean isLocked() {
            return (persistentState & LOCKED) == LOCKED;
        public boolean isSelectedFileEncrypted() {
            return ((selectedFile.getAccessConditions() & DigitalTachograph.ENCRYPTED) == DigitalTachograph.ENCRYPTED);
    }

Maybe you are looking for

  • Error in saving invoice

    Hi I wrote an add-on that save an invoice when the user click on the add button in the invoice form (133). My program add automatically some additional expenses to the document. If I save the invoice with a VATGRoup as CA the invoice is created, if I

  • Route Pattern Add Question

    CUCM 9.1.2 I am trying to get a better understanding of what happens when you add a Route Pattern. When you click save a warning pops up saying "Any update to this Route Pattern automatically resets the associated gateway or route list." This pattern

  • Can BAPI Calls in a report trigger an IDOC using BAPI-ALE?

    Hi, I had a requirement to create PO using BAPI. The code is complete. But now I have to use an IDOc instead of BAPI since it is an asynchronous scenario. Is there any possible way that after CALL BAPI step in the report, an IDOc will be triggered. I

  • Contrct number in the billing doc

    We have revenure recognition implemented.We create contract and then billing and revenue recogniton.When the revenue recognition is done with VF44 against the contract ..hence the contract number is captured in the Revenue recogniton document.However

  • Is GarageBand somehow "warmer" by default?

    Hey all. Okay, I've just put together a little audio post production studio and am interfacing it with my Mac Pro. I basically have a set of BX5a Delulxe monitors, a Fast Track Ultra, a set of Ultimate Ears 'headphones,' and finally, a Sputnik Tube M